ccxt 4.1.4 → 4.1.6

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.
Files changed (72) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1231 -81
  3. package/dist/ccxt.browser.min.js +12 -12
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +216 -0
  6. package/dist/cjs/src/binance.js +96 -1
  7. package/dist/cjs/src/bingx.js +24 -0
  8. package/dist/cjs/src/bitfinex2.js +55 -11
  9. package/dist/cjs/src/bitget.js +132 -12
  10. package/dist/cjs/src/bitmex.js +49 -0
  11. package/dist/cjs/src/bybit.js +56 -3
  12. package/dist/cjs/src/coinbase.js +85 -6
  13. package/dist/cjs/src/coinbasepro.js +18 -0
  14. package/dist/cjs/src/coinex.js +1 -1
  15. package/dist/cjs/src/coinsph.js +1 -2
  16. package/dist/cjs/src/cryptocom.js +30 -0
  17. package/dist/cjs/src/gate.js +56 -3
  18. package/dist/cjs/src/huobi.js +69 -4
  19. package/dist/cjs/src/kraken.js +18 -8
  20. package/dist/cjs/src/krakenfutures.js +24 -0
  21. package/dist/cjs/src/kucoin.js +59 -4
  22. package/dist/cjs/src/kucoinfutures.js +35 -1
  23. package/dist/cjs/src/kuna.js +97 -10
  24. package/dist/cjs/src/okx.js +66 -4
  25. package/dist/cjs/src/poloniex.js +18 -2
  26. package/dist/cjs/src/pro/bitget.js +22 -6
  27. package/js/ccxt.d.ts +1 -1
  28. package/js/ccxt.js +1 -1
  29. package/js/src/abstract/kuna.d.ts +34 -0
  30. package/js/src/base/Exchange.d.ts +7 -0
  31. package/js/src/base/Exchange.js +216 -0
  32. package/js/src/binance.d.ts +5 -5
  33. package/js/src/binance.js +96 -1
  34. package/js/src/bingx.d.ts +1 -1
  35. package/js/src/bingx.js +24 -0
  36. package/js/src/bitfinex2.d.ts +3 -3
  37. package/js/src/bitfinex2.js +56 -12
  38. package/js/src/bitget.d.ts +7 -6
  39. package/js/src/bitget.js +132 -12
  40. package/js/src/bitmex.d.ts +6 -6
  41. package/js/src/bitmex.js +49 -0
  42. package/js/src/bybit.d.ts +6 -6
  43. package/js/src/bybit.js +56 -3
  44. package/js/src/coinbase.d.ts +5 -5
  45. package/js/src/coinbase.js +86 -7
  46. package/js/src/coinbasepro.d.ts +5 -5
  47. package/js/src/coinbasepro.js +18 -0
  48. package/js/src/coinex.js +1 -1
  49. package/js/src/coinsph.js +1 -2
  50. package/js/src/cryptocom.d.ts +4 -4
  51. package/js/src/cryptocom.js +30 -0
  52. package/js/src/gate.d.ts +4 -4
  53. package/js/src/gate.js +56 -3
  54. package/js/src/huobi.d.ts +2 -2
  55. package/js/src/huobi.js +69 -4
  56. package/js/src/kraken.d.ts +2 -2
  57. package/js/src/kraken.js +18 -8
  58. package/js/src/krakenfutures.d.ts +2 -2
  59. package/js/src/krakenfutures.js +24 -0
  60. package/js/src/kucoin.d.ts +5 -5
  61. package/js/src/kucoin.js +59 -4
  62. package/js/src/kucoinfutures.d.ts +4 -4
  63. package/js/src/kucoinfutures.js +35 -1
  64. package/js/src/kuna.d.ts +1 -0
  65. package/js/src/kuna.js +97 -10
  66. package/js/src/okx.d.ts +6 -6
  67. package/js/src/okx.js +66 -4
  68. package/js/src/poloniex.d.ts +1 -1
  69. package/js/src/poloniex.js +18 -2
  70. package/js/src/pro/bitget.d.ts +5 -0
  71. package/js/src/pro/bitget.js +22 -6
  72. package/package.json +1 -1
