* @method * @name binance#fetchConvertQuote * @description fetch a quote for converting from one currency to another * @see https://developers.binance.com/docs/convert/trade/Send-quote-request * @param {string} fromCode the currency that you want to sell and convert from * @
(fromCode: string, toCode: string, amount: Num = undefined, params = {})
| 14075 | * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure} |
| 14076 | */ |
| 14077 | async fetchConvertQuote (fromCode: string, toCode: string, amount: Num = undefined, params = {}): Promise<Conversion> { |
| 14078 | if (amount === undefined) { |
| 14079 | throw new ArgumentsRequired (this.id + ' fetchConvertQuote() requires an amount argument'); |
| 14080 | } |
| 14081 | await this.loadMarkets (); |
| 14082 | const request: Dict = { |
| 14083 | 'fromAsset': fromCode, |
| 14084 | 'toAsset': toCode, |
| 14085 | 'fromAmount': amount, |
| 14086 | }; |
| 14087 | const response = await this.sapiPostConvertGetQuote (this.extend (request, params)); |
| 14088 | // |
| 14089 | // { |
| 14090 | // "quoteId":"12415572564", |
| 14091 | // "ratio":"38163.7", |
| 14092 | // "inverseRatio":"0.0000262", |
| 14093 | // "validTimestamp":1623319461670, |
| 14094 | // "toAmount":"3816.37", |
| 14095 | // "fromAmount":"0.1" |
| 14096 | // } |
| 14097 | // |
| 14098 | const fromCurrency = this.currency (fromCode); |
| 14099 | const toCurrency = this.currency (toCode); |
| 14100 | return this.parseConversion (response, fromCurrency, toCurrency); |
| 14101 | } |
| 14102 | |
| 14103 | /** |
| 14104 | * @method |
nothing calls this directly
no test coverage detected