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/binance.js CHANGED
@@ -3324,9 +3324,15 @@ export default class binance extends Exchange {
3324
3324
  * @param {object} [params] extra parameters specific to the binance api endpoint
3325
3325
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
3326
3326
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
3327
+ * @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)
3327
3328
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
3328
3329
  */
3329
3330
  await this.loadMarkets();
3331
+ let paginate = false;
3332
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
3333
+ if (paginate) {
3334
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
3335
+ }
3330
3336
  const market = this.market(symbol);
3331
3337
  // binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets
3332
3338
  // the reality is that the time range wider than 500 candles won't work right
@@ -3661,12 +3667,18 @@ export default class binance extends Exchange {
3661
3667
  * @param {object} [params] extra parameters specific to the binance api endpoint
3662
3668
  * @param {int} [params.until] only used when fetchTradesMethod is 'publicGetAggTrades', 'fapiPublicGetAggTrades', or 'dapiPublicGetAggTrades'
3663
3669
  * @param {int} [params.fetchTradesMethod] 'publicGetAggTrades' (spot default), 'fapiPublicGetAggTrades' (swap default), 'dapiPublicGetAggTrades' (future default), 'eapiPublicGetTrades' (option default), 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', 'publicGetHistoricalTrades', 'fapiPublicGetHistoricalTrades', 'dapiPublicGetHistoricalTrades', 'eapiPublicGetHistoricalTrades'
3670
+ * @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)
3664
3671
  *
3665
3672
  * EXCHANGE SPECIFIC PARAMETERS
3666
3673
  * @param {int} [params.fromId] trade id to fetch from, default gets most recent trades, not used when fetchTradesMethod is 'publicGetTrades', 'fapiPublicGetTrades', 'dapiPublicGetTrades', or 'eapiPublicGetTrades'
3667
3674
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
3668
3675
  */
3669
3676
  await this.loadMarkets();
3677
+ let paginate = false;
3678
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
3679
+ if (paginate) {
3680
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params);
3681
+ }
3670
3682
  const market = this.market(symbol);
3671
3683
  const request = {
3672
3684
  'symbol': market['id'],
@@ -4698,10 +4710,17 @@ export default class binance extends Exchange {
4698
4710
  * @param {int} [limit] the maximum number of order structures to retrieve
4699
4711
  * @param {object} [params] extra parameters specific to the binance api endpoint
4700
4712
  * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
4713
+ * @param {int} [params.until] the latest time in ms to fetch orders for
4714
+ * @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)
4701
4715
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4702
4716
  */
4703
4717
  this.checkRequiredSymbol('fetchOrders', symbol);
4704
4718
  await this.loadMarkets();
4719
+ let paginate = false;
4720
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
4721
+ if (paginate) {
4722
+ return await this.fetchPaginatedCallDynamic('fetchOrders', symbol, since, limit, params);
4723
+ }
4705
4724
  const market = this.market(symbol);
4706
4725
  const defaultType = this.safeString2(this.options, 'fetchOrders', 'defaultType', 'spot');
4707
4726
  const type = this.safeString(params, 'type', defaultType);
@@ -4725,6 +4744,11 @@ export default class binance extends Exchange {
4725
4744
  request['isIsolated'] = true;
4726
4745
  }
4727
4746
  }
4747
+ const until = this.safeInteger(params, 'until');
4748
+ if (until !== undefined) {
4749
+ params = this.omit(params, 'until');
4750
+ request['endTime'] = until;
4751
+ }
4728
4752
  if (since !== undefined) {
4729
4753
  request['startTime'] = since;
4730
4754
  }
