* @method * @name whitebit#editOrder * @description edit a trade order * @see https://docs.whitebit.com/private/http-trade-v4/#modify-order * @param {string} id cancel order id * @param {string} symbol unified symbol of the market to create an order in * @param {string}
(id: string, symbol: string, type: OrderType, side: OrderSide, amount: Num = undefined, price: Num = undefined, params = {})
| 2070 | * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure} |
| 2071 | */ |
| 2072 | async editOrder (id: string, symbol: string, type: OrderType, side: OrderSide, amount: Num = undefined, price: Num = undefined, params = {}) { |
| 2073 | await this.loadMarkets (); |
| 2074 | const market = this.market (symbol); |
| 2075 | const request: Dict = { |
| 2076 | 'market': market['id'], |
| 2077 | }; |
| 2078 | // Handle clientOrderId vs orderId (clientOrderId takes priority) |
| 2079 | const clientOrderId = this.safeString (params, 'clientOrderId'); |
| 2080 | if (clientOrderId !== undefined) { |
| 2081 | request['clientOrderId'] = clientOrderId; |
| 2082 | } else { |
| 2083 | request['orderId'] = id; |
| 2084 | } |
| 2085 | // Handle amount vs total parameter based on order type and side |
| 2086 | const triggerPrice = this.safeNumberN (params, [ 'triggerPrice', 'stopPrice', 'activationPrice' ]); |
| 2087 | const isStopOrder = (triggerPrice !== undefined); |
| 2088 | // Handle activation price for stop orders |
| 2089 | if (isStopOrder) { |
| 2090 | request['activation_price'] = this.priceToPrecision (symbol, triggerPrice); |
| 2091 | } |
| 2092 | const isLimitOrder = type === 'limit'; |
| 2093 | const total = this.safeNumber (params, 'total'); |
| 2094 | if (total !== undefined) { |
| 2095 | request['total'] = this.amountToPrecision (symbol, total); |
| 2096 | } else if (amount !== undefined) { |
| 2097 | if (isLimitOrder) { |
| 2098 | // Limit orders always use amount parameter |
| 2099 | request['amount'] = this.amountToPrecision (symbol, amount); |
| 2100 | } else if (type === 'market' && side === 'buy') { |
| 2101 | // Market buy orders use total parameter |
| 2102 | request['total'] = this.amountToPrecision (symbol, amount); |
| 2103 | } else { |
| 2104 | // Market sell orders use amount parameter |
| 2105 | request['amount'] = this.amountToPrecision (symbol, amount); |
| 2106 | } |
| 2107 | } |
| 2108 | // Handle price parameter for limit orders |
| 2109 | if (price !== undefined) { |
| 2110 | request['price'] = this.priceToPrecision (symbol, price); |
| 2111 | } |
| 2112 | // Ensure at least one modifiable parameter is provided |
| 2113 | const hasModifiableParam = (amount !== undefined) || (price !== undefined) || (triggerPrice !== undefined) || (total !== undefined); |
| 2114 | if (!hasModifiableParam) { |
| 2115 | throw new ArgumentsRequired (this.id + ' editOrder() requires at least one of: amount, price, activationPrice, or total parameters'); |
| 2116 | } |
| 2117 | params = this.omit (params, [ 'clientOrderId', 'triggerPrice', 'stopPrice', 'activationPrice', 'total' ]); |
| 2118 | const response = await this.v4PrivatePostOrderModify (this.extend (request, params)); |
| 2119 | return this.parseOrder (response); |
| 2120 | } |
| 2121 | |
| 2122 | /** |
| 2123 | * @method |
nothing calls this directly
no test coverage detected