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

Method fetch_convert_quote

python/ccxt/phemex.py:4899–4940  ·  view source on GitHub ↗

fetch a quote for converting from one currency to another https://phemex-docs.github.io/#rfq-quote :param str fromCode: the currency that you want to sell and convert from :param str toCode: the currency that you want to buy and convert into :param float am

(self, fromCode: str, toCode: str, amount: Num = None, params={})

Source from the content-addressed store, hash-verified

4897 }, market)
4898
4899 def fetch_convert_quote(self, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
4900 """
4901 fetch a quote for converting from one currency to another
4902
4903 https://phemex-docs.github.io/#rfq-quote
4904
4905 :param str fromCode: the currency that you want to sell and convert from
4906 :param str toCode: the currency that you want to buy and convert into
4907 :param float amount: how much you want to trade in units of the from currency
4908 :param dict [params]: extra parameters specific to the exchange API endpoint
4909 :returns dict: a `conversion structure <https://docs.ccxt.com/?id=conversion-structure>`
4910 """
4911 self.load_markets()
4912 fromCurrency = self.currency(fromCode)
4913 toCurrency = self.currency(toCode)
4914 valueScale = self.safe_integer(fromCurrency, 'valueScale')
4915 request = {
4916 'fromCurrency': fromCode,
4917 'toCurrency': toCode,
4918 'fromAmountEv': self.to_en(amount, valueScale),
4919 }
4920 response = self.privateGetAssetsQuote(self.extend(request, params))
4921 #
4922 # {
4923 # "code": 0,
4924 # "msg": "OK",
4925 # "data": {
4926 # "code": "GIF...AAA",
4927 # "quoteArgs": {
4928 # "origin": 10,
4929 # "price": "0.00000939",
4930 # "proceeds": "0.00000000",
4931 # "ttlMs": 7000,
4932 # "expireAt": 1739875826009,
4933 # "requestAt": 1739875818009,
4934 # "quoteAt": 1739875816594
4935 # }
4936 # }
4937 # }
4938 #
4939 data = self.safe_dict(response, 'data', {})
4940 return self.parse_conversion(data, fromCurrency, toCurrency)
4941
4942 def create_convert_trade(self, id: str, fromCode: str, toCode: str, amount: Num = None, params={}) -> Conversion:
4943 """

Callers

nothing calls this directly

Calls 8

to_enMethod · 0.95
parse_conversionMethod · 0.95
safe_integerMethod · 0.80
safe_dictMethod · 0.80
privateGetAssetsQuoteMethod · 0.65
load_marketsMethod · 0.45
currencyMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected