ccxt 4.2.93 → 4.2.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,6 +57,8 @@ class woo extends woo$1 {
57
57
  'fetchCanceledOrders': false,
58
58
  'fetchClosedOrder': false,
59
59
  'fetchClosedOrders': true,
60
+ 'fetchConvertCurrencies': true,
61
+ 'fetchConvertQuote': true,
60
62
  'fetchCurrencies': true,
61
63
  'fetchDepositAddress': true,
62
64
  'fetchDeposits': true,
@@ -2985,6 +2987,143 @@ class woo extends woo$1 {
2985
2987
  'takeProfitPrice': undefined,
2986
2988
  });
2987
2989
  }
2990
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
2991
+ /**
2992
+ * @method
2993
+ * @name woo#fetchConvertQuote
2994
+ * @description fetch a quote for converting from one currency to another
2995
+ * @see https://docs.woo.org/#get-quote-rfq
2996
+ * @param {string} fromCode the currency that you want to sell and convert from
2997
+ * @param {string} toCode the currency that you want to buy and convert into
2998
+ * @param {float} [amount] how much you want to trade in units of the from currency
2999
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3000
+ * @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
3001
+ */
3002
+ await this.loadMarkets();
3003
+ const request = {
3004
+ 'sellToken': fromCode.toUpperCase(),
3005
+ 'buyToken': toCode.toUpperCase(),
3006
+ 'sellQuantity': this.numberToString(amount),
3007
+ };
3008
+ const response = await this.v3PrivateGetConvertRfq(this.extend(request, params));
3009
+ //
3010
+ // {
3011
+ // "success": true,
3012
+ // "data": {
3013
+ // "quoteId": 123123123,
3014
+ // "counterPartyId": "",
3015
+ // "sellToken": "ETH",
3016
+ // "sellQuantity": "0.0445",
3017
+ // "buyToken": "USDT",
3018
+ // "buyQuantity": "33.45",
3019
+ // "buyPrice": "6.77",
3020
+ // "expireTimestamp": 1659084466000,
3021
+ // "message": 1659084466000
3022
+ // }
3023
+ // }
3024
+ //
3025
+ const data = this.safeDict(response, 'data', {});
3026
+ const fromCurrencyId = this.safeString(data, 'sellToken', fromCode);
3027
+ const fromCurrency = this.currency(fromCurrencyId);
3028
+ const toCurrencyId = this.safeString(data, 'buyToken', toCode);
3029
+ const toCurrency = this.currency(toCurrencyId);
3030
+ return this.parseConversion(data, fromCurrency, toCurrency);
3031
+ }
3032
+ parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
3033
+ //
3034
+ // fetchConvertQuote
3035
+ //
3036
+ // {
3037
+ // "quoteId": 123123123,
3038
+ // "counterPartyId": "",
3039
+ // "sellToken": "ETH",
3040
+ // "sellQuantity": "0.0445",
3041
+ // "buyToken": "USDT",
3042
+ // "buyQuantity": "33.45",
3043
+ // "buyPrice": "6.77",
3044
+ // "expireTimestamp": 1659084466000,
3045
+ // "message": 1659084466000
3046
+ // }
3047
+ //
3048
+ const timestamp = this.safeInteger(conversion, 'expireTimestamp');
3049
+ const fromCoin = this.safeString(conversion, 'sellToken');
3050
+ const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
3051
+ const to = this.safeString(conversion, 'buyToken');
3052
+ const toCode = this.safeCurrencyCode(to, toCurrency);
3053
+ return {
3054
+ 'info': conversion,
3055
+ 'timestamp': timestamp,
3056
+ 'datetime': this.iso8601(timestamp),
3057
+ 'id': this.safeString(conversion, 'quoteId'),
3058
+ 'fromCurrency': fromCode,
3059
+ 'fromAmount': this.safeNumber(conversion, 'sellQuantity'),
3060
+ 'toCurrency': toCode,
3061
+ 'toAmount': this.safeNumber(conversion, 'buyQuantity'),
3062
+ 'price': this.safeNumber(conversion, 'buyPrice'),
3063
+ 'fee': undefined,
3064
+ };
3065
+ }
3066
+ async fetchConvertCurrencies(params = {}) {
3067
+ /**
3068
+ * @method
3069
+ * @name woo#fetchConvertCurrencies
3070
+ * @description fetches all available currencies that can be converted
3071
+ * @see https://docs.woo.org/#get-quote-asset-info
3072
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3073
+ * @returns {object} an associative dictionary of currencies
3074
+ */
3075
+ await this.loadMarkets();
3076
+ const response = await this.v3PrivateGetConvertAssetInfo(params);
3077
+ //
3078
+ // {
3079
+ // "success": true,
3080
+ // "rows": [
3081
+ // {
3082
+ // "token": "BTC",
3083
+ // "tick": 0.0001,
3084
+ // "createdTime": "1575014248.99", // Unix epoch time in seconds
3085
+ // "updatedTime": "1575014248.99" // Unix epoch time in seconds
3086
+ // },
3087
+ // ]
3088
+ // }
3089
+ //
3090
+ const result = {};
3091
+ const data = this.safeList(response, 'rows', []);
3092
+ for (let i = 0; i < data.length; i++) {
3093
+ const entry = data[i];
3094
+ const id = this.safeString(entry, 'token');
3095
+ const code = this.safeCurrencyCode(id);
3096
+ result[code] = {
3097
+ 'info': entry,
3098
+ 'id': id,
3099
+ 'code': code,
3100
+ 'networks': undefined,
3101
+ 'type': undefined,
3102
+ 'name': undefined,
3103
+ 'active': undefined,
3104
+ 'deposit': undefined,
3105
+ 'withdraw': undefined,
3106
+ 'fee': undefined,
3107
+ 'precision': this.safeNumber(entry, 'tick'),
3108
+ 'limits': {
3109
+ 'amount': {
3110
+ 'min': undefined,
3111
+ 'max': undefined,
3112
+ },
3113
+ 'withdraw': {
3114
+ 'min': undefined,
3115
+ 'max': undefined,
3116
+ },
3117
+ 'deposit': {
3118
+ 'min': undefined,
3119
+ 'max': undefined,
3120
+ },
3121
+ },
3122
+ 'created': this.safeTimestamp(entry, 'createdTime'),
3123
+ };
3124
+ }
3125
+ return result;
3126
+ }
2988
3127
  defaultNetworkCodeForCurrency(code) {
2989
3128
  const currencyItem = this.currency(code);
2990
3129
  const networks = currencyItem['networks'];
@@ -112,8 +112,11 @@ try {
112
112
  for (const [credential, isRequired] of Object.entries (requiredCredentials)) {
113
113
  if (isRequired && exchange[credential] === undefined) {
114
114
  const credentialEnvName = (exchangeId + '_' + credential).toUpperCase () // example: KRAKEN_APIKEY
115
- const credentialValue = process.env[credentialEnvName]
115
+ let credentialValue = process.env[credentialEnvName]
116
116
  if (credentialValue) {
117
+ if (credentialValue.indexOf('---BEGIN') > -1) {
118
+ credentialValue = credentialValue.replaceAll('\\n', '\n');
119
+ }
117
120
  exchange[credential] = credentialValue
118
121
  }
119
122
  }
@@ -109,8 +109,11 @@ try {
109
109
  for (const [credential, isRequired] of Object.entries (requiredCredentials)) {
110
110
  if (isRequired && exchange[credential] === undefined) {
111
111
  const credentialEnvName = (exchangeId + '_' + credential).toUpperCase () // example: KRAKEN_APIKEY
112
- const credentialValue = process.env[credentialEnvName]
112
+ let credentialValue = process.env[credentialEnvName]
113
113
  if (credentialValue) {
114
+ if (credentialValue.indexOf('---BEGIN') > -1) {
115
+ credentialValue = (credentialValue as any).replaceAll('\\n', '\n');
116
+ }
114
117
  exchange[credential] = credentialValue
115
118
  }
116
119
  }
package/js/ccxt.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Exchange } from './src/base/Exchange.js';
2
2
  import { Precise } from './src/base/Precise.js';
3
3
  import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
- import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain } from './src/base/types.js';
5
+ import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
7
- declare const version = "4.2.92";
7
+ declare const version = "4.2.93";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
@@ -519,5 +519,5 @@ declare const ccxt: {
519
519
  zaif: typeof zaif;
520
520
  zonda: typeof zonda;
521
521
  } & typeof functions & typeof errors;
522
- export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseinternational, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
522
+ export { version, Exchange, exchanges, pro, Precise, functions, errors, BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser, Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks, Leverage, Leverages, Option, OptionChain, Conversion, ace, alpaca, ascendex, bequant, bigone, binance, binancecoinm, binanceus, binanceusdm, bingx, bit2c, bitbank, bitbay, bitbns, bitcoincom, bitfinex, bitfinex2, bitflyer, bitget, bithumb, bitmart, bitmex, bitopro, bitpanda, bitrue, bitso, bitstamp, bitteam, bitvavo, bl3p, blockchaincom, blofin, btcalpha, btcbox, btcmarkets, btcturk, bybit, cex, coinbase, coinbaseinternational, coinbasepro, coincheck, coinex, coinlist, coinmate, coinmetro, coinone, coinsph, coinspot, cryptocom, currencycom, delta, deribit, digifinex, exmo, fmfwio, gate, gateio, gemini, hitbtc, hitbtc3, hollaex, htx, huobi, huobijp, hyperliquid, idex, independentreserve, indodax, kraken, krakenfutures, kucoin, kucoinfutures, kuna, latoken, lbank, luno, lykke, mercado, mexc, ndax, novadax, oceanex, okcoin, okx, onetrading, p2b, paymium, phemex, poloniex, poloniexfutures, probit, timex, tokocrypto, tradeogre, upbit, wavesexchange, wazirx, whitebit, woo, yobit, zaif, zonda, };
523
523
  export default ccxt;
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, ExchangeClosedByUser } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.93';
41
+ const version = '4.2.94';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -607,6 +607,7 @@ interface Exchange {
607
607
  privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
608
608
  privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
609
609
  privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
610
+ privatePostOrderListOco(params?: {}): Promise<implicitReturnType>;
610
611
  privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
611
612
  privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
612
613
  privatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -607,6 +607,7 @@ interface binance {
607
607
  privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
608
608
  privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
609
609
  privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
610
+ privatePostOrderListOco(params?: {}): Promise<implicitReturnType>;
610
611
  privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
611
612
  privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
612
613
  privatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -659,6 +659,7 @@ interface binance {
659
659
  privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
660
660
  privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
661
661
  privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
662
+ privatePostOrderListOco(params?: {}): Promise<implicitReturnType>;
662
663
  privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
663
664
  privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
664
665
  privatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -607,6 +607,7 @@ interface binance {
607
607
  privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
608
608
  privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
609
609
  privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
610
+ privatePostOrderListOco(params?: {}): Promise<implicitReturnType>;
610
611
  privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
611
612
  privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
612
613
  privatePostOrder(params?: {}): Promise<implicitReturnType>;
@@ -3,8 +3,8 @@ import { // eslint-disable-line object-curly-newline
3
3
  ExchangeError, AuthenticationError, DDoSProtection, RequestTimeout, ExchangeNotAvailable, RateLimitExceeded } from "./errors.js";
4
4
  import WsClient from './ws/WsClient.js';
5
5
  import { OrderBook as WsOrderBook, IndexedOrderBook, CountedOrderBook } from './ws/OrderBook.js';
6
- import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './types.js';
7
- export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, BorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings } from './types.js';
6
+ import type { Market, Trade, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, FundingRate, DepositWithdrawFeeNetwork, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion } from './types.js';
7
+ export type { Market, Trade, Fee, Ticker, OHLCV, OHLCVC, Order, OrderBook, Balance, Balances, Dictionary, Transaction, DepositAddressResponse, Currency, MinMax, IndexType, Int, OrderType, OrderSide, Position, LedgerEntry, BorrowInterest, OpenInterest, LeverageTier, TransferEntry, BorrowRate, FundingRateHistory, Liquidation, FundingHistory, OrderRequest, MarginMode, Tickers, Greeks, Option, OptionChain, Str, Num, MarketInterface, CurrencyInterface, BalanceAccount, MarginModes, MarketType, Leverage, Leverages, LastPrice, LastPrices, Account, Strings, Conversion } from './types.js';
8
8
  import { ArrayCache, ArrayCacheByTimestamp } from './ws/Cache.js';
9
9
  import { OrderBook as Ob } from './ws/OrderBook.js';
10
10
  /**
@@ -348,6 +348,8 @@ export default class Exchange {
348
348
  fetchClosedOrder: any;
349
349
  fetchClosedOrders: any;
350
350
  fetchClosedOrdersWs: any;
351
+ fetchConvertCurrencies: any;
352
+ fetchConvertQuote: any;
351
353
  fetchCrossBorrowRate: any;
352
354
  fetchCrossBorrowRates: any;
353
355
  fetchCurrencies: string;
@@ -776,6 +778,7 @@ export default class Exchange {
776
778
  convertOHLCVToTradingView(ohlcvs: number[][], timestamp?: string, open?: string, high?: string, low?: string, close?: string, volume?: string, ms?: boolean): {};
777
779
  fetchWebEndpoint(method: any, endpointMethod: any, returnAsJson: any, startRegex?: any, endRegex?: any): Promise<any>;
778
780
  marketIds(symbols?: Strings): any[];
781
+ marketsForSymbols(symbols?: Strings): any[];
779
782
  marketSymbols(symbols?: Strings, type?: Str, allowEmpty?: boolean, sameTypeOnly?: boolean, sameSubTypeOnly?: boolean): any[];
780
783
  marketCodes(codes?: Strings): any[];
781
784
  parseBidsAsks(bidasks: any, priceKey?: IndexType, amountKey?: IndexType, countOrIdKey?: IndexType): any[];
@@ -910,6 +913,7 @@ export default class Exchange {
910
913
  fetchGreeks(symbol: string, params?: {}): Promise<Greeks>;
911
914
  fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
912
915
  fetchOption(symbol: string, params?: {}): Promise<Option>;
916
+ fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
913
917
  fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
914
918
  fetchDeposits(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
915
919
  fetchWithdrawals(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
@@ -974,6 +978,7 @@ export default class Exchange {
974
978
  fetchTradingFees(params?: {}): Promise<TradingFees>;
975
979
  fetchTradingFeesWs(params?: {}): Promise<TradingFees>;
976
980
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
981
+ fetchConvertCurrencies(params?: {}): Promise<Currencies>;
977
982
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
978
983
  parseOpenInterests(response: any, market?: any, since?: Int, limit?: Int): OpenInterest[];
979
984
  fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
@@ -1015,6 +1020,7 @@ export default class Exchange {
1015
1020
  parseMarginMode(marginMode: any, market?: Market): MarginMode;
1016
1021
  parseLeverages(response: object[], symbols?: string[], symbolKey?: Str, marketType?: MarketType): Leverages;
1017
1022
  parseLeverage(leverage: any, market?: Market): Leverage;
1023
+ parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
1018
1024
  convertExpireDate(date: string): string;
1019
1025
  convertExpireDateToMarketIdDate(date: string): string;
1020
1026
  convertMarketIdExpireDate(date: string): string;
@@ -406,6 +406,8 @@ export default class Exchange {
406
406
  'fetchClosedOrder': undefined,
407
407
  'fetchClosedOrders': undefined,
408
408
  'fetchClosedOrdersWs': undefined,
409
+ 'fetchConvertCurrencies': undefined,
410
+ 'fetchConvertQuote': undefined,
409
411
  'fetchCrossBorrowRate': undefined,
410
412
  'fetchCrossBorrowRates': undefined,
411
413
  'fetchCurrencies': 'emulated',
@@ -3165,6 +3167,16 @@ export default class Exchange {
3165
3167
  }
3166
3168
  return result;
3167
3169
  }
3170
+ marketsForSymbols(symbols = undefined) {
3171
+ if (symbols === undefined) {
3172
+ return symbols;
3173
+ }
3174
+ const result = [];
3175
+ for (let i = 0; i < symbols.length; i++) {
3176
+ result.push(this.market(symbols[i]));
3177
+ }
3178
+ return result;
3179
+ }
3168
3180
  marketSymbols(symbols = undefined, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
3169
3181
  if (symbols === undefined) {
3170
3182
  if (!allowEmpty) {
@@ -4513,6 +4525,9 @@ export default class Exchange {
4513
4525
  async fetchOption(symbol, params = {}) {
4514
4526
  throw new NotSupported(this.id + ' fetchOption() is not supported yet');
4515
4527
  }
4528
+ async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
4529
+ throw new NotSupported(this.id + ' fetchConvertQuote() is not supported yet');
4530
+ }
4516
4531
  async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
4517
4532
  /**
4518
4533
  * @method
@@ -5061,6 +5076,9 @@ export default class Exchange {
5061
5076
  const fees = await this.fetchTradingFees(params);
5062
5077
  return this.safeDict(fees, symbol);
5063
5078
  }
5079
+ async fetchConvertCurrencies(params = {}) {
5080
+ throw new NotSupported(this.id + ' fetchConvertCurrencies() is not supported yet');
5081
+ }
5064
5082
  parseOpenInterest(interest, market = undefined) {
5065
5083
  throw new NotSupported(this.id + ' parseOpenInterest () is not supported yet');
5066
5084
  }
@@ -5758,7 +5776,10 @@ export default class Exchange {
5758
5776
  return leverageStructures;
5759
5777
  }
5760
5778
  parseLeverage(leverage, market = undefined) {
5761
- throw new NotSupported(this.id + ' parseLeverage() is not supported yet');
5779
+ throw new NotSupported(this.id + ' parseLeverage () is not supported yet');
5780
+ }
5781
+ parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
5782
+ throw new NotSupported(this.id + ' parseConversion () is not supported yet');
5762
5783
  }
5763
5784
  convertExpireDate(date) {
5764
5785
  // parse YYMMDD to datetime string
@@ -427,6 +427,18 @@ export interface Greeks {
427
427
  underlyingPrice: number;
428
428
  info: any;
429
429
  }
430
+ export interface Conversion {
431
+ info: any;
432
+ timestamp?: number;
433
+ datetime?: string;
434
+ id: string;
435
+ fromCurrency: string;
436
+ fromAmount: number;
437
+ toCurrency: string;
438
+ toAmount: number;
439
+ price: number;
440
+ fee: number;
441
+ }
430
442
  export interface Option {
431
443
  info: any;
432
444
  currency: string;
@@ -439,4 +439,5 @@ export default class binance extends Exchange {
439
439
  quoteVolume: any;
440
440
  };
441
441
  fetchMarginAdjustmentHistory(symbol?: Str, type?: Str, since?: Num, limit?: Num, params?: {}): Promise<MarginModification[]>;
442
+ fetchConvertCurrencies(params?: {}): Promise<Currencies>;
442
443
  }
package/js/src/binance.js CHANGED
@@ -74,6 +74,8 @@ export default class binance extends Exchange {
74
74
  'fetchCanceledOrders': 'emulated',
75
75
  'fetchClosedOrder': false,
76
76
  'fetchClosedOrders': 'emulated',
77
+ 'fetchConvertCurrencies': true,
78
+ 'fetchConvertQuote': false,
77
79
  'fetchCrossBorrowRate': true,
78
80
  'fetchCrossBorrowRates': false,
79
81
  'fetchCurrencies': true,
@@ -973,6 +975,7 @@ export default class binance extends Exchange {
973
975
  },
974
976
  'post': {
975
977
  'order/oco': 0.2,
978
+ 'orderList/oco': 0.2,
976
979
  'sor/order': 0.2,
977
980
  'sor/order/test': 0.2,
978
981
  'order': 0.2,
@@ -4240,11 +4243,14 @@ export default class binance extends Exchange {
4240
4243
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
4241
4244
  'limit': limit,
4242
4245
  };
4246
+ const marketId = market['id'];
4243
4247
  if (price === 'index') {
4244
- request['pair'] = market['id']; // Index price takes this argument instead of symbol
4248
+ const parts = marketId.split('_');
4249
+ const pair = this.safeString(parts, 0);
4250
+ request['pair'] = pair; // Index price takes this argument instead of symbol
4245
4251
  }
4246
4252
  else {
4247
- request['symbol'] = market['id'];
4253
+ request['symbol'] = marketId;
4248
4254
  }
4249
4255
  // const duration = this.parseTimeframe (timeframe);
4250
4256
  if (since !== undefined) {
@@ -12589,4 +12595,59 @@ export default class binance extends Exchange {
12589
12595
  const modifications = this.parseMarginModifications(response);
12590
12596
  return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
12591
12597
  }
12598
+ async fetchConvertCurrencies(params = {}) {
12599
+ /**
12600
+ * @method
12601
+ * @name binance#fetchConvertCurrencies
12602
+ * @description fetches all available currencies that can be converted
12603
+ * @see https://binance-docs.github.io/apidocs/spot/en/#query-order-quantity-precision-per-asset-user_data
12604
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12605
+ * @returns {object} an associative dictionary of currencies
12606
+ */
12607
+ await this.loadMarkets();
12608
+ const response = await this.sapiGetConvertAssetInfo(params);
12609
+ //
12610
+ // [
12611
+ // {
12612
+ // "asset": "BTC",
12613
+ // "fraction": 8
12614
+ // },
12615
+ // ]
12616
+ //
12617
+ const result = {};
12618
+ for (let i = 0; i < response.length; i++) {
12619
+ const entry = response[i];
12620
+ const id = this.safeString(entry, 'asset');
12621
+ const code = this.safeCurrencyCode(id);
12622
+ result[code] = {
12623
+ 'info': entry,
12624
+ 'id': id,
12625
+ 'code': code,
12626
+ 'networks': undefined,
12627
+ 'type': undefined,
12628
+ 'name': undefined,
12629
+ 'active': undefined,
12630
+ 'deposit': undefined,
12631
+ 'withdraw': undefined,
12632
+ 'fee': undefined,
12633
+ 'precision': this.safeInteger(entry, 'fraction'),
12634
+ 'limits': {
12635
+ 'amount': {
12636
+ 'min': undefined,
12637
+ 'max': undefined,
12638
+ },
12639
+ 'withdraw': {
12640
+ 'min': undefined,
12641
+ 'max': undefined,
12642
+ },
12643
+ 'deposit': {
12644
+ 'min': undefined,
12645
+ 'max': undefined,
12646
+ },
12647
+ },
12648
+ 'created': undefined,
12649
+ };
12650
+ }
12651
+ return result;
12652
+ }
12592
12653
  }
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitget.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification, TradingFeeInterface, Currencies, TradingFees, Conversion } from './base/types.js';
3
3
  /**
4
4
  * @class bitget
5
5
  * @augments Exchange
@@ -282,6 +282,9 @@ export default class bitget extends Exchange {
282
282
  closeAllPositions(params?: {}): Promise<Position[]>;
283
283
  fetchMarginMode(symbol: string, params?: {}): Promise<MarginMode>;
284
284
  parseMarginMode(marginMode: any, market?: any): MarginMode;
285
+ fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
286
+ parseConversion(conversion: any, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
287
+ fetchConvertCurrencies(params?: {}): Promise<Currencies>;
285
288
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
286
289
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
287
290
  url: string;