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

Method edit_order

python/ccxt/async_support/xt.py:4709–4795  ·  view source on GitHub ↗

cancels an order and places a new order https://doc.xt.com/#orderorderUpdate https://doc.xt.com/#futures_orderupdate https://doc.xt.com/#futures_entrustupdateProfit :param str id: order id :param str symbol: unified symbol of the market to create an

(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={})

Source from the content-addressed store, hash-verified

4707 return response # unify return type
4708
4709 async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
4710 """
4711 cancels an order and places a new order
4712
4713 https://doc.xt.com/#orderorderUpdate
4714 https://doc.xt.com/#futures_orderupdate
4715 https://doc.xt.com/#futures_entrustupdateProfit
4716
4717 :param str id: order id
4718 :param str symbol: unified symbol of the market to create an order in
4719 :param str type: 'market' or 'limit'
4720 :param str side: 'buy' or 'sell'
4721 :param float amount: how much of the currency you want to trade in units of the base currency
4722 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4723 :param dict [params]: extra parameters specific to the exchange API endpoint
4724 :param float [params.stopLoss]: price to set a stop-loss on an open position
4725 :param float [params.takeProfit]: price to set a take-profit on an open position
4726 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
4727 """
4728 if amount is None:
4729 raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
4730 await self.load_markets()
4731 market = self.market(symbol)
4732 request = {}
4733 stopLoss = self.safe_number_2(params, 'stopLoss', 'triggerStopPrice')
4734 takeProfit = self.safe_number_2(params, 'takeProfit', 'triggerProfitPrice')
4735 params = self.omit(params, ['stopLoss', 'takeProfit'])
4736 isStopLoss = (stopLoss is not None)
4737 isTakeProfit = (takeProfit is not None)
4738 if isStopLoss or isTakeProfit:
4739 request['profitId'] = id
4740 else:
4741 request['orderId'] = id
4742 request['price'] = self.price_to_precision(symbol, price)
4743 response = None
4744 if market['swap']:
4745 if isStopLoss:
4746 request['triggerStopPrice'] = self.price_to_precision(symbol, stopLoss)
4747 elif takeProfit is not None:
4748 request['triggerProfitPrice'] = self.price_to_precision(symbol, takeProfit)
4749 else:
4750 request['origQty'] = self.amount_to_precision(symbol, amount)
4751 subType = None
4752 subType, params = self.handle_sub_type_and_params('editOrder', market, params)
4753 if subType == 'inverse':
4754 if isStopLoss or isTakeProfit:
4755 response = await self.privateInversePostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
4756 else:
4757 response = await self.privateInversePostFutureTradeV1OrderUpdate(self.extend(request, params))
4758 #
4759 # {
4760 # "returnCode": 0,
4761 # "msgInfo": "success",
4762 # "error": null,
4763 # "result": "483869474947826752"
4764 # }
4765 #
4766 else:

Callers

nothing calls this directly

Tested by

no test coverage detected