MCPcopy Create free account
hub / github.com/ccxt/ccxt / createOrderWs

Method createOrderWs

js/src/pro/pacifica.js:99–161  ·  view source on GitHub ↗

* @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 = {})

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 9

createOrderRequestMethod · 0.95
wrapAsPostActionMethod · 0.95
loadMarketsMethod · 0.45
omitMethod · 0.45
safeStringMethod · 0.45
watchMethod · 0.45
safeIntegerMethod · 0.45
safeDictMethod · 0.45
safeOrderMethod · 0.45

Tested by

no test coverage detected