@@ -4812,6 +4836,10 @@ export default class binance extends Exchange {
4812
4836
  /**
4813
4837
  * @method
4814
4838
  * @name binance#fetchOpenOrders
4839
+ * @see https://binance-docs.github.io/apidocs/spot/en/#cancel-an-existing-order-and-send-a-new-order-trade
4840
+ * @see https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data
4841
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#current-all-open-orders-user_data
4842
+ * @see https://binance-docs.github.io/apidocs/voptions/en/#query-current-open-option-orders-user_data
4815
4843
  * @description fetch all unfilled currently open orders
4816
4844
  * @see https://binance-docs.github.io/apidocs/spot/en/#current-open-orders-user_data
4817
4845
  * @see https://binance-docs.github.io/apidocs/futures/en/#current-all-open-orders-user_data
@@ -4894,6 +4922,7 @@ export default class binance extends Exchange {
4894
4922
  * @param {int} [since] the earliest time in ms to fetch orders for
4895
4923
  * @param {int} [limit] the maximum number of order structures to retrieve
4896
4924
  * @param {object} [params] extra parameters specific to the binance api endpoint
4925
+ * @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)
4897
4926
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4898
4927
  */
4899
4928
  const orders = await this.fetchOrders(symbol, since, limit, params);
@@ -4911,6 +4940,7 @@ export default class binance extends Exchange {
4911
4940
  * @param {int} [since] the earliest time in ms to fetch orders for
4912
4941
  * @param {int} [limit] the maximum number of order structures to retrieve
4913
4942
  * @param {object} [params] extra parameters specific to the binance api endpoint
4943
+ * @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)
4914
4944
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4915
4945
  */
4916
4946
  this.checkRequiredSymbol('fetchCanceledOrders', symbol);
@@ -5144,9 +5174,16 @@ export default class binance extends Exchange {
5144
5174
  * @param {int} [since] the earliest time in ms to fetch trades for
5145
5175
  * @param {int} [limit] the maximum number of trades structures to retrieve
5146
5176
  * @param {object} [params] extra parameters specific to the binance api endpoint
5177
+ * @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)
5178
+ * @param {int} [params.until] the latest time in ms to fetch entries for
5147
5179
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
5148
5180
  */
5149
5181
  await this.loadMarkets();
5182
+ let paginate = false;
5183
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
5184
+ if (paginate) {
5185
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
5186
+ }
5150
5187
  const request = {};
5151
5188
  let market = undefined;
5152
5189
  let type = undefined;
@@ -5417,6 +5454,7 @@ export default class binance extends Exchange {
5417
5454
  /**
5418
5455
  * @method
5419
5456
  * @name binance#fetchDeposits
5457
+ * @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5420
5458
  * @description fetch all deposits made to an account
5421
5459
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5422
5460
  * @see https://binance-docs.github.io/apidocs/spot/en/#deposit-history-supporting-network-user_data
@@ -5425,10 +5463,16 @@ export default class binance extends Exchange {
5425
5463
  * @param {int} [limit] the maximum number of deposits structures to retrieve
5426
5464
  * @param {object} [params] extra parameters specific to the binance api endpoint
5427
5465
  * @param {bool} [params.fiat] if true, only fiat deposits will be returned
5428
- * @param {int} [params.until] the latest time in ms to fetch deposits for
5466
+ * @param {int} [params.until] the latest time in ms to fetch entries for
5467
+ * @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)
5429
5468
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5430
5469
  */
5431
5470
  await this.loadMarkets();
5471
+ let paginate = false;
5472
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
5473
+ if (paginate) {
5474
+ return await this.fetchPaginatedCallDynamic('fetchDeposits', code, since, limit, params);
5475
+ }
5432
5476
  let currency = undefined;
5433
5477
  let response = undefined;
5434
5478
  const request = {};
@@ -5436,6 +5480,7 @@ export default class binance extends Exchange {
5436
5480
  const fiatOnly = this.safeValue(params, 'fiat', false);
5437
5481
  params = this.omit(params, 'fiatOnly');
5438
5482
  const until = this.safeInteger(params, 'until');
5483
+ params = this.omit(params, 'until');
5439
5484
  if (fiatOnly || (code in legalMoney)) {
5440
5485
  if (code !== undefined) {
5441
5486
  currency = this.currency(code);
@@ -5523,6 +5568,8 @@ export default class binance extends Exchange {
5523
5568
  /**
5524
5569
  * @method
5525
5570
  * @name binance#fetchWithdrawals
5571
+ * @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5572
+ * @see https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
5526
5573
  * @description fetch all withdrawals made from an account
5527
5574
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-fiat-deposit-withdraw-history-user_data
5528
5575
  * @see https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
@@ -5531,13 +5578,25 @@ export default class binance extends Exchange {
5531
5578
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
5532
5579
  * @param {object} [params] extra parameters specific to the binance api endpoint
5533
5580
  * @param {bool} [params.fiat] if true, only fiat withdrawals will be returned
5581
+ * @param {int} [params.until] the latest time in ms to fetch withdrawals for
5582
+ * @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)
5534
5583
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
5535
5584
  */
5536
5585
  await this.loadMarkets();
5586
+ let paginate = false;
5587
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
5588
+ if (paginate) {
5589
+ return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
5590
+ }
5537
5591
  const legalMoney = this.safeValue(this.options, 'legalMoney', {});
5538
5592
  const fiatOnly = this.safeValue(params, 'fiat', false);
5539
5593
  params = this.omit(params, 'fiatOnly');
5540
5594
  const request = {};
5595
+ const until = this.safeInteger(params, 'until');
5596
+ if (until !== undefined) {
5597
+ params = this.omit(params, 'until');
5598
+ request['endTime'] = until;
5599
+ }
5541
5600
  let response = undefined;
5542
5601
  let currency = undefined;
5543
5602
  if (fiatOnly || (code in legalMoney)) {
@@ -5989,15 +6048,23 @@ export default class binance extends Exchange {
5989
6048
  /**
5990
6049
  * @method
5991
6050
  * @name binance#fetchTransfers
6051
+ * @see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data
5992
6052
  * @description fetch a history of internal transfers made on an account
5993
6053
  * @see https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
5994
6054
  * @param {string} code unified currency code of the currency transferred
5995
6055
  * @param {int} [since] the earliest time in ms to fetch transfers for
5996
6056
  * @param {int} [limit] the maximum number of transfers structures to retrieve
5997
6057
  * @param {object} [params] extra parameters specific to the binance api endpoint
6058
+ * @param {int} [params.until] the latest time in ms to fetch transfers for
6059
+ * @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)
5998
6060
  * @returns {object[]} a list of [transfer structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
5999
6061
  */
6000
6062
  await this.loadMarkets();
6063
+ let paginate = false;
6064
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
6065
+ if (paginate) {
6066
+ return await this.fetchPaginatedCallDynamic('fetchTransfers', code, since, limit, params);
6067
+ }
6001
6068
  let currency = undefined;
6002
6069
  if (code !== undefined) {
6003
6070
  currency = this.currency(code);
@@ -6030,6 +6097,11 @@ export default class binance extends Exchange {
6030
6097
  if (limit !== undefined) {
6031
6098
  request['size'] = limit;
6032
6099
  }
6100
+ const until = this.safeInteger(params, 'until');
6101
+ if (until !== undefined) {
6102
+ params = this.omit(params, 'until');
6103
+ request['endTime'] = until;
6104
+ }
6033
6105
  const response = await this.sapiGetAssetTransfer(this.extend(request, params));
6034
6106
  //
6035
6107
  // {
@@ -6714,11 +6786,17 @@ export default class binance extends Exchange {
6714
6786
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
6715
6787
  * @param {object} [params] extra parameters specific to the binance api endpoint
6716
6788
  * @param {int} [params.until] timestamp in ms of the latest funding rate
6789
+ * @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)
6717
6790
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
6718
6791
  */
6719
6792
  await this.loadMarkets();
6720
6793
  const request = {};
6721
6794
  let method = undefined;
6795
+ let paginate = false;
6796
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
6797
+ if (paginate) {
6798
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
6799
+ }
6722
6800
  const defaultType = this.safeString2(this.options, 'fetchFundingRateHistory', 'defaultType', 'future');
6723
6801
  const type = this.safeString(params, 'type', defaultType);
6724
6802
  let market = undefined;
@@ -8122,9 +8200,16 @@ export default class binance extends Exchange {
8122
8200
  * @param {int} [since] timestamp in ms of the earliest ledger entry
8123
8201
  * @param {int} [limit] max number of ledger entrys to return
8124
8202
  * @param {object} [params] extra parameters specific to the binance api endpoint
8203
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
8204
+ * @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)
8125
8205
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
8126
8206
  */
8127
8207
  await this.loadMarkets();
8208
+ let paginate = false;
8209
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
8210
+ if (paginate) {
8211
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
8212
+ }
8128
8213
  let type = undefined;
8129
8214
  let subType = undefined;
8130
8215
  let currency = undefined;
@@ -8153,6 +8238,11 @@ export default class binance extends Exchange {
8153
8238
  if (limit !== undefined) {
8154
8239
  request['limit'] = limit;
8155
8240
  }
8241
+ const until = this.safeInteger(params, 'until');
8242
+ if (until !== undefined) {
8243
+ params = this.omit(params, 'until');
8244
+ request['endTime'] = until;
8245
+ }
8156
8246
  const response = await this[method](this.extend(request, params));
8157
8247
  //
8158
8248
  // options (eapi)
@@ -8942,6 +9032,11 @@ export default class binance extends Exchange {
8942
9032
  throw new BadRequest(this.id + 'fetchOpenInterestHistory cannot use the 1m timeframe');
8943
9033
  }
8944
9034
  await this.loadMarkets();
9035
+ let paginate = false;
9036
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenInterestHistory', 'paginate', false);
9037
+ if (paginate) {
9038
+ return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, timeframe, params, 500);
9039
+ }
8945
9040
  const market = this.market(symbol);
8946
9041
  const request = {
8947
9042
  'period': this.safeString(this.timeframes, timeframe, timeframe),
package/js/src/bingx.d.ts CHANGED
@@ -59,7 +59,7 @@ export default class bingx extends Exchange {
59
59
  info: any;
60
60
  };
61
61
  fetchMarkets(params?: {}): Promise<any>;
62
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
62
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
63
63
  parseOHLCV(ohlcv: any, market?: any): number[];
64
64
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
65
65
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
package/js/src/bingx.js CHANGED
@@ -298,6 +298,7 @@ export default class bingx extends Exchange {
298
298
  '100001': AuthenticationError,
299
299
  '100412': AuthenticationError,
300
300
  '100202': InsufficientFunds,
301
+ '100204': BadRequest,
301
302
  '100400': BadRequest,
302
303
  '100440': ExchangeError,
303
304
  '100500': ExchangeError,
@@ -628,9 +629,15 @@ export default class bingx extends Exchange {
628
629
  * @param {object} [params] extra parameters specific to the bingx api endpoint
629
630
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
630
631
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
632
+ * @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)
631
633
  * @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
632
634
  */
633
635
  await this.loadMarkets();
636
+ let paginate = false;
637
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
638
+ if (paginate) {
639
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1440);
640
+ }
634
641
  const market = this.market(symbol);
635
642
  const request = {
636
643
  'symbol': market['id'],
@@ -645,6 +652,11 @@ export default class bingx extends Exchange {
645
652
  else {
646
653
  request['limit'] = 50;
647
654
  }
655
+ const until = this.safeInteger2(params, 'until', 'startTime');
656
+ if (until !== undefined) {
657
+ params = this.omit(params, ['until']);
658
+ request['startTime'] = until;
659
+ }
648
660
  let response = undefined;
649
661
  if (market['spot']) {
650
662
  response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
@@ -1024,10 +1036,17 @@ export default class bingx extends Exchange {
1024
1036
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
1025
1037
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
1026
1038
  * @param {object} [params] extra parameters specific to the bingx api endpoint
1039
+ * @param {int} [params.until] timestamp in ms of the latest funding rate to fetch
1040
+ * @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)
1027
1041
  * @returns {[object]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
1028
1042
  */
1029
1043
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
1030
1044
  await this.loadMarkets();
1045
+ let paginate = false;
1046
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
1047
+ if (paginate) {
1048
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
1049
+ }
1031
1050
  const market = this.market(symbol);
1032
1051
  const request = {
1033
1052
  'symbol': market['id'],
@@ -1038,6 +1057,11 @@ export default class bingx extends Exchange {
1038
1057
  if (limit !== undefined) {
1039
1058
  request['limit'] = limit;
1040
1059
  }
1060
+ const until = this.safeInteger2(params, 'until', 'startTime');
1061
+ if (until !== undefined) {
1062
+ params = this.omit(params, ['until']);
1063
+ request['startTime'] = until;
1064
+ }
1041
1065
  const response = await this.swapV2PublicGetQuoteFundingRate(this.extend(request, params));
1042
1066
  //
1043
1067
  // {
@@ -51,8 +51,8 @@ export default class bitfinex2 extends Exchange {
51
51
  fetchTickers(symbols?: string[], params?: {}): Promise<any>;
52
52
  fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
53
53
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
54
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
55
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: number, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
54
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
55
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: number, params?: {}): Promise<any>;
56
56
  parseOHLCV(ohlcv: any, market?: any): number[];
57
57
  parseOrderStatus(status: any): any;
58
58
  parseOrderFlags(flags: any): any;
@@ -64,7 +64,7 @@ export default class bitfinex2 extends Exchange {
64
64
  fetchOpenOrder(id: string, symbol?: string, params?: {}): Promise<any>;
65
65
  fetchClosedOrder(id: string, symbol?: string, params?: {}): Promise<any>;
66
66
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
67
- fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
67
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
68
68
  fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
69
69
  fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
70
70
  createDepositAddress(code: string, params?: {}): Promise<{
@@ -5,7 +5,7 @@
5
5
  // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
- import { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported, PermissionDenied, ExchangeNotAvailable } from './base/errors.js';
8
+ import { ExchangeError, InvalidAddress, ArgumentsRequired, InsufficientFunds, AuthenticationError, OrderNotFound, InvalidOrder, BadRequest, InvalidNonce, BadSymbol, OnMaintenance, NotSupported, PermissionDenied, ExchangeNotAvailable, RateLimitExceeded } from './base/errors.js';
9
9
  import { Precise } from './base/Precise.js';
10
10
  import Exchange from './abstract/bitfinex2.js';
11
11
  import { SIGNIFICANT_DIGITS, DECIMAL_PLACES, TRUNCATE, ROUND } from './base/functions/number.js';
@@ -343,6 +343,7 @@ export default class bitfinex2 extends Exchange {
343
343
  },
344
344
  'exceptions': {
345
345
  'exact': {
346
+ '11010': RateLimitExceeded,
346
347
  '10001': PermissionDenied,
347
348
  '10020': BadRequest,
348
349
  '10100': AuthenticationError,
@@ -1268,17 +1269,24 @@ export default class bitfinex2 extends Exchange {
1268
1269
  * @method
1269
1270
  * @name bitfinex2#fetchTrades
1270
1271
  * @description get the list of most recent trades for a particular symbol
1271
- * @see https://docs.bitfinex.com/reference/rest-public-tickers-history
1272
+ * @see https://docs.bitfinex.com/reference/rest-public-trades
1272
1273
  * @param {string} symbol unified symbol of the market to fetch trades for
1273
1274
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1274
1275
  * @param {int} [limit] the maximum amount of trades to fetch
1275
1276
  * @param {object} [params] extra parameters specific to the bitfinex2 api endpoint
1277
+ * @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)
1278
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1276
1279
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
1277
1280
  */
1278
1281
  await this.loadMarkets();
1282
+ let paginate = false;
1283
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
1284
+ if (paginate) {
1285
+ return await this.fetchPaginatedCallDynamic('fetchTrades', symbol, since, limit, params, 10000);
1286
+ }
1279
1287
  const market = this.market(symbol);
1280
1288
  let sort = '-1';
1281
- const request = {
1289
+ let request = {
1282
1290
  'symbol': market['id'],
1283
1291
  };
1284
1292
  if (since !== undefined) {
@@ -1289,6 +1297,7 @@ export default class bitfinex2 extends Exchange {
1289
1297
  request['limit'] = Math.min(limit, 10000); // default 120, max 10000
1290
1298
  }
1291
1299
  request['sort'] = sort;
1300
+ [request, params] = this.handleUntilOption('end', request, params);
1292
1301
  const response = await this.publicGetTradesSymbolHist(this.extend(request, params));
1293
1302
  //
1294
1303
  // [
@@ -1315,23 +1324,27 @@ export default class bitfinex2 extends Exchange {
1315
1324
  * @param {int} [limit] the maximum amount of candles to fetch
1316
1325
  * @param {object} [params] extra parameters specific to the bitfinex2 api endpoint
1317
1326
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1327
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
1328
+ * @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)
1318
1329
  */
1319
1330
  await this.loadMarkets();
1331
+ let paginate = false;
1332
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
1333
+ if (paginate) {
1334
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 10000);
1335
+ }
1320
1336
  const market = this.market(symbol);
1321
1337
  if (limit === undefined) {
1322
- limit = 100; // default 100, max 5000
1323
- }
1324
- if (since === undefined) {
1325
- const duration = this.parseTimeframe(timeframe);
1326
- since = this.milliseconds() - duration * limit * 1000;
1338
+ limit = 10000; // default 100, max 5000
1327
1339
  }
1328
- const request = {
1340
+ let request = {
1329
1341
  'symbol': market['id'],
1330
1342
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
1331
1343
  'sort': 1,
1332
1344
  'start': since,
1333
1345
  'limit': limit,
1334
1346
  };
1347
+ [request, params] = this.handleUntilOption('end', request, params);
1335
1348
  const response = await this.publicGetCandlesTradeTimeframeSymbolHist(this.extend(request, params));
1336
1349
  //
1337
1350
  // [
@@ -1805,17 +1818,25 @@ export default class bitfinex2 extends Exchange {
1805
1818
  * @param {int} [since] the earliest time in ms to fetch orders for
1806
1819
  * @param {int} [limit] the maximum number of orde structures to retrieve
1807
1820
  * @param {object} [params] extra parameters specific to the bitfinex2 api endpoint
1821
+ * @param {int} [params.until] the latest time in ms to fetch entries for
1822
+ * @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)
1808
1823
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1809
1824
  */
1810
1825
  // returns the most recent closed or canceled orders up to circa two weeks ago
1811
1826
  await this.loadMarkets();
1812
- const request = {};
1827
+ let paginate = false;
1828
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
1829
+ if (paginate) {
1830
+ return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
1831
+ }
1832
+ let request = {};
1813
1833
  if (since !== undefined) {
1814
1834
  request['start'] = since;
1815
1835
  }
1816
1836
  if (limit !== undefined) {
1817
1837
  request['limit'] = limit; // default 25, max 2500
1818
1838
  }
1839
+ [request, params] = this.handleUntilOption('end', request, params);
1819
1840
  let market = undefined;
1820
1841
  let response = undefined;
1821
1842
  if (symbol === undefined) {
@@ -2576,6 +2597,7 @@ export default class bitfinex2 extends Exchange {
2576
2597
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2577
2598
  }
2578
2599
  handleErrors(statusCode, statusText, url, method, headers, body, response, requestHeaders, requestBody) {
2600
+ // ['error', 11010, 'ratelimit: error']
2579
2601
  if (response !== undefined) {
2580
2602
  if (!Array.isArray(response)) {
2581
2603
  const message = this.safeString2(response, 'message', 'error');
@@ -2588,6 +2610,9 @@ export default class bitfinex2 extends Exchange {
2588
2610
  else if (response === '') {
2589
2611
  throw new ExchangeError(this.id + ' returned empty response');
2590
2612
  }
2613
+ if (statusCode === 429) {
2614
+ throw new RateLimitExceeded(this.id + ' ' + body);
2615
+ }
2591
2616
  if (statusCode === 500) {
2592
2617
  // See https://docs.bitfinex.com/docs/abbreviations-glossary#section-errorinfo-codes
2593
2618
  const errorCode = this.safeString(response, 1, '');
@@ -2683,18 +2708,26 @@ export default class bitfinex2 extends Exchange {
2683
2708
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
2684
2709
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
2685
2710
  * @param {object} [params] extra parameters specific to the bitfinex2 api endpoint
2711
+ * @param {int} [params.until] timestamp in ms of the latest ledger entry
2712
+ * @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)
2686
2713
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
2687
2714
  */
2688
2715
  await this.loadMarkets();
2689
2716
  await this.loadMarkets();
2717
+ let paginate = false;
2718
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
2719
+ if (paginate) {
2720
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params, 2500);
2721
+ }
2690
2722
  let currency = undefined;
2691
- const request = {};
2723
+ let request = {};
2692
2724
  if (since !== undefined) {
2693
2725
  request['start'] = since;
2694
2726
  }
2695
2727
  if (limit !== undefined) {
2696
2728
  request['limit'] = limit; // max 2500
2697
2729
  }
2730
+ [request, params] = this.handleUntilOption('end', request, params);
2698
2731
  let response = undefined;
2699
2732
  if (code !== undefined) {
2700
2733
  currency = this.currency(code);
@@ -2792,14 +2825,25 @@ export default class bitfinex2 extends Exchange {
2792
2825
  * @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
2793
2826
  * @param {string} symbol unified market symbol
2794
2827
  * @param {object} [params] extra parameters specific to the bingx api endpoint
2828
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
2829
+ * @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)
2795
2830
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
2796
2831
  */
2797
2832
  await this.loadMarkets();
2798
2833
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
2834
+ let paginate = false;
2835
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2836
+ if (paginate) {
2837
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 5000);
2838
+ }
2799
2839
  const market = this.market(symbol);
2800
- const request = {
2840
+ let request = {
2801
2841
  'symbol': market['id'],
2802
2842
  };
2843
+ if (since !== undefined) {
2844
+ request['start'] = since;
2845
+ }
2846
+ [request, params] = this.handleUntilOption('end', request, params);
2803
2847
  const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
2804
2848
  //
2805
2849
  // [
@@ -128,7 +128,7 @@ export default class bitget extends Exchange {
128
128
  fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
129
129
  fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
130
130
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade;
131
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
131
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
132
132
  fetchTradingFee(symbol: string, params?: {}): Promise<{
133
133
  info: any;
134
134
  symbol: any;
@@ -143,7 +143,7 @@ export default class bitget extends Exchange {
143
143
  taker: number;
144
144
  };
145
145
  parseOHLCV(ohlcv: any, market?: any): number[];
146
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
146
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
147
147
  fetchBalance(params?: {}): Promise<import("./base/types.js").Balances>;
148
148
  parseBalance(balance: any): import("./base/types.js").Balances;
149
149
  parseOrderStatus(status: any): string;
@@ -154,10 +154,11 @@ export default class bitget extends Exchange {
154
154
  cancelOrders(ids: any, symbol?: string, params?: {}): Promise<any>;
155
155
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
156
156
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
157
- fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
158
- fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
159
- fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
157
+ fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
158
+ fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
159
+ fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
160
160
  fetchCanceledAndClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
161
+ addPaginationCursorToResult(response: any, data: any): any;
161
162
  fetchLedger(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
162
163
  parseLedgerEntry(item: any, currency?: any): {
163
164
  info: any;
@@ -176,7 +177,7 @@ export default class bitget extends Exchange {
176
177
  status: any;
177
178
  fee: number;
178
179
  };
179
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
180
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
180
181
  fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
181
182
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
182
183
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;