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

Method editOrder

ts/src/modetrade.ts:1703–1763  ·  view source on GitHub ↗

* @method * @name modetrade#editOrder * @description edit a trade order * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/edit-order * @see https://orderly.network/docs/build-on-evm/evm-api/restful-api/private/edit-algo-order * @param {string} id o

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

Source from the content-addressed store, hash-verified

1701 * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1702 */
1703 async editOrder (id: string, symbol: string, type:OrderType, side: OrderSide, amount: Num = undefined, price: Num = undefined, params = {}) {
1704 await this.loadMarkets ();
1705 const market = this.market (symbol);
1706 const request: Dict = {
1707 'order_id': id,
1708 };
1709 const triggerPrice = this.safeStringN (params, [ 'triggerPrice', 'stopPrice', 'takeProfitPrice', 'stopLossPrice' ]);
1710 if (triggerPrice !== undefined) {
1711 request['triggerPrice'] = this.priceToPrecision (symbol, triggerPrice);
1712 }
1713 const isConditional = (triggerPrice !== undefined) || (this.safeValue (params, 'childOrders') !== undefined);
1714 const orderQtyKey = isConditional ? 'quantity' : 'order_quantity';
1715 const priceKey = isConditional ? 'price' : 'order_price';
1716 if (price !== undefined) {
1717 request[priceKey] = this.priceToPrecision (symbol, price);
1718 }
1719 if (amount !== undefined) {
1720 request[orderQtyKey] = this.amountToPrecision (symbol, amount);
1721 }
1722 params = this.omit (params, [ 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice', 'trailingTriggerPrice', 'trailingAmount', 'trailingPercent' ]);
1723 let response = undefined;
1724 if (isConditional) {
1725 response = await this.v1PrivatePutAlgoOrder (this.extend (request, params));
1726 } else {
1727 request['symbol'] = market['id'];
1728 request['side'] = side.toUpperCase ();
1729 const orderType = type.toUpperCase ();
1730 const timeInForce = this.safeStringLower (params, 'timeInForce');
1731 const isMarket = orderType === 'MARKET';
1732 const postOnly = this.isPostOnly (isMarket, undefined, params);
1733 if (postOnly) {
1734 request['order_type'] = 'POST_ONLY';
1735 } else if (timeInForce === 'fok') {
1736 request['order_type'] = 'FOK';
1737 } else if (timeInForce === 'ioc') {
1738 request['order_type'] = 'IOC';
1739 } else {
1740 request['order_type'] = orderType;
1741 }
1742 const clientOrderId = this.safeStringN (params, [ 'clOrdID', 'clientOrderId', 'client_order_id' ]);
1743 params = this.omit (params, [ 'clOrdID', 'clientOrderId', 'client_order_id', 'postOnly', 'timeInForce' ]);
1744 if (clientOrderId !== undefined) {
1745 request['client_order_id'] = clientOrderId;
1746 }
1747 // request['side'] = side.toUpperCase ();
1748 // request['symbol'] = market['id'];
1749 response = await this.v1PrivatePutOrder (this.extend (request, params));
1750 }
1751 //
1752 // {
1753 // "success": true,
1754 // "timestamp": 1702989203989,
1755 // "data": {
1756 // "status": "EDIT_SENT"
1757 // }
1758 // }
1759 //
1760 const data = this.safeDict (response, 'data', {});

Callers

nothing calls this directly

Calls 15

parseOrderMethod · 0.95
v1PrivatePutAlgoOrderMethod · 0.65
v1PrivatePutOrderMethod · 0.65
loadMarketsMethod · 0.45
marketMethod · 0.45
safeStringNMethod · 0.45
priceToPrecisionMethod · 0.45
safeValueMethod · 0.45
amountToPrecisionMethod · 0.45
omitMethod · 0.45
extendMethod · 0.45
safeStringLowerMethod · 0.45

Tested by

no test coverage detected