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

Method fetch_convert_trade

python/ccxt/binance.py:13365–13435  ·  view source on GitHub ↗

fetch the data for a conversion trade https://developers.binance.com/docs/convert/trade/Order-Status :param str id: the id of the trade that you want to fetch :param str [code]: the unified currency code of the conversion trade :param dict [params]: extra p

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

Source from the content-addressed store, hash-verified

13363 return self.parse_conversion(response, fromCurrency, toCurrency)
13364
13365 def fetch_convert_trade(self, id: str, code: Str = None, params={}) -> Conversion:
13366 """
13367 fetch the data for a conversion trade
13368
13369 https://developers.binance.com/docs/convert/trade/Order-Status
13370
13371 :param str id: the id of the trade that you want to fetch
13372 :param str [code]: the unified currency code of the conversion trade
13373 :param dict [params]: extra parameters specific to the exchange API endpoint
13374 :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
13375 """
13376 self.load_markets()
13377 request = {}
13378 response = None
13379 if code == 'BUSD':
13380 msInDay = 86400000
13381 now = self.milliseconds()
13382 if code is not None:
13383 currency = self.currency(code)
13384 request['asset'] = currency['id']
13385 request['tranId'] = id
13386 request['startTime'] = now - msInDay
13387 request['endTime'] = now
13388 response = self.sapiGetAssetConvertTransferQueryByPage(self.extend(request, params))
13389 #
13390 # {
13391 # "total": 3,
13392 # "rows": [
13393 # {
13394 # "tranId": 118263615991,
13395 # "type": 244,
13396 # "time": 1664442078000,
13397 # "deductedAsset": "BUSD",
13398 # "deductedAmount": "1",
13399 # "targetAsset": "USDC",
13400 # "targetAmount": "1",
13401 # "status": "S",
13402 # "accountType": "MAIN"
13403 # },
13404 # ]
13405 # }
13406 #
13407 else:
13408 request['orderId'] = id
13409 response = self.sapiGetConvertOrderStatus(self.extend(request, params))
13410 #
13411 # {
13412 # "orderId":933256278426274426,
13413 # "orderStatus":"SUCCESS",
13414 # "fromAsset":"BTC",
13415 # "fromAmount":"0.00054414",
13416 # "toAsset":"USDT",
13417 # "toAmount":"20",
13418 # "ratio":"36755",
13419 # "inverseRatio":"0.00002721",
13420 # "createTime":1623381330472
13421 # }
13422 #

Callers

nothing calls this directly

Calls 10

parse_conversionMethod · 0.95
safe_listMethod · 0.80
safe_dictMethod · 0.80
safe_string_2Method · 0.80
load_marketsMethod · 0.45
millisecondsMethod · 0.45
currencyMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected