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

Method cancel_order

python/ccxt/async_support/derive.py:1505–1591  ·  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

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