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

Method cancel_order

python/ccxt/lighter.py:2888–2930  ·  view source on GitHub ↗

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 :param str [params.accountIndex]: account index :param str

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

Source from the content-addressed store, hash-verified

2886 return self.publicPostSendTx(request)
2887
2888 def cancel_order(self, id: str, symbol: Str = None, params={}):
2889 """
2890 cancels an open order
2891 :param str id: order id
2892 :param str symbol: unified symbol of the market the order was made in
2893 :param dict [params]: extra parameters specific to the exchange API endpoint
2894 :param str [params.accountIndex]: account index
2895 :param str [params.apiKeyIndex]: api key index
2896 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
2897 """
2898 self.load_markets()
2899 apiKeyIndex = None
2900 apiKeyIndex, params = self.handle_api_key_index(params, 'cancelOrder', 'apiKeyIndex', 'api_key_index')
2901 if symbol is None:
2902 raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
2903 market = self.market(symbol)
2904 clientOrderId = self.safe_string_2(params, 'client_order_index', 'clientOrderId')
2905 params = self.omit(params, ['client_order_index', 'clientOrderId'])
2906 accountIndex = None
2907 accountIndex, params = self.handle_account_index(params, 'cancelOrder', 'accountIndex', 'account_index')
2908 strAccountIndex = self.number_to_string(accountIndex)
2909 strApiKeyIndex = self.number_to_string(apiKeyIndex)
2910 signer = self.load_account(self.options['chainId'], self.get_lighter_private_key(strAccountIndex, strApiKeyIndex), strApiKeyIndex, strAccountIndex, params)
2911 nonce = self.fetch_nonce(accountIndex, apiKeyIndex, params)
2912 signRaw = {
2913 'market_index': self.parse_to_int(market['id']),
2914 'nonce': nonce,
2915 'api_key_index': apiKeyIndex,
2916 'account_index': accountIndex,
2917 }
2918 if clientOrderId is not None:
2919 signRaw['order_index'] = self.parse_to_int(clientOrderId)
2920 elif id is not None:
2921 signRaw['order_index'] = self.parse_to_int(id)
2922 else:
2923 raise ArgumentsRequired(self.id + ' cancelOrder requires order id or client order id')
2924 txType, txInfo = self.lighter_sign_cancel_order(signer, self.extend(signRaw, params))
2925 request = {
2926 'tx_type': txType,
2927 'tx_info': txInfo,
2928 }
2929 response = self.publicPostSendTx(request)
2930 return self.parse_order(response, market)
2931
2932 def cancel_all_orders(self, symbol: Str = None, params={}):
2933 """

Callers

nothing calls this directly

Calls 15

handle_api_key_indexMethod · 0.95
handle_account_indexMethod · 0.95
load_accountMethod · 0.95
fetch_nonceMethod · 0.95
parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90
safe_string_2Method · 0.80
parse_to_intMethod · 0.80
publicPostSendTxMethod · 0.65
load_marketsMethod · 0.45

Tested by

no test coverage detected