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

Method createOrder

js/src/pacifica.js:1277–1317  ·  view source on GitHub ↗

* @method * @name pacifica#createOrder * @description create a trade order * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order * @see https://docs.p

(symbol, type, side, amount, price = undefined, params = {})

Source from the content-addressed store, hash-verified

1275 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1276 */
1277 async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1278 await this.loadMarkets();
1279 await this.initializeClient();
1280 const [request, operationType] = this.createOrderRequest(symbol, type, side, amount, price, params);
1281 params = this.omit(params, [
1282 'reduceOnly', 'clientOrderId', 'stopLimitPrice', 'timeInForce', 'triggerPrice', 'stopLossCloid',
1283 'stopLossPrice', 'stopLossLimitPrice', 'takeProfitCloid', 'takeProfitPrice', 'takeProfitLimitPrice', 'expiryWindow',
1284 ]);
1285 let response = undefined;
1286 if (operationType === 'create_market_order') {
1287 response = await this.privatePostOrdersCreateMarket(this.extend(request, params));
1288 }
1289 else if (operationType === 'create_stop_order') {
1290 response = await this.privatePostOrdersStopCreate(this.extend(request, params));
1291 }
1292 else if (operationType === 'set_position_tpsl') {
1293 response = await this.privatePostPositionsTpsl(this.extend(request, params));
1294 }
1295 else { // create_order
1296 response = await this.privatePostOrdersCreate(this.extend(request, params));
1297 }
1298 //
1299 // {
1300 // 'success': true,
1301 // 'data': {
1302 // "order_id": 12345
1303 // },
1304 // }
1305 //
1306 const success = this.safeBool(response, 'success', false);
1307 let status = undefined;
1308 if (!success) {
1309 status = 'rejected';
1310 }
1311 else {
1312 status = 'open';
1313 }
1314 const order = this.safeDict(response, 'data', {});
1315 const orderId = this.safeString(order, 'order_id');
1316 return this.safeOrder({ 'id': orderId, 'status': status, 'info': response, 'symbol': symbol });
1317 }
1318 createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1319 /**
1320 * @method

Callers

nothing calls this directly

Calls 13

initializeClientMethod · 0.95
createOrderRequestMethod · 0.95
loadMarketsMethod · 0.45
omitMethod · 0.45
extendMethod · 0.45
safeBoolMethod · 0.45
safeDictMethod · 0.45
safeStringMethod · 0.45

Tested by

no test coverage detected