@@ -1558,9 +1558,15 @@ class kucoin extends kucoin$1 {
1558
1558
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
1559
1559
  * @param {int} [limit] the maximum amount of candles to fetch
1560
1560
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
1561
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1561
1562
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1562
1563
  */
1563
1564
  await this.loadMarkets();
1565
+ let paginate = false;
1566
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1567
+ if (paginate) {
1568
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1500);
1569
+ }
1564
1570
  const market = this.market(symbol);
1565
1571
  const marketId = market['id'];
1566
1572
  const request = {
@@ -2216,8 +2222,15 @@ class kucoin extends kucoin$1 {
2216
2222
  * @param {string} [params.tradeType] TRADE for spot trading, MARGIN_TRADE for Margin Trading
2217
2223
  * @param {bool} [params.stop] True if fetching a stop order
2218
2224
  * @param {bool} [params.hf] false, // true for hf order
2225
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2219
2226
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2220
2227
  */
2228
+ await this.loadMarkets;
2229
+ let paginate = false;
2230
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
2231
+ if (paginate) {
2232
+ return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
2233
+ }
2221
2234
  return await this.fetchOrdersByStatus('done', symbol, since, limit, params);
2222
2235
  }
2223
2236
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2242,8 +2255,15 @@ class kucoin extends kucoin$1 {
2242
2255
  * @param {string} [params.orderIds] *stop orders only* comma seperated order ID list
2243
2256
  * @param {bool} [params.stop] True if fetching a stop order
2244
2257
  * @param {bool} [params.hf] false, // true for hf order
2258
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2245
2259
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2246
2260
  */
2261
+ await this.loadMarkets;
2262
+ let paginate = false;
2263
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
2264
+ if (paginate) {
2265
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params);
2266
+ }
2247
2267
  return await this.fetchOrdersByStatus('active', symbol, since, limit, params);
2248
2268
  }
