edit a trade order https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#amend-order-by-orderid :param str id: cancel order id :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or
(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={})
| 2829 | return self.parse_order(data, market) |
| 2830 | |
| 2831 | def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}): |
| 2832 | """ |
| 2833 | edit a trade order |
| 2834 | |
| 2835 | https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#amend-order-by-orderid |
| 2836 | |
| 2837 | :param str id: cancel order id |
| 2838 | :param str symbol: unified symbol of the market to create an order in |
| 2839 | :param str type: 'market' or 'limit' |
| 2840 | :param str side: 'buy' or 'sell' |
| 2841 | :param float amount: how much of currency you want to trade in units of base currency |
| 2842 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 2843 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2844 | :param str [params.posSide]: either 'Merged' or 'Long' or 'Short' |
| 2845 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 2846 | """ |
| 2847 | self.load_markets() |
| 2848 | market = self.market(symbol) |
| 2849 | request = { |
| 2850 | 'symbol': market['id'], |
| 2851 | } |
| 2852 | clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clOrdID') |
| 2853 | params = self.omit(params, ['clientOrderId', 'clOrdID']) |
| 2854 | isStableSettled = (market['settle'] == 'USDT') or (market['settle'] == 'USDC') |
| 2855 | if clientOrderId is not None: |
| 2856 | request['clOrdID'] = clientOrderId |
| 2857 | else: |
| 2858 | request['orderID'] = id |
| 2859 | if price is not None: |
| 2860 | if isStableSettled: |
| 2861 | request['priceRp'] = self.price_to_precision(market['symbol'], price) |
| 2862 | else: |
| 2863 | request['priceEp'] = self.to_ep(price, market) |
| 2864 | # Note the uppercase 'V' in 'baseQtyEV' request. that is exchange's requirement at self moment. However, to avoid mistakes from user side, let's support lowercased 'baseQtyEv' too |
| 2865 | finalQty = self.safe_string(params, 'baseQtyEv') |
| 2866 | params = self.omit(params, ['baseQtyEv']) |
| 2867 | if finalQty is not None: |
| 2868 | request['baseQtyEV'] = finalQty |
| 2869 | elif amount is not None: |
| 2870 | if isStableSettled: |
| 2871 | request['orderQtyRq'] = self.amount_to_precision(market['symbol'], amount) |
| 2872 | else: |
| 2873 | request['baseQtyEV'] = self.to_ev(amount, market) |
| 2874 | triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPx', 'stopPrice']) |
| 2875 | if triggerPrice is not None: |
| 2876 | if isStableSettled: |
| 2877 | request['stopPxRp'] = self.price_to_precision(symbol, triggerPrice) |
| 2878 | else: |
| 2879 | request['stopPxEp'] = self.to_ep(triggerPrice, market) |
| 2880 | params = self.omit(params, ['triggerPrice', 'stopPx', 'stopPrice']) |
| 2881 | response: dict |
| 2882 | if isStableSettled: |
| 2883 | posSide = self.safe_string(params, 'posSide') |
| 2884 | if posSide is None: |
| 2885 | request['posSide'] = 'Merged' |
| 2886 | response = self.privatePutGOrdersReplace(self.extend(request, params)) |
| 2887 | elif market['swap']: |
| 2888 | response = self.privatePutOrdersReplace(self.extend(request, params)) |
nothing calls this directly
no test coverage detected