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

Method fetch_convert_trade

python/ccxt/bybit.py:8840–8898  ·  view source on GitHub ↗

fetch the data for a conversion trade https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-result :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 [param

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

Source from the content-addressed store, hash-verified

8838 return self.parse_conversion(data)
8839
8840 def fetch_convert_trade(self, id: str, code: Str = None, params={}) -> Conversion:
8841 """
8842 fetch the data for a conversion trade
8843
8844 https://bybit-exchange.github.io/docs/v5/asset/convert/get-convert-result
8845
8846 :param str id: the id of the trade that you want to fetch
8847 :param str [code]: the unified currency code of the conversion trade
8848 :param dict [params]: extra parameters specific to the exchange API endpoint
8849 :param str [params.accountType]: eb_convert_uta, eb_convert_spot, eb_convert_funding, eb_convert_inverse, or eb_convert_contract
8850 :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
8851 """
8852 self.load_markets()
8853 accountType = None
8854 enableUnifiedMargin, enableUnifiedAccount = self.is_unified_enabled()
8855 isUnifiedAccount = (enableUnifiedMargin or enableUnifiedAccount)
8856 accountTypeDefault = 'eb_convert_uta' if isUnifiedAccount else 'eb_convert_spot'
8857 accountType, params = self.handle_option_and_params(params, 'fetchConvertQuote', 'accountType', accountTypeDefault)
8858 request = {
8859 'quoteTxId': id,
8860 'accountType': accountType,
8861 }
8862 response = self.privateGetV5AssetExchangeConvertResultQuery(self.extend(request, params))
8863 #
8864 # {
8865 # "retCode": 0,
8866 # "retMsg": "ok",
8867 # "result": {
8868 # "result": {
8869 # "accountType": "eb_convert_uta",
8870 # "exchangeTxId": "1010020692439483803499737088",
8871 # "userId": "100406395",
8872 # "fromCoin": "USDT",
8873 # "fromCoinType": "crypto",
8874 # "fromAmount": "10",
8875 # "toCoin": "BTC",
8876 # "toCoinType": "crypto",
8877 # "toAmount": "0.00015344889",
8878 # "exchangeStatus": "success",
8879 # "extInfo": {},
8880 # "convertRate": "0.000015344889",
8881 # "createdAt": "1727257904726"
8882 # }
8883 # },
8884 # "retExtInfo": {},
8885 # "time": 1727258257216
8886 # }
8887 #
8888 data = self.safe_dict(response, 'result', {})
8889 result = self.safe_dict(data, 'result', {})
8890 fromCurrencyId = self.safe_string(result, 'fromCoin')
8891 toCurrencyId = self.safe_string(result, 'toCoin')
8892 fromCurrency = None
8893 toCurrency = None
8894 if fromCurrencyId is not None:
8895 fromCurrency = self.currency(fromCurrencyId)
8896 if toCurrencyId is not None:
8897 toCurrency = self.currency(toCurrencyId)

Callers

nothing calls this directly

Calls 9

is_unified_enabledMethod · 0.95
parse_conversionMethod · 0.95
safe_dictMethod · 0.80
safe_stringMethod · 0.80
load_marketsMethod · 0.45
extendMethod · 0.45
currencyMethod · 0.45

Tested by

no test coverage detected