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

Method cancel_order

python/ccxt/bitget.py:5655–5804  ·  view source on GitHub ↗

cancels an open order https://www.bitget.com/api-doc/spot/trade/Cancel-Order https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order https://www.bitget.com/api-doc/contract/trade/Cancel-Order https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order

(self, id: str, symbol: Str = None, params={})

Source from the content-addressed store, hash-verified

5653 return self.parse_order(data, market)
5654
5655 def cancel_order(self, id: str, symbol: Str = None, params={}):
5656 """
5657 cancels an open order
5658
5659 https://www.bitget.com/api-doc/spot/trade/Cancel-Order
5660 https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
5661 https://www.bitget.com/api-doc/contract/trade/Cancel-Order
5662 https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
5663 https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
5664 https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-Order
5665 https://www.bitget.com/api-doc/uta/trade/Cancel-Order
5666 https://www.bitget.com/api-doc/uta/strategy/Cancel-Strategy-Order
5667
5668 :param str id: order id
5669 :param str symbol: unified symbol of the market the order was made in
5670 :param dict [params]: extra parameters specific to the exchange API endpoint
5671 :param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
5672 :param boolean [params.trigger]: set to True for canceling trigger orders
5673 :param str [params.planType]: *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
5674 :param boolean [params.trailing]: set to True if you want to cancel a trailing order
5675 :param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
5676 :param str [params.clientOrderId]: the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
5677 :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
5678 """
5679 if symbol is None:
5680 raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
5681 self.load_markets()
5682 market = self.market(symbol)
5683 marginMode = None
5684 response = None
5685 marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
5686 request = {}
5687 trailing = self.safe_value(params, 'trailing')
5688 trigger = self.safe_value_2(params, 'stop', 'trigger')
5689 params = self.omit(params, ['stop', 'trigger', 'trailing'])
5690 if not (market['spot'] and trigger):
5691 request['symbol'] = market['id']
5692 uta = None
5693 uta, params = self.handle_option_and_params(params, 'cancelOrder', 'uta', False)
5694 isPlanOrder = trigger or trailing
5695 isContract = market['swap'] or market['future']
5696 isContractTriggerEndpoint = isContract and isPlanOrder and not uta
5697 clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOid')
5698 if isContractTriggerEndpoint:
5699 orderIdList = []
5700 orderId = {}
5701 if clientOrderId is not None:
5702 params = self.omit(params, 'clientOrderId')
5703 orderId['clientOid'] = clientOrderId
5704 else:
5705 orderId['orderId'] = id
5706 orderIdList.append(orderId)
5707 request['orderIdList'] = orderIdList
5708 else:
5709 if clientOrderId is not None:
5710 params = self.omit(params, 'clientOrderId')
5711 request['clientOid'] = clientOrderId
5712 else:

Callers

nothing calls this directly

Calls 15

parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
NotSupportedClass · 0.90
safe_valueMethod · 0.80
safe_value_2Method · 0.80
safe_string_2Method · 0.80
safe_stringMethod · 0.80

Tested by

no test coverage detected