ccxt 4.2.92 → 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.
- package/README.md +3 -3
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +807 -175
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +50 -9
- package/dist/cjs/src/base/functions/encode.js +4 -4
- package/dist/cjs/src/binance.js +63 -2
- package/dist/cjs/src/bitget.js +139 -0
- package/dist/cjs/src/coinex.js +0 -30
- package/dist/cjs/src/digifinex.js +1 -22
- package/dist/cjs/src/okx.js +153 -0
- package/dist/cjs/src/pro/kraken.js +107 -17
- package/dist/cjs/src/pro/krakenfutures.js +117 -40
- package/dist/cjs/src/pro/kucoin.js +30 -19
- package/dist/cjs/src/probit.js +3 -4
- package/dist/cjs/src/woo.js +139 -0
- package/examples/js/cli.js +4 -1
- package/examples/ts/cli.ts +4 -1
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +16 -10
- package/js/src/base/Exchange.js +50 -9
- package/js/src/base/functions/encode.d.ts +1 -1
- package/js/src/base/functions/encode.js +4 -4
- package/js/src/base/functions/rsa.d.ts +1 -1
- package/js/src/base/types.d.ts +12 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +63 -2
- package/js/src/bitget.d.ts +4 -1
- package/js/src/bitget.js +139 -0
- package/js/src/coinex.d.ts +0 -1
- package/js/src/coinex.js +0 -30
- package/js/src/digifinex.d.ts +0 -1
- package/js/src/digifinex.js +1 -49
- package/js/src/okx.d.ts +4 -1
- package/js/src/okx.js +153 -0
- package/js/src/pro/kraken.d.ts +6 -1
- package/js/src/pro/kraken.js +107 -17
- package/js/src/pro/krakenfutures.d.ts +8 -2
- package/js/src/pro/krakenfutures.js +117 -40
- package/js/src/pro/kucoin.js +30 -19
- package/js/src/probit.d.ts +1 -1
- package/js/src/probit.js +3 -4
- package/js/src/woo.d.ts +4 -1
- package/js/src/woo.js +139 -0
- package/package.json +1 -1
- package/skip-tests.json +4 -0
package/dist/cjs/ccxt.js
CHANGED
|
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
182
182
|
|
|
183
183
|
//-----------------------------------------------------------------------------
|
|
184
184
|
// this is updated by vss.js when building
|
|
185
|
-
const version = '4.2.
|
|
185
|
+
const version = '4.2.94';
|
|
186
186
|
Exchange["default"].ccxtVersion = version;
|
|
187
187
|
const exchanges = {
|
|
188
188
|
'ace': ace,
|
|
@@ -421,6 +421,8 @@ class Exchange {
|
|
|
421
421
|
'fetchClosedOrder': undefined,
|
|
422
422
|
'fetchClosedOrders': undefined,
|
|
423
423
|
'fetchClosedOrdersWs': undefined,
|
|
424
|
+
'fetchConvertCurrencies': undefined,
|
|
425
|
+
'fetchConvertQuote': undefined,
|
|
424
426
|
'fetchCrossBorrowRate': undefined,
|
|
425
427
|
'fetchCrossBorrowRates': undefined,
|
|
426
428
|
'fetchCurrencies': 'emulated',
|
|
@@ -3178,6 +3180,16 @@ class Exchange {
|
|
|
3178
3180
|
}
|
|
3179
3181
|
return result;
|
|
3180
3182
|
}
|
|
3183
|
+
marketsForSymbols(symbols = undefined) {
|
|
3184
|
+
if (symbols === undefined) {
|
|
3185
|
+
return symbols;
|
|
3186
|
+
}
|
|
3187
|
+
const result = [];
|
|
3188
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
3189
|
+
result.push(this.market(symbols[i]));
|
|
3190
|
+
}
|
|
3191
|
+
return result;
|
|
3192
|
+
}
|
|
3181
3193
|
marketSymbols(symbols = undefined, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
|
|
3182
3194
|
if (symbols === undefined) {
|
|
3183
3195
|
if (!allowEmpty) {
|
|
@@ -3447,14 +3459,34 @@ class Exchange {
|
|
|
3447
3459
|
// marketIdKey should only be undefined when response is a dictionary
|
|
3448
3460
|
symbols = this.marketSymbols(symbols);
|
|
3449
3461
|
const tiers = {};
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3462
|
+
let symbolsLength = 0;
|
|
3463
|
+
if (symbols !== undefined) {
|
|
3464
|
+
symbolsLength = symbols.length;
|
|
3465
|
+
}
|
|
3466
|
+
const noSymbols = (symbols === undefined) || (symbolsLength === 0);
|
|
3467
|
+
if (Array.isArray(response)) {
|
|
3468
|
+
for (let i = 0; i < response.length; i++) {
|
|
3469
|
+
const item = response[i];
|
|
3470
|
+
const id = this.safeString(item, marketIdKey);
|
|
3471
|
+
const market = this.safeMarket(id, undefined, undefined, 'swap');
|
|
3472
|
+
const symbol = market['symbol'];
|
|
3473
|
+
const contract = this.safeBool(market, 'contract', false);
|
|
3474
|
+
if (contract && (noSymbols || this.inArray(symbol, symbols))) {
|
|
3475
|
+
tiers[symbol] = this.parseMarketLeverageTiers(item, market);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
else {
|
|
3480
|
+
const keys = Object.keys(response);
|
|
3481
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3482
|
+
const marketId = keys[i];
|
|
3483
|
+
const item = response[marketId];
|
|
3484
|
+
const market = this.safeMarket(marketId, undefined, undefined, 'swap');
|
|
3485
|
+
const symbol = market['symbol'];
|
|
3486
|
+
const contract = this.safeBool(market, 'contract', false);
|
|
3487
|
+
if (contract && (noSymbols || this.inArray(symbol, symbols))) {
|
|
3488
|
+
tiers[symbol] = this.parseMarketLeverageTiers(item, market);
|
|
3489
|
+
}
|
|
3458
3490
|
}
|
|
3459
3491
|
}
|
|
3460
3492
|
return tiers;
|
|
@@ -4506,6 +4538,9 @@ class Exchange {
|
|
|
4506
4538
|
async fetchOption(symbol, params = {}) {
|
|
4507
4539
|
throw new errors.NotSupported(this.id + ' fetchOption() is not supported yet');
|
|
4508
4540
|
}
|
|
4541
|
+
async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
|
|
4542
|
+
throw new errors.NotSupported(this.id + ' fetchConvertQuote() is not supported yet');
|
|
4543
|
+
}
|
|
4509
4544
|
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4510
4545
|
/**
|
|
4511
4546
|
* @method
|
|
@@ -5054,6 +5089,9 @@ class Exchange {
|
|
|
5054
5089
|
const fees = await this.fetchTradingFees(params);
|
|
5055
5090
|
return this.safeDict(fees, symbol);
|
|
5056
5091
|
}
|
|
5092
|
+
async fetchConvertCurrencies(params = {}) {
|
|
5093
|
+
throw new errors.NotSupported(this.id + ' fetchConvertCurrencies() is not supported yet');
|
|
5094
|
+
}
|
|
5057
5095
|
parseOpenInterest(interest, market = undefined) {
|
|
5058
5096
|
throw new errors.NotSupported(this.id + ' parseOpenInterest () is not supported yet');
|
|
5059
5097
|
}
|
|
@@ -5751,7 +5789,10 @@ class Exchange {
|
|
|
5751
5789
|
return leverageStructures;
|
|
5752
5790
|
}
|
|
5753
5791
|
parseLeverage(leverage, market = undefined) {
|
|
5754
|
-
throw new errors.NotSupported(this.id + ' parseLeverage() is not supported yet');
|
|
5792
|
+
throw new errors.NotSupported(this.id + ' parseLeverage () is not supported yet');
|
|
5793
|
+
}
|
|
5794
|
+
parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
|
|
5795
|
+
throw new errors.NotSupported(this.id + ' parseConversion () is not supported yet');
|
|
5755
5796
|
}
|
|
5756
5797
|
convertExpireDate(date) {
|
|
5757
5798
|
// parse YYMMDD to datetime string
|
|
@@ -9,13 +9,13 @@ var index$1 = require('../../static_dependencies/qs/index.cjs.js');
|
|
|
9
9
|
|
|
10
10
|
/* eslint-disable */
|
|
11
11
|
/* ------------------------------------------------------------------------ */
|
|
12
|
-
const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedObject = object => ((typeof object === 'string') &&
|
|
12
|
+
const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedObject = (object) => ((typeof object === 'string') &&
|
|
13
13
|
(object.length >= 2) &&
|
|
14
|
-
((object[0] === '{') || (object[0] === '['))), binaryToString = index.utf8.encode, stringToBinary = index.utf8.decode, stringToBase64 = string => index.base64.encode(index.utf8.decode(string)), base64ToString = string => index.utf8.encode(index.base64.decode(string)), base64ToBinary = index.base64.decode, binaryToBase64 = index.base64.encode, base16ToBinary = index.base16.decode, binaryToBase16 = index.base16.encode, base58ToBinary = index.base58.decode, binaryToBase58 = index.base58.encode, binaryConcat = utils.concatBytes, binaryConcatArray = (arr) => utils.concatBytes(...arr), urlencode = object => index$1.stringify(object), urlencodeNested = object => index$1.stringify(object) // implemented only in python
|
|
15
|
-
, urlencodeWithArrayRepeat = object => index$1.stringify(object, { arrayFormat: 'repeat' }), rawencode = object => index$1.stringify(object, { encode: false }), encode = index.utf8.decode // lol
|
|
14
|
+
((object[0] === '{') || (object[0] === '['))), binaryToString = index.utf8.encode, stringToBinary = index.utf8.decode, stringToBase64 = (string) => index.base64.encode(index.utf8.decode(string)), base64ToString = (string) => index.utf8.encode(index.base64.decode(string)), base64ToBinary = index.base64.decode, binaryToBase64 = index.base64.encode, base16ToBinary = index.base16.decode, binaryToBase16 = index.base16.encode, base58ToBinary = index.base58.decode, binaryToBase58 = index.base58.encode, binaryConcat = utils.concatBytes, binaryConcatArray = (arr) => utils.concatBytes(...arr), urlencode = (object) => index$1.stringify(object), urlencodeNested = (object) => index$1.stringify(object) // implemented only in python
|
|
15
|
+
, urlencodeWithArrayRepeat = (object) => index$1.stringify(object, { arrayFormat: 'repeat' }), rawencode = (object) => index$1.stringify(object, { encode: false }), encode = index.utf8.decode // lol
|
|
16
16
|
, decode = index.utf8.encode
|
|
17
17
|
// Url-safe-base64 without equals signs, with + replaced by - and slashes replaced by underscores
|
|
18
|
-
, urlencodeBase64 = base64string => base64string.replace(/[=]+$/, '')
|
|
18
|
+
, urlencodeBase64 = (base64string) => base64string.replace(/[=]+$/, '')
|
|
19
19
|
.replace(/\+/g, '-')
|
|
20
20
|
.replace(/\//g, '_'), numberToLE = (n, padding) => utils.numberToBytesLE(BigInt(n), padding), numberToBE = (n, padding) => utils.numberToBytesBE(BigInt(n), padding);
|
|
21
21
|
function packb(req) {
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -71,6 +71,8 @@ class binance extends binance$1 {
|
|
|
71
71
|
'fetchCanceledOrders': 'emulated',
|
|
72
72
|
'fetchClosedOrder': false,
|
|
73
73
|
'fetchClosedOrders': 'emulated',
|
|
74
|
+
'fetchConvertCurrencies': true,
|
|
75
|
+
'fetchConvertQuote': false,
|
|
74
76
|
'fetchCrossBorrowRate': true,
|
|
75
77
|
'fetchCrossBorrowRates': false,
|
|
76
78
|
'fetchCurrencies': true,
|
|
@@ -970,6 +972,7 @@ class binance extends binance$1 {
|
|
|
970
972
|
},
|
|
971
973
|
'post': {
|
|
972
974
|
'order/oco': 0.2,
|
|
975
|
+
'orderList/oco': 0.2,
|
|
973
976
|
'sor/order': 0.2,
|
|
974
977
|
'sor/order/test': 0.2,
|
|
975
978
|
'order': 0.2,
|
|
@@ -4237,11 +4240,14 @@ class binance extends binance$1 {
|
|
|
4237
4240
|
'interval': this.safeString(this.timeframes, timeframe, timeframe),
|
|
4238
4241
|
'limit': limit,
|
|
4239
4242
|
};
|
|
4243
|
+
const marketId = market['id'];
|
|
4240
4244
|
if (price === 'index') {
|
|
4241
|
-
|
|
4245
|
+
const parts = marketId.split('_');
|
|
4246
|
+
const pair = this.safeString(parts, 0);
|
|
4247
|
+
request['pair'] = pair; // Index price takes this argument instead of symbol
|
|
4242
4248
|
}
|
|
4243
4249
|
else {
|
|
4244
|
-
request['symbol'] =
|
|
4250
|
+
request['symbol'] = marketId;
|
|
4245
4251
|
}
|
|
4246
4252
|
// const duration = this.parseTimeframe (timeframe);
|
|
4247
4253
|
if (since !== undefined) {
|
|
@@ -12586,6 +12592,61 @@ class binance extends binance$1 {
|
|
|
12586
12592
|
const modifications = this.parseMarginModifications(response);
|
|
12587
12593
|
return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
|
|
12588
12594
|
}
|
|
12595
|
+
async fetchConvertCurrencies(params = {}) {
|
|
12596
|
+
/**
|
|
12597
|
+
* @method
|
|
12598
|
+
* @name binance#fetchConvertCurrencies
|
|
12599
|
+
* @description fetches all available currencies that can be converted
|
|
12600
|
+
* @see https://binance-docs.github.io/apidocs/spot/en/#query-order-quantity-precision-per-asset-user_data
|
|
12601
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
12602
|
+
* @returns {object} an associative dictionary of currencies
|
|
12603
|
+
*/
|
|
12604
|
+
await this.loadMarkets();
|
|
12605
|
+
const response = await this.sapiGetConvertAssetInfo(params);
|
|
12606
|
+
//
|
|
12607
|
+
// [
|
|
12608
|
+
// {
|
|
12609
|
+
// "asset": "BTC",
|
|
12610
|
+
// "fraction": 8
|
|
12611
|
+
// },
|
|
12612
|
+
// ]
|
|
12613
|
+
//
|
|
12614
|
+
const result = {};
|
|
12615
|
+
for (let i = 0; i < response.length; i++) {
|
|
12616
|
+
const entry = response[i];
|
|
12617
|
+
const id = this.safeString(entry, 'asset');
|
|
12618
|
+
const code = this.safeCurrencyCode(id);
|
|
12619
|
+
result[code] = {
|
|
12620
|
+
'info': entry,
|
|
12621
|
+
'id': id,
|
|
12622
|
+
'code': code,
|
|
12623
|
+
'networks': undefined,
|
|
12624
|
+
'type': undefined,
|
|
12625
|
+
'name': undefined,
|
|
12626
|
+
'active': undefined,
|
|
12627
|
+
'deposit': undefined,
|
|
12628
|
+
'withdraw': undefined,
|
|
12629
|
+
'fee': undefined,
|
|
12630
|
+
'precision': this.safeInteger(entry, 'fraction'),
|
|
12631
|
+
'limits': {
|
|
12632
|
+
'amount': {
|
|
12633
|
+
'min': undefined,
|
|
12634
|
+
'max': undefined,
|
|
12635
|
+
},
|
|
12636
|
+
'withdraw': {
|
|
12637
|
+
'min': undefined,
|
|
12638
|
+
'max': undefined,
|
|
12639
|
+
},
|
|
12640
|
+
'deposit': {
|
|
12641
|
+
'min': undefined,
|
|
12642
|
+
'max': undefined,
|
|
12643
|
+
},
|
|
12644
|
+
},
|
|
12645
|
+
'created': undefined,
|
|
12646
|
+
};
|
|
12647
|
+
}
|
|
12648
|
+
return result;
|
|
12649
|
+
}
|
|
12589
12650
|
}
|
|
12590
12651
|
|
|
12591
12652
|
module.exports = binance;
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -63,6 +63,8 @@ class bitget extends bitget$1 {
|
|
|
63
63
|
'fetchCanceledAndClosedOrders': true,
|
|
64
64
|
'fetchCanceledOrders': true,
|
|
65
65
|
'fetchClosedOrders': true,
|
|
66
|
+
'fetchConvertCurrencies': true,
|
|
67
|
+
'fetchConvertQuote': true,
|
|
66
68
|
'fetchCrossBorrowRate': true,
|
|
67
69
|
'fetchCrossBorrowRates': false,
|
|
68
70
|
'fetchCurrencies': true,
|
|
@@ -8442,6 +8444,143 @@ class bitget extends bitget$1 {
|
|
|
8442
8444
|
'marginMode': marginType,
|
|
8443
8445
|
};
|
|
8444
8446
|
}
|
|
8447
|
+
async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
|
|
8448
|
+
/**
|
|
8449
|
+
* @method
|
|
8450
|
+
* @name bitget#fetchConvertQuote
|
|
8451
|
+
* @description fetch a quote for converting from one currency to another
|
|
8452
|
+
* @see https://www.bitget.com/api-doc/common/convert/Get-Quoted-Price
|
|
8453
|
+
* @param {string} fromCode the currency that you want to sell and convert from
|
|
8454
|
+
* @param {string} toCode the currency that you want to buy and convert into
|
|
8455
|
+
* @param {float} [amount] how much you want to trade in units of the from currency
|
|
8456
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8457
|
+
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
8458
|
+
*/
|
|
8459
|
+
await this.loadMarkets();
|
|
8460
|
+
const request = {
|
|
8461
|
+
'fromCoin': fromCode.toUpperCase(),
|
|
8462
|
+
'toCoin': toCode.toUpperCase(),
|
|
8463
|
+
'fromCoinSize': this.numberToString(amount),
|
|
8464
|
+
};
|
|
8465
|
+
const response = await this.privateConvertGetV2ConvertQuotedPrice(this.extend(request, params));
|
|
8466
|
+
//
|
|
8467
|
+
// {
|
|
8468
|
+
// "code": "00000",
|
|
8469
|
+
// "msg": "success",
|
|
8470
|
+
// "requestTime": 1712121940158,
|
|
8471
|
+
// "data": {
|
|
8472
|
+
// "fromCoin": "USDT",
|
|
8473
|
+
// "fromCoinSize": "5",
|
|
8474
|
+
// "cnvtPrice": "0.9993007892377704",
|
|
8475
|
+
// "toCoin": "USDC",
|
|
8476
|
+
// "toCoinSize": "4.99650394",
|
|
8477
|
+
// "traceId": "1159288930228187140",
|
|
8478
|
+
// "fee": "0"
|
|
8479
|
+
// }
|
|
8480
|
+
// }
|
|
8481
|
+
//
|
|
8482
|
+
const data = this.safeDict(response, 'data', {});
|
|
8483
|
+
const fromCurrencyId = this.safeString(data, 'fromCoin', fromCode);
|
|
8484
|
+
const fromCurrency = this.currency(fromCurrencyId);
|
|
8485
|
+
const toCurrencyId = this.safeString(data, 'toCoin', toCode);
|
|
8486
|
+
const toCurrency = this.currency(toCurrencyId);
|
|
8487
|
+
return this.parseConversion(data, fromCurrency, toCurrency);
|
|
8488
|
+
}
|
|
8489
|
+
parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
|
|
8490
|
+
//
|
|
8491
|
+
// fetchConvertQuote
|
|
8492
|
+
//
|
|
8493
|
+
// {
|
|
8494
|
+
// "fromCoin": "USDT",
|
|
8495
|
+
// "fromCoinSize": "5",
|
|
8496
|
+
// "cnvtPrice": "0.9993007892377704",
|
|
8497
|
+
// "toCoin": "USDC",
|
|
8498
|
+
// "toCoinSize": "4.99650394",
|
|
8499
|
+
// "traceId": "1159288930228187140",
|
|
8500
|
+
// "fee": "0"
|
|
8501
|
+
// }
|
|
8502
|
+
//
|
|
8503
|
+
const timestamp = this.safeInteger(conversion, 'ts');
|
|
8504
|
+
const fromCoin = this.safeString(conversion, 'fromCoin');
|
|
8505
|
+
const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
|
|
8506
|
+
const to = this.safeString(conversion, 'toCoin');
|
|
8507
|
+
const toCode = this.safeCurrencyCode(to, toCurrency);
|
|
8508
|
+
return {
|
|
8509
|
+
'info': conversion,
|
|
8510
|
+
'timestamp': timestamp,
|
|
8511
|
+
'datetime': this.iso8601(timestamp),
|
|
8512
|
+
'id': this.safeString(conversion, 'traceId'),
|
|
8513
|
+
'fromCurrency': fromCode,
|
|
8514
|
+
'fromAmount': this.safeNumber(conversion, 'fromCoinSize'),
|
|
8515
|
+
'toCurrency': toCode,
|
|
8516
|
+
'toAmount': this.safeNumber(conversion, 'toCoinSize'),
|
|
8517
|
+
'price': this.safeNumber(conversion, 'cnvtPrice'),
|
|
8518
|
+
'fee': this.safeNumber(conversion, 'fee'),
|
|
8519
|
+
};
|
|
8520
|
+
}
|
|
8521
|
+
async fetchConvertCurrencies(params = {}) {
|
|
8522
|
+
/**
|
|
8523
|
+
* @method
|
|
8524
|
+
* @name bitget#fetchConvertCurrencies
|
|
8525
|
+
* @description fetches all available currencies that can be converted
|
|
8526
|
+
* @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Currencies
|
|
8527
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
8528
|
+
* @returns {object} an associative dictionary of currencies
|
|
8529
|
+
*/
|
|
8530
|
+
await this.loadMarkets();
|
|
8531
|
+
const response = await this.privateConvertGetV2ConvertCurrencies(params);
|
|
8532
|
+
//
|
|
8533
|
+
// {
|
|
8534
|
+
// "code": "00000",
|
|
8535
|
+
// "msg": "success",
|
|
8536
|
+
// "requestTime": 1712121755897,
|
|
8537
|
+
// "data": [
|
|
8538
|
+
// {
|
|
8539
|
+
// "coin": "BTC",
|
|
8540
|
+
// "available": "0.00009850",
|
|
8541
|
+
// "maxAmount": "0.756266",
|
|
8542
|
+
// "minAmount": "0.00001"
|
|
8543
|
+
// },
|
|
8544
|
+
// ]
|
|
8545
|
+
// }
|
|
8546
|
+
//
|
|
8547
|
+
const result = {};
|
|
8548
|
+
const data = this.safeList(response, 'data', []);
|
|
8549
|
+
for (let i = 0; i < data.length; i++) {
|
|
8550
|
+
const entry = data[i];
|
|
8551
|
+
const id = this.safeString(entry, 'coin');
|
|
8552
|
+
const code = this.safeCurrencyCode(id);
|
|
8553
|
+
result[code] = {
|
|
8554
|
+
'info': entry,
|
|
8555
|
+
'id': id,
|
|
8556
|
+
'code': code,
|
|
8557
|
+
'networks': undefined,
|
|
8558
|
+
'type': undefined,
|
|
8559
|
+
'name': undefined,
|
|
8560
|
+
'active': undefined,
|
|
8561
|
+
'deposit': undefined,
|
|
8562
|
+
'withdraw': this.safeNumber(entry, 'available'),
|
|
8563
|
+
'fee': undefined,
|
|
8564
|
+
'precision': undefined,
|
|
8565
|
+
'limits': {
|
|
8566
|
+
'amount': {
|
|
8567
|
+
'min': this.safeNumber(entry, 'minAmount'),
|
|
8568
|
+
'max': this.safeNumber(entry, 'maxAmount'),
|
|
8569
|
+
},
|
|
8570
|
+
'withdraw': {
|
|
8571
|
+
'min': undefined,
|
|
8572
|
+
'max': undefined,
|
|
8573
|
+
},
|
|
8574
|
+
'deposit': {
|
|
8575
|
+
'min': undefined,
|
|
8576
|
+
'max': undefined,
|
|
8577
|
+
},
|
|
8578
|
+
},
|
|
8579
|
+
'created': undefined,
|
|
8580
|
+
};
|
|
8581
|
+
}
|
|
8582
|
+
return result;
|
|
8583
|
+
}
|
|
8445
8584
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
8446
8585
|
if (!response) {
|
|
8447
8586
|
return undefined; // fallback to default error handler
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -4125,36 +4125,6 @@ class coinex extends coinex$1 {
|
|
|
4125
4125
|
const data = this.safeValue(response, 'data', {});
|
|
4126
4126
|
return this.parseLeverageTiers(data, symbols, undefined);
|
|
4127
4127
|
}
|
|
4128
|
-
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
4129
|
-
//
|
|
4130
|
-
// {
|
|
4131
|
-
// "BTCUSD": [
|
|
4132
|
-
// ["500001", "100", "0.005"],
|
|
4133
|
-
// ["1000001", "50", "0.01"],
|
|
4134
|
-
// ["2000001", "30", "0.015"],
|
|
4135
|
-
// ["5000001", "20", "0.02"],
|
|
4136
|
-
// ["10000001", "15", "0.025"],
|
|
4137
|
-
// ["20000001", "10", "0.03"]
|
|
4138
|
-
// ],
|
|
4139
|
-
// ...
|
|
4140
|
-
// }
|
|
4141
|
-
//
|
|
4142
|
-
const tiers = {};
|
|
4143
|
-
const marketIds = Object.keys(response);
|
|
4144
|
-
for (let i = 0; i < marketIds.length; i++) {
|
|
4145
|
-
const marketId = marketIds[i];
|
|
4146
|
-
const market = this.safeMarket(marketId, undefined, undefined, 'spot');
|
|
4147
|
-
const symbol = this.safeString(market, 'symbol');
|
|
4148
|
-
let symbolsLength = 0;
|
|
4149
|
-
if (symbols !== undefined) {
|
|
4150
|
-
symbolsLength = symbols.length;
|
|
4151
|
-
}
|
|
4152
|
-
if (symbol !== undefined && (symbolsLength === 0 || this.inArray(symbols, symbol))) {
|
|
4153
|
-
tiers[symbol] = this.parseMarketLeverageTiers(response[marketId], market);
|
|
4154
|
-
}
|
|
4155
|
-
}
|
|
4156
|
-
return tiers;
|
|
4157
|
-
}
|
|
4158
4128
|
parseMarketLeverageTiers(item, market = undefined) {
|
|
4159
4129
|
const tiers = [];
|
|
4160
4130
|
let minNotional = 0;
|
|
@@ -3805,28 +3805,7 @@ class digifinex extends digifinex$1 {
|
|
|
3805
3805
|
//
|
|
3806
3806
|
const data = this.safeValue(response, 'data', []);
|
|
3807
3807
|
symbols = this.marketSymbols(symbols);
|
|
3808
|
-
return this.parseLeverageTiers(data, symbols, '
|
|
3809
|
-
}
|
|
3810
|
-
parseLeverageTiers(response, symbols = undefined, marketIdKey = undefined) {
|
|
3811
|
-
const result = {};
|
|
3812
|
-
for (let i = 0; i < response.length; i++) {
|
|
3813
|
-
const entry = response[i];
|
|
3814
|
-
const marketId = this.safeString(entry, 'instrument_id');
|
|
3815
|
-
const market = this.safeMarket(marketId);
|
|
3816
|
-
const symbol = this.safeSymbol(marketId, market);
|
|
3817
|
-
let symbolsLength = 0;
|
|
3818
|
-
this.parseMarketLeverageTiers(response[i], market);
|
|
3819
|
-
if (symbols !== undefined) {
|
|
3820
|
-
symbolsLength = symbols.length;
|
|
3821
|
-
if (this.inArray(symbol, symbols)) {
|
|
3822
|
-
result[symbol] = this.parseMarketLeverageTiers(response[i], market);
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
if (symbol !== undefined && (symbolsLength === 0 || this.inArray(symbols, symbol))) {
|
|
3826
|
-
result[symbol] = this.parseMarketLeverageTiers(response[i], market);
|
|
3827
|
-
}
|
|
3828
|
-
}
|
|
3829
|
-
return result;
|
|
3808
|
+
return this.parseLeverageTiers(data, symbols, 'instrument_id');
|
|
3830
3809
|
}
|
|
3831
3810
|
async fetchMarketLeverageTiers(symbol, params = {}) {
|
|
3832
3811
|
/**
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -60,6 +60,8 @@ class okx extends okx$1 {
|
|
|
60
60
|
'fetchCanceledOrders': true,
|
|
61
61
|
'fetchClosedOrder': undefined,
|
|
62
62
|
'fetchClosedOrders': true,
|
|
63
|
+
'fetchConvertCurrencies': true,
|
|
64
|
+
'fetchConvertQuote': true,
|
|
63
65
|
'fetchCrossBorrowRate': true,
|
|
64
66
|
'fetchCrossBorrowRates': true,
|
|
65
67
|
'fetchCurrencies': true,
|
|
@@ -7604,6 +7606,157 @@ class okx extends okx$1 {
|
|
|
7604
7606
|
'quoteVolume': undefined,
|
|
7605
7607
|
};
|
|
7606
7608
|
}
|
|
7609
|
+
async fetchConvertQuote(fromCode, toCode, amount = undefined, params = {}) {
|
|
7610
|
+
/**
|
|
7611
|
+
* @method
|
|
7612
|
+
* @name okx#fetchConvertQuote
|
|
7613
|
+
* @description fetch a quote for converting from one currency to another
|
|
7614
|
+
* @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-estimate-quote
|
|
7615
|
+
* @param {string} fromCode the currency that you want to sell and convert from
|
|
7616
|
+
* @param {string} toCode the currency that you want to buy and convert into
|
|
7617
|
+
* @param {float} [amount] how much you want to trade in units of the from currency
|
|
7618
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7619
|
+
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/#/?id=conversion-structure}
|
|
7620
|
+
*/
|
|
7621
|
+
await this.loadMarkets();
|
|
7622
|
+
const request = {
|
|
7623
|
+
'baseCcy': fromCode.toUpperCase(),
|
|
7624
|
+
'quoteCcy': toCode.toUpperCase(),
|
|
7625
|
+
'rfqSzCcy': fromCode.toUpperCase(),
|
|
7626
|
+
'rfqSz': this.numberToString(amount),
|
|
7627
|
+
'side': 'sell',
|
|
7628
|
+
};
|
|
7629
|
+
const response = await this.privatePostAssetConvertEstimateQuote(this.extend(request, params));
|
|
7630
|
+
//
|
|
7631
|
+
// {
|
|
7632
|
+
// "code": "0",
|
|
7633
|
+
// "data": [
|
|
7634
|
+
// {
|
|
7635
|
+
// "baseCcy": "ETH",
|
|
7636
|
+
// "baseSz": "0.01023052",
|
|
7637
|
+
// "clQReqId": "",
|
|
7638
|
+
// "cnvtPx": "2932.40104429",
|
|
7639
|
+
// "origRfqSz": "30",
|
|
7640
|
+
// "quoteCcy": "USDT",
|
|
7641
|
+
// "quoteId": "quoterETH-USDT16461885104612381",
|
|
7642
|
+
// "quoteSz": "30",
|
|
7643
|
+
// "quoteTime": "1646188510461",
|
|
7644
|
+
// "rfqSz": "30",
|
|
7645
|
+
// "rfqSzCcy": "USDT",
|
|
7646
|
+
// "side": "buy",
|
|
7647
|
+
// "ttlMs": "10000"
|
|
7648
|
+
// }
|
|
7649
|
+
// ],
|
|
7650
|
+
// "msg": ""
|
|
7651
|
+
// }
|
|
7652
|
+
//
|
|
7653
|
+
const data = this.safeList(response, 'data', []);
|
|
7654
|
+
const result = this.safeDict(data, 0, {});
|
|
7655
|
+
const fromCurrencyId = this.safeString(result, 'baseCcy', fromCode);
|
|
7656
|
+
const fromCurrency = this.currency(fromCurrencyId);
|
|
7657
|
+
const toCurrencyId = this.safeString(result, 'quoteCcy', toCode);
|
|
7658
|
+
const toCurrency = this.currency(toCurrencyId);
|
|
7659
|
+
return this.parseConversion(result, fromCurrency, toCurrency);
|
|
7660
|
+
}
|
|
7661
|
+
parseConversion(conversion, fromCurrency = undefined, toCurrency = undefined) {
|
|
7662
|
+
//
|
|
7663
|
+
// fetchConvertQuote
|
|
7664
|
+
//
|
|
7665
|
+
// {
|
|
7666
|
+
// "baseCcy": "ETH",
|
|
7667
|
+
// "baseSz": "0.01023052",
|
|
7668
|
+
// "clQReqId": "",
|
|
7669
|
+
// "cnvtPx": "2932.40104429",
|
|
7670
|
+
// "origRfqSz": "30",
|
|
7671
|
+
// "quoteCcy": "USDT",
|
|
7672
|
+
// "quoteId": "quoterETH-USDT16461885104612381",
|
|
7673
|
+
// "quoteSz": "30",
|
|
7674
|
+
// "quoteTime": "1646188510461",
|
|
7675
|
+
// "rfqSz": "30",
|
|
7676
|
+
// "rfqSzCcy": "USDT",
|
|
7677
|
+
// "side": "buy",
|
|
7678
|
+
// "ttlMs": "10000"
|
|
7679
|
+
// }
|
|
7680
|
+
//
|
|
7681
|
+
const timestamp = this.safeInteger(conversion, 'quoteTime');
|
|
7682
|
+
const fromCoin = this.safeString(conversion, 'baseCcy');
|
|
7683
|
+
const fromCode = this.safeCurrencyCode(fromCoin, fromCurrency);
|
|
7684
|
+
const to = this.safeString(conversion, 'quoteCcy');
|
|
7685
|
+
const toCode = this.safeCurrencyCode(to, toCurrency);
|
|
7686
|
+
return {
|
|
7687
|
+
'info': conversion,
|
|
7688
|
+
'timestamp': timestamp,
|
|
7689
|
+
'datetime': this.iso8601(timestamp),
|
|
7690
|
+
'id': this.safeString(conversion, 'clQReqId'),
|
|
7691
|
+
'fromCurrency': fromCode,
|
|
7692
|
+
'fromAmount': this.safeNumber(conversion, 'baseSz'),
|
|
7693
|
+
'toCurrency': toCode,
|
|
7694
|
+
'toAmount': this.safeNumber(conversion, 'quoteSz'),
|
|
7695
|
+
'price': this.safeNumber(conversion, 'cnvtPx'),
|
|
7696
|
+
'fee': undefined,
|
|
7697
|
+
};
|
|
7698
|
+
}
|
|
7699
|
+
async fetchConvertCurrencies(params = {}) {
|
|
7700
|
+
/**
|
|
7701
|
+
* @method
|
|
7702
|
+
* @name okx#fetchConvertCurrencies
|
|
7703
|
+
* @description fetches all available currencies that can be converted
|
|
7704
|
+
* @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-convert-currencies
|
|
7705
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
7706
|
+
* @returns {object} an associative dictionary of currencies
|
|
7707
|
+
*/
|
|
7708
|
+
await this.loadMarkets();
|
|
7709
|
+
const response = await this.privateGetAssetConvertCurrencies(params);
|
|
7710
|
+
//
|
|
7711
|
+
// {
|
|
7712
|
+
// "code": "0",
|
|
7713
|
+
// "data": [
|
|
7714
|
+
// {
|
|
7715
|
+
// "ccy": "BTC",
|
|
7716
|
+
// "max": "",
|
|
7717
|
+
// "min": ""
|
|
7718
|
+
// },
|
|
7719
|
+
// ],
|
|
7720
|
+
// "msg": ""
|
|
7721
|
+
// }
|
|
7722
|
+
//
|
|
7723
|
+
const result = {};
|
|
7724
|
+
const data = this.safeList(response, 'data', []);
|
|
7725
|
+
for (let i = 0; i < data.length; i++) {
|
|
7726
|
+
const entry = data[i];
|
|
7727
|
+
const id = this.safeString(entry, 'ccy');
|
|
7728
|
+
const code = this.safeCurrencyCode(id);
|
|
7729
|
+
result[code] = {
|
|
7730
|
+
'info': entry,
|
|
7731
|
+
'id': id,
|
|
7732
|
+
'code': code,
|
|
7733
|
+
'networks': undefined,
|
|
7734
|
+
'type': undefined,
|
|
7735
|
+
'name': undefined,
|
|
7736
|
+
'active': undefined,
|
|
7737
|
+
'deposit': undefined,
|
|
7738
|
+
'withdraw': undefined,
|
|
7739
|
+
'fee': undefined,
|
|
7740
|
+
'precision': undefined,
|
|
7741
|
+
'limits': {
|
|
7742
|
+
'amount': {
|
|
7743
|
+
'min': this.safeNumber(entry, 'min'),
|
|
7744
|
+
'max': this.safeNumber(entry, 'max'),
|
|
7745
|
+
},
|
|
7746
|
+
'withdraw': {
|
|
7747
|
+
'min': undefined,
|
|
7748
|
+
'max': undefined,
|
|
7749
|
+
},
|
|
7750
|
+
'deposit': {
|
|
7751
|
+
'min': undefined,
|
|
7752
|
+
'max': undefined,
|
|
7753
|
+
},
|
|
7754
|
+
},
|
|
7755
|
+
'created': undefined,
|
|
7756
|
+
};
|
|
7757
|
+
}
|
|
7758
|
+
return result;
|
|
7759
|
+
}
|
|
7607
7760
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
7608
7761
|
if (!response) {
|
|
7609
7762
|
return undefined; // fallback to default error handler
|