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

Method cancel_order

python/ccxt/derive.py:1504–1590  ·  view source on GitHub ↗

https://docs.derive.xyz/reference/post_private-cancel cancels an open order :param str id: order id :param str symbol: unified symbol of the market the order was made in :param dict [params]: extra parameters specific to the exchange API endpoint :p

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

Source from the content-addressed store, hash-verified

1502 return order
1503
1504 def cancel_order(self, id: str, symbol: Str = None, params={}):
1505 """
1506
1507 https://docs.derive.xyz/reference/post_private-cancel
1508
1509 cancels an open order
1510 :param str id: order id
1511 :param str symbol: unified symbol of the market the order was made in
1512 :param dict [params]: extra parameters specific to the exchange API endpoint
1513 :param boolean [params.trigger]: whether the order is a trigger/algo order
1514 :param str [params.subaccount_id]: *required* the subaccount id
1515 :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
1516 """
1517 if symbol is None:
1518 raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
1519 self.load_markets()
1520 market = self.market(symbol)
1521 isTrigger = self.safe_bool_2(params, 'trigger', 'stop', False)
1522 subaccountId = None
1523 subaccountId, params = self.handle_derive_subaccount_id('cancelOrder', params)
1524 params = self.omit(params, ['trigger', 'stop'])
1525 request = {
1526 'instrument_name': market['id'],
1527 'subaccount_id': subaccountId,
1528 }
1529 clientOrderIdUnified = self.safe_string(params, 'clientOrderId')
1530 clientOrderIdExchangeSpecific = self.safe_string(params, 'label', clientOrderIdUnified)
1531 isByClientOrder = clientOrderIdExchangeSpecific is not None
1532 response: dict
1533 if isByClientOrder:
1534 request['label'] = clientOrderIdExchangeSpecific
1535 params = self.omit(params, ['clientOrderId', 'label'])
1536 response = self.privatePostCancelByLabel(self.extend(request, params))
1537 else:
1538 request['order_id'] = id
1539 if isTrigger:
1540 response = self.privatePostCancelTriggerOrder(self.extend(request, params))
1541 else:
1542 response = self.privatePostCancel(self.extend(request, params))
1543 #
1544 # {
1545 # "result": {
1546 # "subaccount_id": 130837,
1547 # "order_id": "de4f30b6-0dcb-4df6-9222-c1a27f1ad80d",
1548 # "instrument_name": "BTC-PERP",
1549 # "direction": "buy",
1550 # "label": "test1234",
1551 # "quote_id": null,
1552 # "creation_timestamp": 1737540100989,
1553 # "last_update_timestamp": 1737540574696,
1554 # "limit_price": "10000",
1555 # "amount": "0.01",
1556 # "filled_amount": "0",
1557 # "average_price": "0",
1558 # "order_fee": "0",
1559 # "order_type": "limit",
1560 # "time_in_force": "post_only",
1561 # "order_status": "cancelled",

Callers

nothing calls this directly

Calls 13

parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_bool_2Method · 0.80
safe_stringMethod · 0.80
safe_dictMethod · 0.80
privatePostCancelMethod · 0.65
load_marketsMethod · 0.45
marketMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected