* @method * @name pacifica#createOrderWs * @description create a trade order * @see https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/create-market-order * @see https://docs.pacifica.fi/api-documentation/api/websocket/trading-operations/create-limit-orde
(symbol, type, side, amount, price = undefined, params = {})
| 97 | * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure} |
| 98 | */ |
| 99 | async createOrderWs(symbol, type, side, amount, price = undefined, params = {}) { |
| 100 | await this.loadMarkets(); |
| 101 | const [request, operationType] = this.createOrderRequest(symbol, type, side, amount, price, params); |
| 102 | params = this.omit(params, [ |
| 103 | 'reduceOnly', 'clientOrderId', 'stopLimitPrice', 'timeInForce', 'triggerPrice', 'stopLossCloid', |
| 104 | 'stopLossPrice', 'stopLossLimitPrice', 'takeProfitCloid', 'takeProfitPrice', 'takeProfitLimitPrice', 'expiryWindow', 'agentAddress', 'originAddress', |
| 105 | ]); |
| 106 | const isTestnet = this.isSandboxModeEnabled; |
| 107 | const urlKey = (isTestnet) ? 'test' : 'api'; |
| 108 | const url = this.urls[urlKey]['ws']['public']; |
| 109 | const wsRequest = this.wrapAsPostAction(operationType, request); |
| 110 | const requestId = this.safeString(wsRequest, 'id'); |
| 111 | if (operationType === 'create_stop_order') { |
| 112 | throw new NotSupported(this.id + ' createOrderWs() do not support stop order type of order. Check provided arguments correctly!'); |
| 113 | } |
| 114 | else if (operationType === 'set_position_tpsl') { |
| 115 | throw new NotSupported(this.id + ' createOrderWs() do not support set position tpsl type of order. Check provided arguments correctly!'); |
| 116 | } |
| 117 | const response = await this.watch(url, requestId, wsRequest, requestId); |
| 118 | // |
| 119 | // market order |
| 120 | // { |
| 121 | // "code": 200, |
| 122 | // "data": { |
| 123 | // "I": "79f948fd-7556-4066-a128-083f3ea49322", |
| 124 | // "i": 645953, |
| 125 | // "s": "BTC" |
| 126 | // }, |
| 127 | // "id": "660065de-8f32-46ad-ba1e-83c93d3e3966", |
| 128 | // "t": 1749223025962, |
| 129 | // "type": "create_market_order" |
| 130 | // } |
| 131 | // |
| 132 | // limit order |
| 133 | // { |
| 134 | // "code": 200, |
| 135 | // "data": { |
| 136 | // "I": "79f948fd-7556-4066-a128-083f3ea49322", |
| 137 | // "i": 645953, |
| 138 | // "s": "BTC" |
| 139 | // }, |
| 140 | // "id": "660065de-8f32-46ad-ba1e-83c93d3e3966", |
| 141 | // "t": 1749223025962, |
| 142 | // "type": "create_order" |
| 143 | // } |
| 144 | // |
| 145 | const code = this.safeInteger(response, 'code'); |
| 146 | let success = false; |
| 147 | if (code === 200) { |
| 148 | success = true; |
| 149 | } |
| 150 | let status = undefined; |
| 151 | if (!success) { |
| 152 | status = 'rejected'; |
| 153 | } |
| 154 | else { |
| 155 | status = 'open'; |
| 156 | } |
nothing calls this directly
no test coverage detected