2249
2269
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -2530,11 +2550,18 @@ class kucoin extends kucoin$1 {
2530
2550
  * @param {int} [since] the earliest time in ms to fetch trades for
2531
2551
  * @param {int} [limit] the maximum number of trades structures to retrieve
2532
2552
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
2553
+ * @param {int} [params.until] the latest time in ms to fetch entries for
2533
2554
  * @param {bool} [params.hf] false, // true for hf order
2555
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2534
2556
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
2535
2557
  */
2536
2558
  await this.loadMarkets();
2537
- const request = {};
2559
+ let paginate = false;
2560
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
2561
+ if (paginate) {
2562
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
2563
+ }
2564
+ let request = {};
2538
2565
  const hf = this.safeValue(params, 'hf', false);
2539
2566
  if (hf && symbol === undefined) {
2540
2567
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol parameter for hf orders');
@@ -2576,6 +2603,7 @@ class kucoin extends kucoin$1 {
2576
2603
  else {
2577
2604
  throw new errors.ExchangeError(this.id + ' fetchMyTradesMethod() invalid method');
2578
2605
  }
2606
+ [request, params] = this.handleUntilOption('endAt', request, params);
2579
2607
  const response = await this[method](this.extend(request, params));
2580
2608
  //
2581
2609
  // {
@@ -3017,6 +3045,8 @@ class kucoin extends kucoin$1 {
3017
3045
  /**
3018
3046
  * @method
3019
3047
  * @name kucoin#fetchDeposits
3048
+ * @see https://docs.kucoin.com/#get-deposit-list
3049
+ * @see https://docs.kucoin.com/#get-v1-historical-deposits-list
3020
3050
  * @description fetch all deposits made to an account
3021
3051
  * @see https://docs.kucoin.com/#get-deposit-list
3022
3052
  * @see https://docs.kucoin.com/#get-v1-historical-deposits-list
@@ -3024,10 +3054,17 @@ class kucoin extends kucoin$1 {
3024
3054
  * @param {int} [since] the earliest time in ms to fetch deposits for
3025
3055
  * @param {int} [limit] the maximum number of deposits structures to retrieve
3026
3056
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
3057
+ * @param {int} [params.until] the latest time in ms to fetch entries for
3058
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3027
3059
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
3028
3060
  */
3029
3061
  await this.loadMarkets();
3030
- const request = {};
3062
+ let paginate = false;
3063
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
3064
+ if (paginate) {
3065
+ return await this.fetchPaginatedCallDynamic('fetchDeposits', code, since, limit, params);
3066
+ }
3067
+ let request = {};
3031
3068
  let currency = undefined;
3032
3069
  if (code !== undefined) {
3033
3070
  currency = this.currency(code);
@@ -3047,6 +3084,7 @@ class kucoin extends kucoin$1 {
3047
3084
  request['startAt'] = since;
3048
3085
  }
3049
3086
  }
3087
+ [request, params] = this.handleUntilOption('endAt', request, params);
3050
3088
  const response = await this[method](this.extend(request, params));
3051
3089
  //
3052
3090
  // {
@@ -3100,10 +3138,17 @@ class kucoin extends kucoin$1 {
3100
3138
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
3101
3139
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
3102
3140
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
3141
+ * @param {int} [params.until] the latest time in ms to fetch entries for
3142
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3103
3143
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
3104
3144
  */
3105
3145
  await this.loadMarkets();
3106
- const request = {};
3146
+ let paginate = false;
3147
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
3148
+ if (paginate) {
3149
+ return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
3150
+ }
3151
+ let request = {};
3107
3152
  let currency = undefined;
3108
3153
  if (code !== undefined) {
3109
3154
  currency = this.currency(code);
@@ -3123,6 +3168,7 @@ class kucoin extends kucoin$1 {
3123
3168
  request['startAt'] = since;
3124
3169
  }
3125
3170
  }
3171
+ [request, params] = this.handleUntilOption('endAt', request, params);
3126
3172
  const response = await this[method](this.extend(request, params));
3127
3173
  //
3128
3174
  // {
@@ -3609,17 +3655,25 @@ class kucoin extends kucoin$1 {
3609
3655
  /**
3610
3656
  * @method
3611
3657
  * @name kucoin#fetchLedger
3658
+ * @see https://docs.kucoin.com/#get-account-ledgers
3612
3659
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
3613
3660
  * @see https://docs.kucoin.com/#get-account-ledgers
3614
3661
  * @param {string} code unified currency code, default is undefined
3615
3662
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
3616
3663
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
3617
3664
  * @param {object} [params] extra parameters specific to the kucoin api endpoint
3665
+ * @param {int} [params.until] the latest time in ms to fetch entries for
3666
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3618
3667
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
3619
3668
  */
3620
3669
  await this.loadMarkets();
3621
3670
  await this.loadAccounts();
3622
- const request = {
3671
+ let paginate = false;
3672
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
3673
+ if (paginate) {
3674
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
3675
+ }
3676
+ let request = {
3623
3677
  // 'currency': currency['id'], // can choose up to 10, if not provided returns for all currencies by default
3624
3678
  // 'direction': 'in', // 'out'
3625
3679
  // 'bizType': 'DEPOSIT', // DEPOSIT, WITHDRAW, TRANSFER, SUB_TRANSFER,TRADE_EXCHANGE, MARGIN_EXCHANGE, KUCOIN_BONUS (optional)
@@ -3635,6 +3689,7 @@ class kucoin extends kucoin$1 {
3635
3689
  currency = this.currency(code);
3636
3690
  request['currency'] = currency['id'];
3637
3691
  }
3692
+ [request, params] = this.handleUntilOption('endAt', request, params);
3638
3693
  const response = await this.privateGetAccountsLedgers(this.extend(request, params));
3639
3694
  //
3640
3695
  // {
@@ -537,9 +537,15 @@ class kucoinfutures extends kucoinfutures$1 {
537
537
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
538
538
  * @param {int} [limit] the maximum amount of candles to fetch
539
539
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
540
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
540
541
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
541
542
  */
542
543
  await this.loadMarkets();
544
+ let paginate = false;
545
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
546
+ if (paginate) {
547
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 200);
548
+ }
543
549
  const market = this.market(symbol);
544
550
  const marketId = market['id'];
545
551
  const parsedTimeframe = this.safeInteger(this.timeframes, timeframe);
@@ -1419,9 +1425,15 @@ class kucoinfutures extends kucoinfutures$1 {
1419
1425
  * @param {int} [params.until] End time in ms
1420
1426
  * @param {string} [params.side] buy or sell
1421
1427
  * @param {string} [params.type] limit or market
1428
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1422
1429
  * @returns An [array of order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1423
1430
  */
1424
1431
  await this.loadMarkets();
1432
+ let paginate = false;
1433
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrdersByStatus', 'paginate');
1434
+ if (paginate) {
1435
+ return await this.fetchPaginatedCallDynamic('fetchOrdersByStatus', symbol, since, limit, params);
1436
+ }
1425
1437
  const stop = this.safeValue(params, 'stop');
1426
1438
  const until = this.safeInteger2(params, 'until', 'till');
1427
1439
  params = this.omit(params, ['stop', 'until', 'till']);
@@ -1519,8 +1531,15 @@ class kucoinfutures extends kucoinfutures$1 {
1519
1531
  * @param {int} [params.till] end time in ms
1520
1532
  * @param {string} [params.side] buy or sell
1521
1533
  * @param {string} [params.type] limit, or market
1534
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1522
1535
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1523
1536
  */
1537
+ await this.loadMarkets;
1538
+ let paginate = false;
1539
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
1540
+ if (paginate) {
1541
+ return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
1542
+ }
1524
1543
  return await this.fetchOrdersByStatus('done', symbol, since, limit, params);
1525
1544
  }
1526
1545
  async fetchOrder(id = undefined, symbol = undefined, params = {}) {
@@ -1879,15 +1898,23 @@ class kucoinfutures extends kucoinfutures$1 {
1879
1898
  /**
1880
1899
  * @method
1881
1900
  * @name kucoinfutures#fetchMyTrades
1901
+ * @see https://docs.kucoin.com/futures/#get-fills
1882
1902
  * @description fetch all trades made by the user
1883
1903
  * @param {string} symbol unified market symbol
1884
1904
  * @param {int} [since] the earliest time in ms to fetch trades for
1885
1905
  * @param {int} [limit] the maximum number of trades structures to retrieve
1886
1906
  * @param {object} [params] extra parameters specific to the kucoinfutures api endpoint
1907
+ * @param {int} [params.until] End time in ms
1908
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1887
1909
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1888
1910
  */
1889
1911
  await this.loadMarkets();
1890
- const request = {
1912
+ let paginate = false;
1913
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1914
+ if (paginate) {
1915
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1916
+ }
1917
+ let request = {
1891
1918
  // orderId (String) [optional] Fills for a specific order (other parameters can be ignored if specified)
1892
1919
  // symbol (String) [optional] Symbol of the contract
1893
1920
  // side (String) [optional] buy or sell
@@ -1903,6 +1930,7 @@ class kucoinfutures extends kucoinfutures$1 {
1903
1930
  if (since !== undefined) {
1904
1931
  request['startAt'] = since;
1905
1932
  }
1933
+ [request, params] = this.handleUntilOption('endAt', request, params);
1906
1934
  const response = await this.futuresPrivateGetFills(this.extend(request, params));
1907
1935
  //
1908
1936
  // {
@@ -2303,12 +2331,18 @@ class kucoinfutures extends kucoinfutures$1 {
2303
2331
  * @param {int} [since] not used by kucuoinfutures
2304
2332
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
2305
2333
  * @param {object} [params] extra parameters specific to the okx api endpoint
2334
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2306
2335
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2307
2336
  */
2308
2337
  if (symbol === undefined) {
2309
2338
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2310
2339
  }
2311
2340
  await this.loadMarkets();
2341
+ let paginate = false;
2342
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2343
+ if (paginate) {
2344
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2345
+ }
2312
2346
  const market = this.market(symbol);
2313
2347
  const request = {
2314
2348
  'symbol': market['id'],
@@ -4,12 +4,14 @@ var kuna$1 = require('./abstract/kuna.js');
4
4
  var errors = require('./base/errors.js');
5
5
  var number = require('./base/functions/number.js');
6
6
  var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
7
+ var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
7
8
 
8
9
  // ---------------------------------------------------------------------------
9
10
  // ---------------------------------------------------------------------------
10
11
  /**
11
12
  * @class kuna
12
13
  * @extends Exchange
14
+ * @description Use the public-key as your apiKey
13
15
  */
14
16
  class kuna extends kuna$1 {
15
17
  describe() {
@@ -67,6 +69,7 @@ class kuna extends kuna$1 {
67
69
  'api': {
68
70
  'xreserve': 'https://api.xreserve.fund',
69
71
  'v3': 'https://api.kuna.io',
72
+ 'v4': 'https://api.kuna.io',
70
73
  'public': 'https://kuna.io',
71
74
  'private': 'https://kuna.io', // v2
72
75
  },
@@ -85,6 +88,54 @@ class kuna extends kuna$1 {
85
88
  'delegate-transfer': 1,
86
89
  },
87
90
  },
91
+ 'v4': {
92
+ 'private': {
93
+ 'get': {
94
+ 'me': 1,
95
+ 'getBalance': 1,
96
+ 'active': 1,
97
+ 'order/history': 1,
98
+ 'order/private/{id}/trades': 1,
99
+ 'order/details/{id}?withTrades={withTrades}': 1,
100
+ 'trade/history': 1,
101
+ 'transaction/{hash}': 1,
102
+ 'deposit/preRequest': 1,
103
+ 'deposit/crypto/address': 1,
104
+ 'deposit/crypto/getMerchantAddress': 1,
105
+ 'deposit/history': 1,
106
+ 'deposit/details/{depositId}': 1,
107
+ 'withdraw/preRequest': 1,
108
+ 'withdraw/history': 1,
109
+ 'withdraw/details/{withdrawId}': 1,
110
+ 'kuna-code/{id}': 1,
111
+ 'kuna-code/{code}/check': 1,
112
+ 'kuna-code/issued-by-me': 1,
113
+ 'kuna-code/redeemed-by-me': 1,
114
+ },
115
+ 'post': {
116
+ 'order/create': 1,
117
+ 'order/cancel': 1,
118
+ 'order/cancel/multi': 1,
119
+ 'deposit/crypto/generateAddress': 1,
120
+ 'deposit/crypto/generateMerchantAddress': 1,
121
+ 'withdraw/create': 1,
122
+ 'kuna-code': 1,
123
+ },
124
+ 'put': {
125
+ 'kuna-code/redeem': 1,
126
+ },
127
+ },
128
+ 'public': {
129
+ 'get': {
130
+ 'timestamp': 1,
131
+ 'fees': 1,
132
+ 'currencies?type={type}': 1,
133
+ 'markets/getAll': 1,
134
+ 'markets/tickers?pairs={pairs}': 1,
135
+ 'order/book/{pairs}': 1,
136
+ },
137
+ },
138
+ },
88
139
  'v3': {
89
140
  'public': {
90
141
  'get': {
@@ -292,6 +343,9 @@ class kuna extends kuna$1 {
292
343
  '2002': errors.InsufficientFunds,
293
344
  '2003': errors.OrderNotFound,
294
345
  },
346
+ 'options': {
347
+ // 'account': 'pro' // Only for pro accounts
348
+ },
295
349
  });
296
350
  }
297
351
  async fetchTime(params = {}) {
@@ -848,20 +902,53 @@ class kuna extends kuna$1 {
848
902
  let url = undefined;
849
903
  if (Array.isArray(api)) {
850
904
  const [version, access] = api;
851
- url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams(path, params);
852
- if (access === 'public') {
853
- if (method === 'GET') {
854
- if (Object.keys(params).length) {
855
- url += '?' + this.urlencode(params);
905
+ if (version === 'v3') {
906
+ url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams(path, params);
907
+ if (access === 'public') {
908
+ if (method === 'GET') {
909
+ if (Object.keys(params).length) {
910
+ url += '?' + this.urlencode(params);
911
+ }
912
+ }
913
+ else if ((method === 'POST') || (method === 'PUT')) {
914
+ headers = { 'Content-Type': 'application/json' };
915
+ body = this.json(params);
856
916
  }
857
917
  }
858
- else if ((method === 'POST') || (method === 'PUT')) {
859
- headers = { 'Content-Type': 'application/json' };
860
- body = this.json(params);
918
+ else if (access === 'private') {
919
+ throw new errors.NotSupported(this.id + ' private v3 API is not supported yet');
861
920
  }
862
921
  }
863
- else if (access === 'private') {
864
- throw new errors.NotSupported(this.id + ' private v3 API is not supported yet');
922
+ else if (version === 'v4') {
923
+ const splitPath = path.split('/');
924
+ const splitPathLength = splitPath.length;
925
+ let urlPath = '';
926
+ if ((splitPathLength > 1) && (splitPath[0] !== 'kuna-code')) {
927
+ let pathTail = '';
928
+ for (let i = 1; i < splitPathLength; i++) {
929
+ pathTail += splitPath[i];
930
+ }
931
+ urlPath = '/' + version + '/' + splitPath[0] + '/' + access + '/' + this.implodeParams(pathTail, params);
932
+ }
933
+ else {
934
+ urlPath = '/' + version + '/' + access + '/' + this.implodeParams(path, params);
935
+ }
936
+ url = this.urls['api'][version] + urlPath;
937
+ if (access === 'private') {
938
+ const nonce = this.nonce();
939
+ const auth = urlPath + nonce + this.json(params);
940
+ headers = {
941
+ 'content-type': 'application/json',
942
+ 'accept': 'application/json',
943
+ 'nonce': nonce,
944
+ 'public-key': this.apiKey,
945
+ 'signature': this.hmac(this.encode(auth), this.encode(this.secret), sha512.sha384, 'hex'),
946
+ };
947
+ const account = this.safeString(this.options, 'account');
948
+ if (account === 'pro') {
949
+ headers['account'] = 'pro';
950
+ }
951
+ }
865
952
  }
866
953
  }
867
954
  else {
@@ -1940,9 +1940,15 @@ class okx extends okx$1 {
1940
1940
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1941
1941
  * @param {int} [limit] the maximum amount of trades to fetch
1942
1942
  * @param {object} [params] extra parameters specific to the okx api endpoint
1943
+ * @param {boolean} [params.paginate] *only applies to publicGetMarketHistoryTrades* default false, when true will automatically paginate by calling this endpoint multiple times
1943
1944
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
1944
1945
  */
1945
1946
  await this.loadMarkets();
1947
+ let paginate = false;
1948
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
1949
+ if (paginate) {
1950
+ return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'tradeId', 'after', undefined, 100);
1951
+ }
1946
1952
  const market = this.market(symbol);
1947
1953
  const request = {
1948
1954
  'instId': market['id'],
@@ -2045,10 +2051,16 @@ class okx extends okx$1 {
2045
2051
  * @param {object} [params] extra parameters specific to the okx api endpoint
2046
2052
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
2047
2053
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
2054
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2048
2055
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2049
2056
  */
2050
2057
  await this.loadMarkets();
2051
2058
  const market = this.market(symbol);
2059
+ let paginate = false;
2060
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
2061
+ if (paginate) {
2062
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 200);
2063
+ }
2052
2064
  const price = this.safeString(params, 'price');
2053
2065
  params = this.omit(params, 'price');
2054
2066
  const options = this.safeValue(this.options, 'fetchOHLCV', {});
@@ -2139,12 +2151,18 @@ class okx extends okx$1 {
2139
2151
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2140
2152
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
2141
2153
  * @param {object} [params] extra parameters specific to the okx api endpoint
2154
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2142
2155
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2143
2156
  */
2144
2157
  if (symbol === undefined) {
2145
2158
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2146
2159
  }
2147
2160
  await this.loadMarkets();
2161
+ let paginate = false;
2162
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2163
+ if (paginate) {
2164
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2165
+ }
2148
2166
  const market = this.market(symbol);
2149
2167
  const request = {
2150
2168
  'instId': market['id'],
@@ -3377,9 +3395,15 @@ class okx extends okx$1 {
3377
3395
  * @param {bool} [params.stop] True if fetching trigger or conditional orders
3378
3396
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3379
3397
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
3398
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3380
3399
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3381
3400
  */
3382
3401
  await this.loadMarkets();
3402
+ let paginate = false;
3403
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
3404
+ if (paginate) {
3405
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params);
3406
+ }
3383
3407
  const request = {
3384
3408
  // 'instType': 'SPOT', // SPOT, MARGIN, SWAP, FUTURES, OPTION
3385
3409
  // 'uly': currency['id'],
@@ -3703,9 +3727,15 @@ class okx extends okx$1 {
3703
3727
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3704
3728
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
3705
3729
  * @param {int} [params.until] timestamp in ms to fetch orders for
3730
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3706
3731
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3707
3732
  */
3708
3733
  await this.loadMarkets();
3734
+ let paginate = false;
3735
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
3736
+ if (paginate) {
3737
+ return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
3738
+ }
3709
3739
  const request = {
3710
3740
  // 'instType': type.toUpperCase (), // SPOT, MARGIN, SWAP, FUTURES, OPTION
3711
3741
  // 'uly': currency['id'],
@@ -3865,10 +3895,17 @@ class okx extends okx$1 {
3865
3895
  * @param {int} [since] the earliest time in ms to fetch trades for
3866
3896
  * @param {int} [limit] the maximum number of trades structures to retrieve
3867
3897
  * @param {object} [params] extra parameters specific to the okx api endpoint
3898
+ * @param {int} [params.until] Timestamp in ms of the latest time to retrieve trades for
3899
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3868
3900
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
3869
3901
  */
3870
3902
  await this.loadMarkets();
3871
- const request = {
3903
+ let paginate = false;
3904
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
3905
+ if (paginate) {
3906
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
3907
+ }
3908
+ let request = {
3872
3909
  // 'instType': 'SPOT', // SPOT, MARGIN, SWAP, FUTURES, OPTION
3873
3910
  // 'uly': currency['id'],
3874
3911
  // 'instId': market['id'],
@@ -3882,6 +3919,7 @@ class okx extends okx$1 {
3882
3919
  market = this.market(symbol);
3883
3920
  request['instId'] = market['id'];
3884
3921
  }
3922
+ [request, params] = this.handleUntilOption('end', params, request);
3885
3923
  const [type, query] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
3886
3924
  request['instType'] = this.convertToInstrumentType(type);
3887
3925
  if (limit !== undefined) {
@@ -3951,14 +3989,21 @@ class okx extends okx$1 {
3951
3989
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
3952
3990
  * @param {object} [params] extra parameters specific to the okx api endpoint
3953
3991
  * @param {string} [params.marginMode] 'cross' or 'isolated'
3992
+ * @param {int} [params.until] the latest time in ms to fetch entries for
3993
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3954
3994
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
3955
3995
  */
3956
3996
  await this.loadMarkets();
3997
+ let paginate = false;
3998
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
3999
+ if (paginate) {
4000
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
4001
+ }
3957
4002
  const options = this.safeValue(this.options, 'fetchLedger', {});
3958
4003
  let method = this.safeString(options, 'method');
3959
4004
  method = this.safeString(params, 'method', method);
3960
4005
  params = this.omit(params, 'method');
3961
- const request = {
4006
+ let request = {
3962
4007
  // 'instType': undefined, // 'SPOT', 'MARGIN', 'SWAP', 'FUTURES", 'OPTION'
3963
4008
  // 'ccy': undefined, // currency['id'],
3964
4009
  // 'mgnMode': undefined, // 'isolated', 'cross'
@@ -3993,6 +4038,7 @@ class okx extends okx$1 {
3993
4038
  currency = this.currency(code);
3994
4039
  request['ccy'] = currency['id'];
3995
4040
  }
4041
+ [request, params] = this.handleUntilOption('end', params, request);
3996
4042
  const response = await this[method](this.extend(request, query));
3997
4043
  //
3998
4044
  // privateGetAccountBills, privateGetAccountBillsArchive
@@ -4407,10 +4453,17 @@ class okx extends okx$1 {
4407
4453
  * @param {int} [since] the earliest time in ms to fetch deposits for
4408
4454
  * @param {int} [limit] the maximum number of deposits structures to retrieve
4409
4455
  * @param {object} [params] extra parameters specific to the okx api endpoint
4456
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4457
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4410
4458
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
4411
4459
  */
4412
4460
  await this.loadMarkets();
4413
- const request = {
4461
+ let paginate = false;
4462
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
4463
+ if (paginate) {
4464
+ return await this.fetchPaginatedCallDynamic('fetchDeposits', code, since, limit, params);
4465
+ }
4466
+ let request = {
4414
4467
  // 'ccy': currency['id'],
4415
4468
  // 'state': 2, // 0 waiting for confirmation, 1 deposit credited, 2 deposit successful
4416
4469
  // 'after': since,
@@ -4428,6 +4481,7 @@ class okx extends okx$1 {
4428
4481
  if (limit !== undefined) {
4429
4482
  request['limit'] = limit; // default 100, max 100
4430
4483
  }
4484
+ [request, params] = this.handleUntilOption('after', params, request);
4431
4485
  const response = await this.privateGetAssetDepositHistory(this.extend(request, params));
4432
4486
  //
4433
4487
  // {
@@ -4505,10 +4559,17 @@ class okx extends okx$1 {
4505
4559
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
4506
4560
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
4507
4561
  * @param {object} [params] extra parameters specific to the okx api endpoint
4562
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4563
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4508
4564
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
4509
4565
  */
4510
4566
  await this.loadMarkets();
4511
- const request = {
4567
+ let paginate = false;
4568
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
4569
+ if (paginate) {
4570
+ return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
4571
+ }
4572
+ let request = {
4512
4573
  // 'ccy': currency['id'],
4513
4574
  // 'state': 2, // -3: pending cancel, -2 canceled, -1 failed, 0, pending, 1 sending, 2 sent, 3 awaiting email verification, 4 awaiting manual verification, 5 awaiting identity verification
4514
4575
  // 'after': since,
@@ -4526,6 +4587,7 @@ class okx extends okx$1 {
4526
4587
  if (limit !== undefined) {
4527
4588
  request['limit'] = limit; // default 100, max 100
4528
4589
  }
4590
+ [request, params] = this.handleUntilOption('after', request, params);
4529
4591
  const response = await this.privateGetAssetWithdrawalHistory(this.extend(request, params));
4530
4592
  //
4531
4593
  // {