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

Method fetch_order

python/ccxt/binance.py:6691–6764  ·  view source on GitHub ↗

fetches information on an order made by the user https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#query-order-user_data https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Order https://devel

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

Source from the content-addressed store, hash-verified

6689 return self.create_order(symbol, 'market', 'sell', cost, None, params)
6690
6691 def fetch_order(self, id: str, symbol: Str = None, params={}):
6692 """
6693 fetches information on an order made by the user
6694
6695 https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#query-order-user_data
6696 https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Order
6697 https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api/Query-Order
6698 https://developers.binance.com/docs/derivatives/option/trade/Query-Single-Order
6699 https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
6700 https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-UM-Order
6701 https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Query-CM-Order
6702 https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Query-Algo-Order
6703
6704 :param str id: the order id
6705 :param str symbol: unified symbol of the market the order was made in
6706 :param dict [params]: extra parameters specific to the exchange API endpoint
6707 :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading
6708 :param boolean [params.portfolioMargin]: set to True if you would like to fetch an order in a portfolio margin account
6709 :param boolean [params.trigger]: set to True if you would like to fetch a trigger or conditional order
6710 :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>`
6711 """
6712 if symbol is None:
6713 raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
6714 self.load_markets()
6715 market = self.market(symbol)
6716 defaultType = self.safe_string_2(self.options, 'fetchOrder', 'defaultType', 'spot')
6717 type = self.safe_string(params, 'type', defaultType)
6718 marginMode = None
6719 marginMode, params = self.handle_margin_mode_and_params('fetchOrder', params)
6720 isPortfolioMargin = None
6721 isPortfolioMargin, params = self.handle_option_and_params_2(params, 'fetchOrder', 'papi', 'portfolioMargin', False)
6722 request = {
6723 'symbol': market['id'],
6724 }
6725 isConditional = self.safe_bool_n(params, ['stop', 'trigger', 'conditional'])
6726 clientOrderId = self.safe_string_n(params, ['origClientOrderId', 'clientOrderId', 'clientAlgoId'])
6727 if clientOrderId is not None:
6728 if market['option']:
6729 request['clientOrderId'] = clientOrderId
6730 elif market['linear'] and market['swap'] and isConditional and not isPortfolioMargin:
6731 request['clientAlgoId'] = clientOrderId
6732 else:
6733 request['origClientOrderId'] = clientOrderId
6734 elif market['linear'] and market['swap'] and isConditional and not isPortfolioMargin:
6735 request['algoId'] = id
6736 else:
6737 request['orderId'] = id
6738 params = self.omit(params, ['type', 'clientOrderId', 'origClientOrderId', 'stop', 'trigger', 'conditional', 'clientAlgoId'])
6739 response = None
6740 if market['option']:
6741 response = self.eapiPrivateGetOrder(self.extend(request, params))
6742 elif market['linear']:
6743 if isPortfolioMargin:
6744 response = self.papiGetUmOrder(self.extend(request, params))
6745 else:
6746 if isConditional:
6747 response = self.fapiPrivateGetAlgoOrder(self.extend(request, params))
6748 else:

Callers

nothing calls this directly

Calls 15

marketMethod · 0.95
eapiPrivateGetOrderMethod · 0.95
papiGetUmOrderMethod · 0.95
fapiPrivateGetOrderMethod · 0.95
papiGetCmOrderMethod · 0.95
dapiPrivateGetOrderMethod · 0.95
papiGetMarginOrderMethod · 0.95
sapiGetMarginOrderMethod · 0.95
privateGetOrderMethod · 0.95
parse_orderMethod · 0.95
ArgumentsRequiredClass · 0.90

Tested by

no test coverage detected