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
@@ -2386,10 +2386,16 @@ class bybit extends bybit$1 {
2386
2386
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
2387
2387
  * @param {int} [limit] the maximum amount of candles to fetch
2388
2388
  * @param {object} [params] extra parameters specific to the bybit api endpoint
2389
+ * @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)
2389
2390
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2390
2391
  */
2391
2392
  this.checkRequiredSymbol('fetchOHLCV', symbol);
2392
2393
  await this.loadMarkets();
2394
+ let paginate = false;
2395
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
2396
+ if (paginate) {
2397
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
2398
+ }
2393
2399
  const market = this.market(symbol);
2394
2400
  const request = {
2395
2401
  'symbol': market['id'],
@@ -2624,6 +2630,7 @@ class bybit extends bybit$1 {
2624
2630
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
2625
2631
  * @param {object} [params] extra parameters specific to the bybit api endpoint
2626
2632
  * @param {int} [params.until] timestamp in ms of the latest funding rate
2633
+ * @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)
2627
2634
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2628
2635
  */
2629
2636
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
@@ -2631,6 +2638,11 @@ class bybit extends bybit$1 {
2631
2638
  if (limit === undefined) {
2632
2639
  limit = 200;
2633
2640
  }
2641
+ let paginate = false;
2642
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2643
+ if (paginate) {
2644
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200);
2645
+ }
2634
2646
  const request = {
2635
2647
  // 'category': '', // Product type. linear,inverse
2636
2648
  // 'symbol': '', // Symbol name
@@ -4450,9 +4462,16 @@ class bybit extends bybit$1 {
4450
4462
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4451
4463
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4452
4464
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4465
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4466
+ * @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)
4453
4467
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4454
4468
  */
4455
4469
  await this.loadMarkets();
4470
+ let paginate = false;
4471
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
4472
+ if (paginate) {
4473
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4474
+ }
4456
4475
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4457
4476
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4458
4477
  const request = {};
@@ -4824,9 +4843,15 @@ class bybit extends bybit$1 {
4824
4843
  * @param {boolean} [params.stop] true if stop order
4825
4844
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4826
4845
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4846
+ * @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)
4827
4847
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
4828
4848
  */
4829
4849
  await this.loadMarkets();
4850
+ let paginate = false;
4851
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
4852
+ if (paginate) {
4853
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 100);
4854
+ }
4830
4855
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4831
4856
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4832
4857
  const request = {};
@@ -5040,11 +5065,17 @@ class bybit extends bybit$1 {
5040
5065
  * @param {int} [params.until] the latest time in ms to fetch deposits for, default = 30 days after since
5041
5066
  *
5042
5067
  * EXCHANGE SPECIFIC PARAMETERS
5068
+ * @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)
5043
5069
  * @param {string} [params.cursor] used for pagination
5044
5070
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5045
5071
  */
5046
5072
  await this.loadMarkets();
5047
- const request = {
5073
+ let paginate = false;
5074
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
5075
+ if (paginate) {
5076
+ return await this.fetchPaginatedCallCursor('fetchDeposits', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5077
+ }
5078
+ let request = {
5048
5079
  // 'coin': currency['id'],
5049
5080
  // 'limit': 20, // max 50
5050
5081
  // 'cursor': '',
@@ -5060,6 +5091,7 @@ class bybit extends bybit$1 {
5060
5091
  if (limit !== undefined) {
5061
5092
  request['limit'] = limit;
5062
5093
  }
5094
+ [request, params] = this.handleUntilOption('endTime', request, params);
5063
5095
  const response = await this.privateGetV5AssetDepositQueryRecord(this.extend(request, params));
5064
5096
  //
5065
5097
  // {
@@ -5101,10 +5133,17 @@ class bybit extends bybit$1 {
5101
5133
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
5102
5134
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
5103
5135
  * @param {object} [params] extra parameters specific to the bybit api endpoint
5136
+ * @param {int} [params.until] the latest time in ms to fetch entries for
5137
+ * @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)
5104
5138
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5105
5139
  */
5106
5140
  await this.loadMarkets();
5107
- const request = {
5141
+ let paginate = false;
5142
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
5143
+ if (paginate) {
5144
+ return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5145
+ }
5146
+ let request = {
5108
5147
  // 'coin': currency['id'],
5109
5148
  // 'limit': 20, // max 50
5110
5149
  // 'cusor': '',
@@ -5120,6 +5159,7 @@ class bybit extends bybit$1 {
5120
5159
  if (limit !== undefined) {
5121
5160
  request['limit'] = limit;
5122
5161
  }
5162
+ [request, params] = this.handleUntilOption('endTime', request, params);
5123
5163
  const response = await this.privateGetV5AssetWithdrawQueryRecord(this.extend(request, params));
5124
5164
  //
5125
5165
  // {
@@ -6385,6 +6425,11 @@ class bybit extends bybit$1 {
6385
6425
  throw new errors.BadRequest(this.id + 'fetchOpenInterestHistory cannot use the 1m timeframe');
6386
6426
  }
6387
6427
  await this.loadMarkets();
6428
+ const paginate = this.safeValue(params, 'paginate');
6429
+ if (paginate) {
6430
+ params = this.omit(params, 'paginate');
6431
+ return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, timeframe, params, 500);
6432
+ }
6388
6433
  const market = this.market(symbol);
6389
6434
  if (market['spot'] || market['option']) {
6390
6435
  throw new errors.BadRequest(this.id + ' fetchOpenInterestHistory() symbol does not support market ' + symbol);
@@ -6597,11 +6642,18 @@ class bybit extends bybit$1 {
6597
6642
  * @param {int} [since] the earliest time in ms to fetch transfers for
6598
6643
  * @param {int} [limit] the maximum number of transfers structures to retrieve
6599
6644
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6645
+ * @param {int} [params.until] the latest time in ms to fetch entries for
6646
+ * @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)
6600
6647
  * @returns {object[]} a list of [transfer structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
6601
6648
  */
6602
6649
  await this.loadMarkets();
6650
+ let paginate = false;
6651
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
6652
+ if (paginate) {
6653
+ return await this.fetchPaginatedCallCursor('fetchTransfers', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
6654
+ }
6603
6655
  let currency = undefined;
6604
- const request = {};
6656
+ let request = {};
6605
6657
  if (code !== undefined) {
6606
6658
  currency = this.safeCurrencyCode(code);
6607
6659
  request['coin'] = currency;
@@ -6612,6 +6664,7 @@ class bybit extends bybit$1 {
6612
6664
  if (limit !== undefined) {
6613
6665
  request['limit'] = limit;
6614
6666
  }
6667
+ [request, params] = this.handleUntilOption('endTime', request, params);
6615
6668
  const response = await this.privateGetV5AssetTransferQueryInterTransferList(this.extend(request, params));
6616
6669
  //
6617
6670
  // {
@@ -2400,9 +2400,16 @@ class coinbase extends coinbase$1 {
2400
2400
  * @param {int} [since] the earliest time in ms to fetch orders
2401
2401
  * @param {int} [limit] the maximum number of order structures to retrieve
2402
2402
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2403
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2404
+ * @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)
2403
2405
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2404
2406
  */
2405
2407
  await this.loadMarkets();
2408
+ let paginate = false;
2409
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
2410
+ if (paginate) {
2411
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2412
+ }
2406
2413
  let market = undefined;
2407
2414
  if (symbol !== undefined) {
2408
2415
  market = this.market(symbol);
@@ -2417,6 +2424,11 @@ class coinbase extends coinbase$1 {
2417
2424
  if (since !== undefined) {
2418
2425
  request['start_date'] = this.iso8601(since);
2419
2426
  }
2427
+ const until = this.safeValueN(params, ['until', 'till']);
2428
+ if (until !== undefined) {
2429
+ params = this.omit(params, ['until', 'till']);
2430
+ request['end_date'] = this.iso8601(until);
2431
+ }
2420
2432
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalBatch(this.extend(request, params));
2421
2433
  //
2422
2434
  // {
@@ -2461,6 +2473,12 @@ class coinbase extends coinbase$1 {
2461
2473
  // }
2462
2474
  //
2463
2475
  const orders = this.safeValue(response, 'orders', []);
2476
+ const first = this.safeValue(orders, 0);
2477
+ const cursor = this.safeString(response, 'cursor');
2478
+ if ((cursor !== undefined) && (cursor !== '')) {
2479
+ first['cursor'] = cursor;
2480
+ orders[0] = first;
2481
+ }
2464
2482
  return this.parseOrders(orders, market, since, limit);
2465
2483
  }
2466
2484
  async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2482,6 +2500,11 @@ class coinbase extends coinbase$1 {
2482
2500
  if (since !== undefined) {
2483
2501
  request['start_date'] = this.iso8601(since);
2484
2502
  }
2503
+ const until = this.safeValueN(params, ['until', 'till']);
2504
+ if (until !== undefined) {
2505
+ params = this.omit(params, ['until', 'till']);
2506
+ request['end_date'] = this.iso8601(until);
2507
+ }
2485
2508
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalBatch(this.extend(request, params));
2486
2509
  //
2487
2510
  // {
@@ -2526,6 +2549,12 @@ class coinbase extends coinbase$1 {
2526
2549
  // }
2527
2550
  //
2528
2551
  const orders = this.safeValue(response, 'orders', []);
2552
+ const first = this.safeValue(orders, 0);
2553
+ const cursor = this.safeString(response, 'cursor');
2554
+ if ((cursor !== undefined) && (cursor !== '')) {
2555
+ first['cursor'] = cursor;
2556
+ orders[0] = first;
2557
+ }
2529
2558
  return this.parseOrders(orders, market, since, limit);
2530
2559
  }
2531
2560
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2538,8 +2567,16 @@ class coinbase extends coinbase$1 {
2538
2567
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2539
2568
  * @param {int} [limit] the maximum number of open order structures to retrieve
2540
2569
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2570
+ * @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)
2571
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2541
2572
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2542
2573
  */
2574
+ await this.loadMarkets();
2575
+ let paginate = false;
2576
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
2577
+ if (paginate) {
2578
+ return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2579
+ }
2543
2580
  return await this.fetchOrdersByStatus('OPEN', symbol, since, limit, params);
2544
2581
  }
2545
2582
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2552,8 +2589,16 @@ class coinbase extends coinbase$1 {
2552
2589
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2553
2590
  * @param {int} [limit] the maximum number of closed order structures to retrieve
2554
2591
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2592
+ * @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)
2593
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2555
2594
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2556
2595
  */
2596
+ await this.loadMarkets();
2597
+ let paginate = false;
2598
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
2599
+ if (paginate) {
2600
+ return await this.fetchPaginatedCallCursor('fetchClosedOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2601
+ }
2557
2602
  return await this.fetchOrdersByStatus('FILLED', symbol, since, limit, params);
2558
2603
  }
2559
2604
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2581,24 +2626,40 @@ class coinbase extends coinbase$1 {
2581
2626
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
2582
2627
  * @param {int} [limit] the maximum amount of candles to fetch, not used by coinbase
2583
2628
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2629
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2630
+ * @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)
2584
2631
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2585
2632
  */
2586
2633
  await this.loadMarkets();
2634
+ let paginate = false;
2635
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
2636
+ if (paginate) {
2637
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 299);
2638
+ }
2587
2639
  const market = this.market(symbol);
2588
- const end = this.seconds().toString();
2589
2640
  const request = {
2590
2641
  'product_id': market['id'],
2591
2642
  'granularity': this.safeString(this.timeframes, timeframe, timeframe),
2592
- 'end': end,
2593
2643
  };
2644
+ const until = this.safeValueN(params, ['until', 'till', 'end']);
2645
+ params = this.omit(params, ['until', 'till']);
2646
+ const duration = this.parseTimeframe(timeframe);
2647
+ const candles300 = 300 * duration;
2648
+ let sinceString = undefined;
2594
2649
  if (since !== undefined) {
2595
- const sinceString = since.toString();
2596
- const timeframeToSeconds = Precise["default"].stringDiv(sinceString, '1000');
2597
- request['start'] = this.decimalToPrecision(timeframeToSeconds, number.TRUNCATE, 0, number.DECIMAL_PLACES);
2650
+ sinceString = this.numberToString(this.parseToInt(since / 1000));
2598
2651
  }
2599
2652
  else {
2600
- request['start'] = Precise["default"].stringSub(end, '18000'); // default to 5h in seconds, max 300 candles
2653
+ const now = this.seconds().toString();
2654
+ sinceString = Precise["default"].stringSub(now, candles300.toString());
2655
+ }
2656
+ request['start'] = sinceString;
2657
+ let endString = this.numberToString(until);
2658
+ if (until === undefined) {
2659
+ // 300 candles max
2660
+ endString = Precise["default"].stringAdd(sinceString, candles300.toString());
2601
2661
  }
2662
+ request['end'] = endString;
2602
2663
  const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
2603
2664
  //
2604
2665
  // {
@@ -2689,9 +2750,16 @@ class coinbase extends coinbase$1 {
2689
2750
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2690
2751
  * @param {int} [limit] the maximum number of trade structures to fetch
2691
2752
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2753
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2754
+ * @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)
2692
2755
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
2693
2756
  */
2694
2757
  await this.loadMarkets();
2758
+ let paginate = false;
2759
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
2760
+ if (paginate) {
2761
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2762
+ }
2695
2763
  let market = undefined;
2696
2764
  if (symbol !== undefined) {
2697
2765
  market = this.market(symbol);
@@ -2706,6 +2774,11 @@ class coinbase extends coinbase$1 {
2706
2774
  if (since !== undefined) {
2707
2775
  request['start_sequence_timestamp'] = this.iso8601(since);
2708
2776
  }
2777
+ const until = this.safeValueN(params, ['until', 'till']);
2778
+ if (until !== undefined) {
2779
+ params = this.omit(params, ['until', 'till']);
2780
+ request['end_sequence_timestamp'] = this.iso8601(until);
2781
+ }
2709
2782
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalFills(this.extend(request, params));
2710
2783
  //
2711
2784
  // {
@@ -2731,6 +2804,12 @@ class coinbase extends coinbase$1 {
2731
2804
  // }
2732
2805
  //
2733
2806
  const trades = this.safeValue(response, 'fills', []);
2807
+ const first = this.safeValue(trades, 0);
2808
+ const cursor = this.safeString(response, 'cursor');
2809
+ if ((cursor !== undefined) && (cursor !== '')) {
2810
+ first['cursor'] = cursor;
2811
+ trades[0] = first;
2812
+ }
2734
2813
  return this.parseTrades(trades, market, since, limit);
2735
2814
  }
2736
2815
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -783,9 +783,15 @@ class coinbasepro extends coinbasepro$1 {
783
783
  * @param {int} [limit] the maximum number of trades structures to retrieve
784
784
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
785
785
  * @param {int} [params.until] the latest time in ms to fetch trades for
786
+ * @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)
786
787
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
787
788
  */
788
789
  this.checkRequiredSymbol('fetchMyTrades', symbol);
790
+ let paginate = false;
791
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
792
+ if (paginate) {
793
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 100);
794
+ }
789
795
  await this.loadMarkets();
790
796
  const market = this.market(symbol);
791
797
  const request = {
@@ -904,9 +910,15 @@ class coinbasepro extends coinbasepro$1 {
904
910
  * @param {int} [limit] the maximum amount of candles to fetch
905
911
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
906
912
  * @param {int} [params.until] the latest time in ms to fetch trades for
913
+ * @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)
907
914
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
908
915
  */
909
916
  await this.loadMarkets();
917
+ let paginate = false;
918
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
919
+ if (paginate) {
920
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 300);
921
+ }
910
922
  const market = this.market(symbol);
911
923
  const parsedTimeframe = this.safeInteger(this.timeframes, timeframe);
912
924
  const request = {
@@ -1133,9 +1145,15 @@ class coinbasepro extends coinbasepro$1 {
1133
1145
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1134
1146
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1135
1147
  * @param {int} [params.until] the latest time in ms to fetch open orders for
1148
+ * @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)
1136
1149
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1137
1150
  */
1138
1151
  await this.loadMarkets();
1152
+ let paginate = false;
1153
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
1154
+ if (paginate) {
1155
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params, 100);
1156
+ }
1139
1157
  const request = {};
1140
1158
  let market = undefined;
1141
1159
  if (symbol !== undefined) {
@@ -887,7 +887,7 @@ class coinex extends coinex$1 {
887
887
  // message: 'OK'
888
888
  // }
889
889
  //
890
- return this.safeNumber(response, 'data');
890
+ return this.safeInteger(response, 'data');
891
891
  }
892
892
  async fetchOrderBook(symbol, limit = 20, params = {}) {
893
893
  /**
@@ -540,7 +540,6 @@ class coinsph extends coinsph$1 {
540
540
  const quoteId = this.safeString(market, 'quoteAsset');
541
541
  const base = this.safeCurrencyCode(baseId);
542
542
  const quote = this.safeCurrencyCode(quoteId);
543
- const isActive = this.safeString(market, 'status') === 'TRADING';
544
543
  const limits = this.indexBy(this.safeValue(market, 'filters'), 'filterType');
545
544
  const amountLimits = this.safeValue(limits, 'LOT_SIZE', {});
546
545
  const priceLimits = this.safeValue(limits, 'PRICE_FILTER', {});
@@ -560,7 +559,7 @@ class coinsph extends coinsph$1 {
560
559
  'swap': false,
561
560
  'future': false,
562
561
  'option': false,
563
- 'active': isActive,
562
+ 'active': this.safeStringLower(market, 'status') === 'trading',
564
563
  'contract': false,
565
564
  'linear': undefined,
566
565
  'inverse': undefined,
@@ -652,9 +652,15 @@ class cryptocom extends cryptocom$1 {
652
652
  * @param {int} [limit] the maximum number of order structures to retrieve, default 100 max 100
653
653
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
654
654
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
655
+ * @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)
655
656
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
656
657
  */
657
658
  await this.loadMarkets();
659
+ let paginate = false;
660
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
661
+ if (paginate) {
662
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
663
+ }
658
664
  let market = undefined;
659
665
  const request = {};
660
666
  if (symbol !== undefined) {
@@ -727,9 +733,15 @@ class cryptocom extends cryptocom$1 {
727
733
  * @param {int} [limit] the maximum number of trades to fetch
728
734
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
729
735
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
736
+ * @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)
730
737
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
731
738
  */
732
739
  await this.loadMarkets();
740
+ let paginate = false;
741
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
742
+ if (paginate) {
743
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
744
+ }
733
745
  const market = this.market(symbol);
734
746
  const request = {
735
747
  'instrument_name': market['id'],
@@ -781,9 +793,15 @@ class cryptocom extends cryptocom$1 {
781
793
  * @param {int} [limit] the maximum amount of candles to fetch
782
794
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
783
795
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
796
+ * @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)
784
797
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
785
798
  */
786
799
  await this.loadMarkets();
800
+ let paginate = false;
801
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
802
+ if (paginate) {
803
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 300);
804
+ }
787
805
  const market = this.market(symbol);
788
806
  const request = {
789
807
  'instrument_name': market['id'],
@@ -1273,9 +1291,15 @@ class cryptocom extends cryptocom$1 {
1273
1291
  * @param {int} [limit] the maximum number of trade structures to retrieve
1274
1292
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
1275
1293
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
1294
+ * @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)
1276
1295
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1277
1296
  */
1278
1297
  await this.loadMarkets();
1298
+ let paginate = false;
1299
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1300
+ if (paginate) {
1301
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1302
+ }
1279
1303
  const request = {};
1280
1304
  let market = undefined;
1281
1305
  if (symbol !== undefined) {
@@ -2762,10 +2786,16 @@ class cryptocom extends cryptocom$1 {
2762
2786
  * @param {int} [limit] the maximum amount of [funding rate structures] to fetch
2763
2787
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
2764
2788
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
2789
+ * @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)
2765
2790
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2766
2791
  */
2767
2792
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
2768
2793
  await this.loadMarkets();
2794
+ let paginate = false;
2795
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2796
+ if (paginate) {
2797
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2798
+ }
2769
2799
  const market = this.market(symbol);
2770
2800
  if (!market['swap']) {
2771
2801
  throw new errors.BadSymbol(this.id + ' fetchFundingRateHistory() supports swap contracts only');