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

Method createOrder

ts/src/modetrade.ts:1581–1627  ·  view source on GitHub ↗

* @method * @name modetrade#createOrder * @description create a trade order * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/create-order * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/create-algo-order * @param {stri

(symbol: string, type: OrderType, side: OrderSide, amount: number, price: Num = undefined, params = {})

Source from the content-addressed store, hash-verified

1579 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1580 */
1581 async createOrder (symbol: string, type: OrderType, side: OrderSide, amount: number, price: Num = undefined, params = {}) {
1582 await this.loadMarkets ();
1583 const market = this.market (symbol);
1584 const request = this.createOrderRequest (symbol, type, side, amount, price, params);
1585 const triggerPrice = this.safeString2 (params, 'triggerPrice', 'stopPrice');
1586 const stopLoss = this.safeValue (params, 'stopLoss');
1587 const takeProfit = this.safeValue (params, 'takeProfit');
1588 const isConditional = triggerPrice !== undefined || stopLoss !== undefined || takeProfit !== undefined || (this.safeValue (params, 'childOrders') !== undefined);
1589 let response = undefined;
1590 if (isConditional) {
1591 response = await this.v1PrivatePostAlgoOrder (request);
1592 //
1593 // {
1594 // "success": true,
1595 // "timestamp": 1702989203989,
1596 // "data": {
1597 // "order_id": 13,
1598 // "client_order_id": "testclientid",
1599 // "algo_type": "STOP",
1600 // "quantity": 100.12
1601 // }
1602 // }
1603 //
1604 } else {
1605 response = await this.v1PrivatePostOrder (request);
1606 //
1607 // {
1608 // "success": true,
1609 // "timestamp": 1702989203989,
1610 // "data": {
1611 // "order_id": 13,
1612 // "client_order_id": "testclientid",
1613 // "order_type": "LIMIT",
1614 // "order_price": 100.12,
1615 // "order_quantity": 0.987654,
1616 // "order_amount": 0.8,
1617 // "error_message": "none"
1618 // }
1619 // }
1620 //
1621 }
1622 const data = this.safeDict (response, 'data', {});
1623 data['timestamp'] = this.safeInteger (response, 'timestamp');
1624 const order = this.parseOrder (data, market);
1625 order['type'] = type;
1626 return order;
1627 }
1628
1629 /**
1630 * @method

Callers

nothing calls this directly

Calls 10

createOrderRequestMethod · 0.95
parseOrderMethod · 0.95
v1PrivatePostOrderMethod · 0.65
loadMarketsMethod · 0.45
marketMethod · 0.45
safeString2Method · 0.45
safeValueMethod · 0.45
safeDictMethod · 0.45
safeIntegerMethod · 0.45

Tested by

no test coverage detected