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
package/js/src/bybit.js CHANGED
@@ -2389,10 +2389,16 @@ export default class bybit extends Exchange {
2389
2389
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
2390
2390
  * @param {int} [limit] the maximum amount of candles to fetch
2391
2391
  * @param {object} [params] extra parameters specific to the bybit api endpoint
2392
+ * @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)
2392
2393
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2393
2394
  */
2394
2395
  this.checkRequiredSymbol('fetchOHLCV', symbol);
2395
2396
  await this.loadMarkets();
2397
+ let paginate = false;
2398
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
2399
+ if (paginate) {
2400
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
2401
+ }
2396
2402
  const market = this.market(symbol);
2397
2403
  const request = {
2398
2404
  'symbol': market['id'],
@@ -2627,6 +2633,7 @@ export default class bybit extends Exchange {
2627
2633
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
2628
2634
  * @param {object} [params] extra parameters specific to the bybit api endpoint
2629
2635
  * @param {int} [params.until] timestamp in ms of the latest funding rate
2636
+ * @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)
2630
2637
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2631
2638
  */
2632
2639
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
@@ -2634,6 +2641,11 @@ export default class bybit extends Exchange {
2634
2641
  if (limit === undefined) {
2635
2642
  limit = 200;
2636
2643
  }
2644
+ let paginate = false;
2645
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2646
+ if (paginate) {
2647
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 200);
2648
+ }
2637
2649
  const request = {
2638
2650
  // 'category': '', // Product type. linear,inverse
2639
2651
  // 'symbol': '', // Symbol name
@@ -4453,9 +4465,16 @@ export default class bybit extends Exchange {
4453
4465
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4454
4466
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4455
4467
  * @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
4468
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4469
+ * @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)
4456
4470
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4457
4471
  */
4458
4472
  await this.loadMarkets();
4473
+ let paginate = false;
4474
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
4475
+ if (paginate) {
4476
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4477
+ }
4459
4478
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4460
4479
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4461
4480
  const request = {};
@@ -4827,9 +4846,15 @@ export default class bybit extends Exchange {
4827
4846
  * @param {boolean} [params.stop] true if stop order
4828
4847
  * @param {string} [params.type] market type, ['swap', 'option', 'spot']
4829
4848
  * @param {string} [params.subType] market subType, ['linear', 'inverse']
4849
+ * @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)
4830
4850
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
4831
4851
  */
4832
4852
  await this.loadMarkets();
4853
+ let paginate = false;
4854
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
4855
+ if (paginate) {
4856
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 100);
4857
+ }
4833
4858
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4834
4859
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
4835
4860
  const request = {};
@@ -5043,11 +5068,17 @@ export default class bybit extends Exchange {
5043
5068
  * @param {int} [params.until] the latest time in ms to fetch deposits for, default = 30 days after since
5044
5069
  *
5045
5070
  * EXCHANGE SPECIFIC PARAMETERS
5071
+ * @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)
5046
5072
  * @param {string} [params.cursor] used for pagination
5047
5073
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5048
5074
  */
5049
5075
  await this.loadMarkets();
5050
- const request = {
5076
+ let paginate = false;
5077
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
5078
+ if (paginate) {
5079
+ return await this.fetchPaginatedCallCursor('fetchDeposits', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5080
+ }
5081
+ let request = {
5051
5082
  // 'coin': currency['id'],
5052
5083
  // 'limit': 20, // max 50
5053
5084
  // 'cursor': '',
@@ -5063,6 +5094,7 @@ export default class bybit extends Exchange {
5063
5094
  if (limit !== undefined) {
5064
5095
  request['limit'] = limit;
5065
5096
  }
5097
+ [request, params] = this.handleUntilOption('endTime', request, params);
5066
5098
  const response = await this.privateGetV5AssetDepositQueryRecord(this.extend(request, params));
5067
5099
  //
5068
5100
  // {
@@ -5104,10 +5136,17 @@ export default class bybit extends Exchange {
5104
5136
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
5105
5137
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
5106
5138
  * @param {object} [params] extra parameters specific to the bybit api endpoint
5139
+ * @param {int} [params.until] the latest time in ms to fetch entries for
5140
+ * @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)
5107
5141
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5108
5142
  */
5109
5143
  await this.loadMarkets();
5110
- const request = {
5144
+ let paginate = false;
5145
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
5146
+ if (paginate) {
5147
+ return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5148
+ }
5149
+ let request = {
5111
5150
  // 'coin': currency['id'],
5112
5151
  // 'limit': 20, // max 50
5113
5152
  // 'cusor': '',
@@ -5123,6 +5162,7 @@ export default class bybit extends Exchange {
5123
5162
  if (limit !== undefined) {
5124
5163
  request['limit'] = limit;
5125
5164
  }
5165
+ [request, params] = this.handleUntilOption('endTime', request, params);
5126
5166
  const response = await this.privateGetV5AssetWithdrawQueryRecord(this.extend(request, params));
5127
5167
  //
5128
5168
  // {
@@ -6388,6 +6428,11 @@ export default class bybit extends Exchange {
6388
6428
  throw new BadRequest(this.id + 'fetchOpenInterestHistory cannot use the 1m timeframe');
6389
6429
  }
6390
6430
  await this.loadMarkets();
6431
+ const paginate = this.safeValue(params, 'paginate');
6432
+ if (paginate) {
6433
+ params = this.omit(params, 'paginate');
6434
+ return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, timeframe, params, 500);
6435
+ }
6391
6436
  const market = this.market(symbol);
6392
6437
  if (market['spot'] || market['option']) {
6393
6438
  throw new BadRequest(this.id + ' fetchOpenInterestHistory() symbol does not support market ' + symbol);
@@ -6603,11 +6648,18 @@ export default class bybit extends Exchange {
6603
6648
  * @param {int} [since] the earliest time in ms to fetch transfers for
6604
6649
  * @param {int} [limit] the maximum number of transfers structures to retrieve
6605
6650
  * @param {object} [params] extra parameters specific to the bybit api endpoint
6651
+ * @param {int} [params.until] the latest time in ms to fetch entries for
6652
+ * @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)
6606
6653
  * @returns {object[]} a list of [transfer structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
6607
6654
  */
6608
6655
  await this.loadMarkets();
6656
+ let paginate = false;
6657
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
6658
+ if (paginate) {
6659
+ return await this.fetchPaginatedCallCursor('fetchTransfers', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
6660
+ }
6609
6661
  let currency = undefined;
6610
- const request = {};
6662
+ let request = {};
6611
6663
  if (code !== undefined) {
6612
6664
  currency = this.safeCurrencyCode(code);
6613
6665
  request['coin'] = currency;
@@ -6618,6 +6670,7 @@ export default class bybit extends Exchange {
6618
6670
  if (limit !== undefined) {
6619
6671
  request['limit'] = limit;
6620
6672
  }
6673
+ [request, params] = this.handleUntilOption('endTime', request, params);
6621
6674
  const response = await this.privateGetV5AssetTransferQueryInterTransferList(this.extend(request, params));
6622
6675
  //
6623
6676
  // {
@@ -101,15 +101,15 @@ export default class coinbase extends Exchange {
101
101
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<any>;
102
102
  cancelOrders(ids: any, symbol?: string, params?: {}): Promise<import("./base/types.js").Order[]>;
103
103
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
104
- fetchOrders(symbol?: string, since?: Int, limit?: number, params?: {}): Promise<import("./base/types.js").Order[]>;
104
+ fetchOrders(symbol?: string, since?: Int, limit?: number, params?: {}): Promise<any>;
105
105
  fetchOrdersByStatus(status: any, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
106
- fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
107
- fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
106
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
107
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
108
108
  fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
109
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
109
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
110
110
  parseOHLCV(ohlcv: any, market?: any): number[];
111
111
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
112
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
112
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
113
113
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<import("./base/types.js").OrderBook>;
114
114
  fetchBidsAsks(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
115
115
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
@@ -8,7 +8,7 @@
8
8
  import Exchange from './abstract/coinbase.js';
9
9
  import { ExchangeError, ArgumentsRequired, AuthenticationError, BadRequest, InvalidOrder, NotSupported, OrderNotFound, RateLimitExceeded, InvalidNonce } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
- import { TICK_SIZE, TRUNCATE, DECIMAL_PLACES } from './base/functions/number.js';
11
+ import { TICK_SIZE } from './base/functions/number.js';
12
12
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
13
  // ----------------------------------------------------------------------------
14
14
  /**
@@ -2403,9 +2403,16 @@ export default class coinbase extends Exchange {
2403
2403
  * @param {int} [since] the earliest time in ms to fetch orders
2404
2404
  * @param {int} [limit] the maximum number of order structures to retrieve
2405
2405
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2406
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2407
+ * @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)
2406
2408
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2407
2409
  */
2408
2410
  await this.loadMarkets();
2411
+ let paginate = false;
2412
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
2413
+ if (paginate) {
2414
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2415
+ }
2409
2416
  let market = undefined;
2410
2417
  if (symbol !== undefined) {
2411
2418
  market = this.market(symbol);
@@ -2420,6 +2427,11 @@ export default class coinbase extends Exchange {
2420
2427
  if (since !== undefined) {
2421
2428
  request['start_date'] = this.iso8601(since);
2422
2429
  }
2430
+ const until = this.safeValueN(params, ['until', 'till']);
2431
+ if (until !== undefined) {
2432
+ params = this.omit(params, ['until', 'till']);
2433
+ request['end_date'] = this.iso8601(until);
2434
+ }
2423
2435
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalBatch(this.extend(request, params));
2424
2436
  //
2425
2437
  // {
@@ -2464,6 +2476,12 @@ export default class coinbase extends Exchange {
2464
2476
  // }
2465
2477
  //
2466
2478
  const orders = this.safeValue(response, 'orders', []);
2479
+ const first = this.safeValue(orders, 0);
2480
+ const cursor = this.safeString(response, 'cursor');
2481
+ if ((cursor !== undefined) && (cursor !== '')) {
2482
+ first['cursor'] = cursor;
2483
+ orders[0] = first;
2484
+ }
2467
2485
  return this.parseOrders(orders, market, since, limit);
2468
2486
  }
2469
2487
  async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2485,6 +2503,11 @@ export default class coinbase extends Exchange {
2485
2503
  if (since !== undefined) {
2486
2504
  request['start_date'] = this.iso8601(since);
2487
2505
  }
2506
+ const until = this.safeValueN(params, ['until', 'till']);
2507
+ if (until !== undefined) {
2508
+ params = this.omit(params, ['until', 'till']);
2509
+ request['end_date'] = this.iso8601(until);
2510
+ }
2488
2511
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalBatch(this.extend(request, params));
2489
2512
  //
2490
2513
  // {
@@ -2529,6 +2552,12 @@ export default class coinbase extends Exchange {
2529
2552
  // }
2530
2553
  //
2531
2554
  const orders = this.safeValue(response, 'orders', []);
2555
+ const first = this.safeValue(orders, 0);
2556
+ const cursor = this.safeString(response, 'cursor');
2557
+ if ((cursor !== undefined) && (cursor !== '')) {
2558
+ first['cursor'] = cursor;
2559
+ orders[0] = first;
2560
+ }
2532
2561
  return this.parseOrders(orders, market, since, limit);
2533
2562
  }
2534
2563
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2541,8 +2570,16 @@ export default class coinbase extends Exchange {
2541
2570
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2542
2571
  * @param {int} [limit] the maximum number of open order structures to retrieve
2543
2572
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2573
+ * @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)
2574
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2544
2575
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2545
2576
  */
2577
+ await this.loadMarkets();
2578
+ let paginate = false;
2579
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
2580
+ if (paginate) {
2581
+ return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2582
+ }
2546
2583
  return await this.fetchOrdersByStatus('OPEN', symbol, since, limit, params);
2547
2584
  }
2548
2585
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2555,8 +2592,16 @@ export default class coinbase extends Exchange {
2555
2592
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2556
2593
  * @param {int} [limit] the maximum number of closed order structures to retrieve
2557
2594
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2595
+ * @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)
2596
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2558
2597
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2559
2598
  */
2599
+ await this.loadMarkets();
2600
+ let paginate = false;
2601
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
2602
+ if (paginate) {
2603
+ return await this.fetchPaginatedCallCursor('fetchClosedOrders', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2604
+ }
2560
2605
  return await this.fetchOrdersByStatus('FILLED', symbol, since, limit, params);
2561
2606
  }
2562
2607
  async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2584,24 +2629,40 @@ export default class coinbase extends Exchange {
2584
2629
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
2585
2630
  * @param {int} [limit] the maximum amount of candles to fetch, not used by coinbase
2586
2631
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2632
+ * @param {int} [params.until] the latest time in ms to fetch trades for
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)
2587
2634
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2588
2635
  */
2589
2636
  await this.loadMarkets();
2637
+ let paginate = false;
2638
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
2639
+ if (paginate) {
2640
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 299);
2641
+ }
2590
2642
  const market = this.market(symbol);
2591
- const end = this.seconds().toString();
2592
2643
  const request = {
2593
2644
  'product_id': market['id'],
2594
2645
  'granularity': this.safeString(this.timeframes, timeframe, timeframe),
2595
- 'end': end,
2596
2646
  };
2647
+ const until = this.safeValueN(params, ['until', 'till', 'end']);
2648
+ params = this.omit(params, ['until', 'till']);
2649
+ const duration = this.parseTimeframe(timeframe);
2650
+ const candles300 = 300 * duration;
2651
+ let sinceString = undefined;
2597
2652
  if (since !== undefined) {
2598
- const sinceString = since.toString();
2599
- const timeframeToSeconds = Precise.stringDiv(sinceString, '1000');
2600
- request['start'] = this.decimalToPrecision(timeframeToSeconds, TRUNCATE, 0, DECIMAL_PLACES);
2653
+ sinceString = this.numberToString(this.parseToInt(since / 1000));
2601
2654
  }
2602
2655
  else {
2603
- request['start'] = Precise.stringSub(end, '18000'); // default to 5h in seconds, max 300 candles
2656
+ const now = this.seconds().toString();
2657
+ sinceString = Precise.stringSub(now, candles300.toString());
2658
+ }
2659
+ request['start'] = sinceString;
2660
+ let endString = this.numberToString(until);
2661
+ if (until === undefined) {
2662
+ // 300 candles max
2663
+ endString = Precise.stringAdd(sinceString, candles300.toString());
2604
2664
  }
2665
+ request['end'] = endString;
2605
2666
  const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
2606
2667
  //
2607
2668
  // {
@@ -2692,9 +2753,16 @@ export default class coinbase extends Exchange {
2692
2753
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
2693
2754
  * @param {int} [limit] the maximum number of trade structures to fetch
2694
2755
  * @param {object} [params] extra parameters specific to the coinbase api endpoint
2756
+ * @param {int} [params.until] the latest time in ms to fetch trades for
2757
+ * @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)
2695
2758
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
2696
2759
  */
2697
2760
  await this.loadMarkets();
2761
+ let paginate = false;
2762
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
2763
+ if (paginate) {
2764
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'cursor', 'cursor', undefined, 100);
2765
+ }
2698
2766
  let market = undefined;
2699
2767
  if (symbol !== undefined) {
2700
2768
  market = this.market(symbol);
@@ -2709,6 +2777,11 @@ export default class coinbase extends Exchange {
2709
2777
  if (since !== undefined) {
2710
2778
  request['start_sequence_timestamp'] = this.iso8601(since);
2711
2779
  }
2780
+ const until = this.safeValueN(params, ['until', 'till']);
2781
+ if (until !== undefined) {
2782
+ params = this.omit(params, ['until', 'till']);
2783
+ request['end_sequence_timestamp'] = this.iso8601(until);
2784
+ }
2712
2785
  const response = await this.v3PrivateGetBrokerageOrdersHistoricalFills(this.extend(request, params));
2713
2786
  //
2714
2787
  // {
@@ -2734,6 +2807,12 @@ export default class coinbase extends Exchange {
2734
2807
  // }
2735
2808
  //
2736
2809
  const trades = this.safeValue(response, 'fills', []);
2810
+ const first = this.safeValue(trades, 0);
2811
+ const cursor = this.safeString(response, 'cursor');
2812
+ if ((cursor !== undefined) && (cursor !== '')) {
2813
+ first['cursor'] = cursor;
2814
+ trades[0] = first;
2815
+ }
2737
2816
  return this.parseTrades(trades, market, since, limit);
2738
2817
  }
2739
2818
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -22,19 +22,19 @@ export default class coinbasepro extends Exchange {
22
22
  fetchTickers(symbols?: string[], params?: {}): Promise<any>;
23
23
  fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
24
24
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
25
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
25
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
26
26
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
27
27
  fetchTradingFees(params?: {}): Promise<{}>;
28
28
  parseOHLCV(ohlcv: any, market?: any): number[];
29
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
29
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
30
30
  fetchTime(params?: {}): Promise<number>;
31
31
  parseOrderStatus(status: any): string;
32
32
  parseOrder(order: any, market?: any): import("./base/types.js").Order;
33
33
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
34
34
  fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
35
- fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
36
- fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
37
- fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
35
+ fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
36
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
37
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
38
38
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
39
39
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<any>;
40
40
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
@@ -786,9 +786,15 @@ export default class coinbasepro extends Exchange {
786
786
  * @param {int} [limit] the maximum number of trades structures to retrieve
787
787
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
788
788
  * @param {int} [params.until] the latest time in ms to fetch trades for
789
+ * @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)
789
790
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
790
791
  */
791
792
  this.checkRequiredSymbol('fetchMyTrades', symbol);
793
+ let paginate = false;
794
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
795
+ if (paginate) {
796
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params, 100);
797
+ }
792
798
  await this.loadMarkets();
793
799
  const market = this.market(symbol);
794
800
  const request = {
@@ -907,9 +913,15 @@ export default class coinbasepro extends Exchange {
907
913
  * @param {int} [limit] the maximum amount of candles to fetch
908
914
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
909
915
  * @param {int} [params.until] the latest time in ms to fetch trades for
916
+ * @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)
910
917
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
911
918
  */
912
919
  await this.loadMarkets();
920
+ let paginate = false;
921
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
922
+ if (paginate) {
923
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 300);
924
+ }
913
925
  const market = this.market(symbol);
914
926
  const parsedTimeframe = this.safeInteger(this.timeframes, timeframe);
915
927
  const request = {
@@ -1136,9 +1148,15 @@ export default class coinbasepro extends Exchange {
1136
1148
  * @param {int} [limit] the maximum number of open orders structures to retrieve
1137
1149
  * @param {object} [params] extra parameters specific to the coinbasepro api endpoint
1138
1150
  * @param {int} [params.until] the latest time in ms to fetch open orders for
1151
+ * @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)
1139
1152
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1140
1153
  */
1141
1154
  await this.loadMarkets();
1155
+ let paginate = false;
1156
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
1157
+ if (paginate) {
1158
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params, 100);
1159
+ }
1142
1160
  const request = {};
1143
1161
  let market = undefined;
1144
1162
  if (symbol !== undefined) {
package/js/src/coinex.js CHANGED
@@ -890,7 +890,7 @@ export default class coinex extends Exchange {
890
890
  // message: 'OK'
891
891
  // }
892
892
  //
893
- return this.safeNumber(response, 'data');
893
+ return this.safeInteger(response, 'data');
894
894
  }
895
895
  async fetchOrderBook(symbol, limit = 20, params = {}) {
896
896
  /**
package/js/src/coinsph.js CHANGED
@@ -543,7 +543,6 @@ export default class coinsph extends Exchange {
543
543
  const quoteId = this.safeString(market, 'quoteAsset');
544
544
  const base = this.safeCurrencyCode(baseId);
545
545
  const quote = this.safeCurrencyCode(quoteId);
546
- const isActive = this.safeString(market, 'status') === 'TRADING';
547
546
  const limits = this.indexBy(this.safeValue(market, 'filters'), 'filterType');
548
547
  const amountLimits = this.safeValue(limits, 'LOT_SIZE', {});
549
548
  const priceLimits = this.safeValue(limits, 'PRICE_FILTER', {});
@@ -563,7 +562,7 @@ export default class coinsph extends Exchange {
563
562
  'swap': false,
564
563
  'future': false,
565
564
  'option': false,
566
- 'active': isActive,
565
+ 'active': this.safeStringLower(market, 'status') === 'trading',
567
566
  'contract': false,
568
567
  'linear': undefined,
569
568
  'inverse': undefined,
@@ -9,9 +9,9 @@ export default class cryptocom extends Exchange {
9
9
  fetchMarkets(params?: {}): Promise<any[]>;
10
10
  fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
11
11
  fetchTicker(symbol: string, params?: {}): Promise<any>;
12
- fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
13
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
14
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
12
+ fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
13
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
14
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
15
15
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<import("./base/types.js").OrderBook>;
16
16
  parseBalance(response: any): import("./base/types.js").Balances;
17
17
  fetchBalance(params?: {}): Promise<import("./base/types.js").Balances>;
@@ -21,7 +21,7 @@ export default class cryptocom extends Exchange {
21
21
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
22
22
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
23
23
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
24
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
24
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
25
25
  parseAddress(addressString: any): any[];
26
26
  withdraw(code: string, amount: any, address: any, tag?: any, params?: {}): Promise<{
27
27
  info: any;
@@ -655,9 +655,15 @@ export default class cryptocom extends Exchange {
655
655
  * @param {int} [limit] the maximum number of order structures to retrieve, default 100 max 100
656
656
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
657
657
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
658
+ * @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)
658
659
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
659
660
  */
660
661
  await this.loadMarkets();
662
+ let paginate = false;
663
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
664
+ if (paginate) {
665
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
666
+ }
661
667
  let market = undefined;
662
668
  const request = {};
663
669
  if (symbol !== undefined) {
@@ -730,9 +736,15 @@ export default class cryptocom extends Exchange {
730
736
  * @param {int} [limit] the maximum number of trades to fetch
731
737
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
732
738
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
739
+ * @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)
733
740
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
734
741
  */
735
742
  await this.loadMarkets();
743
+ let paginate = false;
744
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
745
+ if (paginate) {
746
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
747
+ }
736
748
  const market = this.market(symbol);
737
749
  const request = {
738
750
  'instrument_name': market['id'],
@@ -784,9 +796,15 @@ export default class cryptocom extends Exchange {
784
796
  * @param {int} [limit] the maximum amount of candles to fetch
785
797
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
786
798
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
799
+ * @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)
787
800
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
788
801
  */
789
802
  await this.loadMarkets();
803
+ let paginate = false;
804
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
805
+ if (paginate) {
806
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 300);
807
+ }
790
808
  const market = this.market(symbol);
791
809
  const request = {
792
810
  'instrument_name': market['id'],
@@ -1276,9 +1294,15 @@ export default class cryptocom extends Exchange {
1276
1294
  * @param {int} [limit] the maximum number of trade structures to retrieve
1277
1295
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
1278
1296
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
1297
+ * @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)
1279
1298
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1280
1299
  */
1281
1300
  await this.loadMarkets();
1301
+ let paginate = false;
1302
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
1303
+ if (paginate) {
1304
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
1305
+ }
1282
1306
  const request = {};
1283
1307
  let market = undefined;
1284
1308
  if (symbol !== undefined) {
@@ -2765,10 +2789,16 @@ export default class cryptocom extends Exchange {
2765
2789
  * @param {int} [limit] the maximum amount of [funding rate structures] to fetch
2766
2790
  * @param {object} [params] extra parameters specific to the cryptocom api endpoint
2767
2791
  * @param {int} [params.until] timestamp in ms for the ending date filter, default is the current time
2792
+ * @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)
2768
2793
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2769
2794
  */
2770
2795
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
2771
2796
  await this.loadMarkets();
2797
+ let paginate = false;
2798
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2799
+ if (paginate) {
2800
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2801
+ }
2772
2802
  const market = this.market(symbol);
2773
2803
  if (!market['swap']) {
2774
2804
  throw new BadSymbol(this.id + ' fetchFundingRateHistory() supports swap contracts only');
package/js/src/gate.d.ts CHANGED
@@ -210,13 +210,13 @@ export default class gate extends Exchange {
210
210
  fetchBalance(params?: {}): Promise<{
211
211
  info: any;
212
212
  }>;
213
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
213
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
214
214
  fetchOptionOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
215
215
  fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
216
216
  parseOHLCV(ohlcv: any, market?: any): number[];
217
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
218
- fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
219
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
217
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
218
+ fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
219
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
220
220
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
221
221
  fetchDeposits(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
222
222
  fetchWithdrawals(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;