ccxt 4.1.5 → 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 (61) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1106 -55
  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/cryptocom.js +30 -0
  15. package/dist/cjs/src/gate.js +56 -3
  16. package/dist/cjs/src/huobi.js +69 -4
  17. package/dist/cjs/src/kraken.js +17 -3
  18. package/dist/cjs/src/krakenfutures.js +24 -0
  19. package/dist/cjs/src/kucoin.js +59 -4
  20. package/dist/cjs/src/kucoinfutures.js +35 -1
  21. package/dist/cjs/src/okx.js +66 -4
  22. package/dist/cjs/src/poloniex.js +18 -2
  23. package/js/ccxt.d.ts +1 -1
  24. package/js/ccxt.js +1 -1
  25. package/js/src/base/Exchange.d.ts +7 -0
  26. package/js/src/base/Exchange.js +216 -0
  27. package/js/src/binance.d.ts +5 -5
  28. package/js/src/binance.js +96 -1
  29. package/js/src/bingx.d.ts +1 -1
  30. package/js/src/bingx.js +24 -0
  31. package/js/src/bitfinex2.d.ts +3 -3
  32. package/js/src/bitfinex2.js +56 -12
  33. package/js/src/bitget.d.ts +7 -6
  34. package/js/src/bitget.js +132 -12
  35. package/js/src/bitmex.d.ts +6 -6
  36. package/js/src/bitmex.js +49 -0
  37. package/js/src/bybit.d.ts +6 -6
  38. package/js/src/bybit.js +56 -3
  39. package/js/src/coinbase.d.ts +5 -5
  40. package/js/src/coinbase.js +86 -7
  41. package/js/src/coinbasepro.d.ts +5 -5
  42. package/js/src/coinbasepro.js +18 -0
  43. package/js/src/cryptocom.d.ts +4 -4
  44. package/js/src/cryptocom.js +30 -0
  45. package/js/src/gate.d.ts +4 -4
  46. package/js/src/gate.js +56 -3
  47. package/js/src/huobi.d.ts +2 -2
  48. package/js/src/huobi.js +69 -4
  49. package/js/src/kraken.d.ts +1 -1
  50. package/js/src/kraken.js +17 -3
  51. package/js/src/krakenfutures.d.ts +2 -2
  52. package/js/src/krakenfutures.js +24 -0
  53. package/js/src/kucoin.d.ts +5 -5
  54. package/js/src/kucoin.js +59 -4
  55. package/js/src/kucoinfutures.d.ts +4 -4
  56. package/js/src/kucoinfutures.js +35 -1
  57. package/js/src/okx.d.ts +6 -6
  58. package/js/src/okx.js +66 -4
  59. package/js/src/poloniex.d.ts +1 -1
  60. package/js/src/poloniex.js +18 -2
  61. package/package.json +1 -1
@@ -1940,9 +1940,15 @@ class okx extends okx$1 {
1940
1940
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1941
1941
  * @param {int} [limit] the maximum amount of trades to fetch
1942
1942
  * @param {object} [params] extra parameters specific to the okx api endpoint
1943
+ * @param {boolean} [params.paginate] *only applies to publicGetMarketHistoryTrades* default false, when true will automatically paginate by calling this endpoint multiple times
1943
1944
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
1944
1945
  */
1945
1946
  await this.loadMarkets();
1947
+ let paginate = false;
1948
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchTrades', 'paginate');
1949
+ if (paginate) {
1950
+ return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'tradeId', 'after', undefined, 100);
1951
+ }
1946
1952
  const market = this.market(symbol);
1947
1953
  const request = {
1948
1954
  'instId': market['id'],
@@ -2045,10 +2051,16 @@ class okx extends okx$1 {
2045
2051
  * @param {object} [params] extra parameters specific to the okx api endpoint
2046
2052
  * @param {string} [params.price] "mark" or "index" for mark price and index price candles
2047
2053
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
2054
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2048
2055
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
2049
2056
  */
2050
2057
  await this.loadMarkets();
2051
2058
  const market = this.market(symbol);
2059
+ let paginate = false;
2060
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
2061
+ if (paginate) {
2062
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 200);
2063
+ }
2052
2064
  const price = this.safeString(params, 'price');
2053
2065
  params = this.omit(params, 'price');
2054
2066
  const options = this.safeValue(this.options, 'fetchOHLCV', {});
@@ -2139,12 +2151,18 @@ class okx extends okx$1 {
2139
2151
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
2140
2152
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
2141
2153
  * @param {object} [params] extra parameters specific to the okx api endpoint
2154
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2142
2155
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
2143
2156
  */
2144
2157
  if (symbol === undefined) {
2145
2158
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
2146
2159
  }
2147
2160
  await this.loadMarkets();
2161
+ let paginate = false;
2162
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
2163
+ if (paginate) {
2164
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
2165
+ }
2148
2166
  const market = this.market(symbol);
2149
2167
  const request = {
2150
2168
  'instId': market['id'],
@@ -3377,9 +3395,15 @@ class okx extends okx$1 {
3377
3395
  * @param {bool} [params.stop] True if fetching trigger or conditional orders
3378
3396
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3379
3397
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
3398
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3380
3399
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3381
3400
  */
3382
3401
  await this.loadMarkets();
3402
+ let paginate = false;
3403
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
3404
+ if (paginate) {
3405
+ return await this.fetchPaginatedCallDynamic('fetchOpenOrders', symbol, since, limit, params);
3406
+ }
3383
3407
  const request = {
3384
3408
  // 'instType': 'SPOT', // SPOT, MARGIN, SWAP, FUTURES, OPTION
3385
3409
  // 'uly': currency['id'],
@@ -3703,9 +3727,15 @@ class okx extends okx$1 {
3703
3727
  * @param {string} [params.ordType] "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3704
3728
  * @param {string} [params.algoId] Algo ID "'433845797218942976'"
3705
3729
  * @param {int} [params.until] timestamp in ms to fetch orders for
3730
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3706
3731
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3707
3732
  */
3708
3733
  await this.loadMarkets();
3734
+ let paginate = false;
3735
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchClosedOrders', 'paginate');
3736
+ if (paginate) {
3737
+ return await this.fetchPaginatedCallDynamic('fetchClosedOrders', symbol, since, limit, params);
3738
+ }
3709
3739
  const request = {
3710
3740
  // 'instType': type.toUpperCase (), // SPOT, MARGIN, SWAP, FUTURES, OPTION
3711
3741
  // 'uly': currency['id'],
@@ -3865,10 +3895,17 @@ class okx extends okx$1 {
3865
3895
  * @param {int} [since] the earliest time in ms to fetch trades for
3866
3896
  * @param {int} [limit] the maximum number of trades structures to retrieve
3867
3897
  * @param {object} [params] extra parameters specific to the okx api endpoint
3898
+ * @param {int} [params.until] Timestamp in ms of the latest time to retrieve trades for
3899
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3868
3900
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
3869
3901
  */
3870
3902
  await this.loadMarkets();
3871
- const request = {
3903
+ let paginate = false;
3904
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
3905
+ if (paginate) {
3906
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
3907
+ }
3908
+ let request = {
3872
3909
  // 'instType': 'SPOT', // SPOT, MARGIN, SWAP, FUTURES, OPTION
3873
3910
  // 'uly': currency['id'],
3874
3911
  // 'instId': market['id'],
@@ -3882,6 +3919,7 @@ class okx extends okx$1 {
3882
3919
  market = this.market(symbol);
3883
3920
  request['instId'] = market['id'];
3884
3921
  }
3922
+ [request, params] = this.handleUntilOption('end', params, request);
3885
3923
  const [type, query] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
3886
3924
  request['instType'] = this.convertToInstrumentType(type);
3887
3925
  if (limit !== undefined) {
@@ -3951,14 +3989,21 @@ class okx extends okx$1 {
3951
3989
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
3952
3990
  * @param {object} [params] extra parameters specific to the okx api endpoint
3953
3991
  * @param {string} [params.marginMode] 'cross' or 'isolated'
3992
+ * @param {int} [params.until] the latest time in ms to fetch entries for
3993
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3954
3994
  * @returns {object} a [ledger structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ledger-structure}
3955
3995
  */
3956
3996
  await this.loadMarkets();
3997
+ let paginate = false;
3998
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
3999
+ if (paginate) {
4000
+ return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
4001
+ }
3957
4002
  const options = this.safeValue(this.options, 'fetchLedger', {});
3958
4003
  let method = this.safeString(options, 'method');
3959
4004
  method = this.safeString(params, 'method', method);
3960
4005
  params = this.omit(params, 'method');
3961
- const request = {
4006
+ let request = {
3962
4007
  // 'instType': undefined, // 'SPOT', 'MARGIN', 'SWAP', 'FUTURES", 'OPTION'
3963
4008
  // 'ccy': undefined, // currency['id'],
3964
4009
  // 'mgnMode': undefined, // 'isolated', 'cross'
@@ -3993,6 +4038,7 @@ class okx extends okx$1 {
3993
4038
  currency = this.currency(code);
3994
4039
  request['ccy'] = currency['id'];
3995
4040
  }
4041
+ [request, params] = this.handleUntilOption('end', params, request);
3996
4042
  const response = await this[method](this.extend(request, query));
3997
4043
  //
3998
4044
  // privateGetAccountBills, privateGetAccountBillsArchive
@@ -4407,10 +4453,17 @@ class okx extends okx$1 {
4407
4453
  * @param {int} [since] the earliest time in ms to fetch deposits for
4408
4454
  * @param {int} [limit] the maximum number of deposits structures to retrieve
4409
4455
  * @param {object} [params] extra parameters specific to the okx api endpoint
4456
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4457
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4410
4458
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
4411
4459
  */
4412
4460
  await this.loadMarkets();
4413
- const request = {
4461
+ let paginate = false;
4462
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
4463
+ if (paginate) {
4464
+ return await this.fetchPaginatedCallDynamic('fetchDeposits', code, since, limit, params);
4465
+ }
4466
+ let request = {
4414
4467
  // 'ccy': currency['id'],
4415
4468
  // 'state': 2, // 0 waiting for confirmation, 1 deposit credited, 2 deposit successful
4416
4469
  // 'after': since,
@@ -4428,6 +4481,7 @@ class okx extends okx$1 {
4428
4481
  if (limit !== undefined) {
4429
4482
  request['limit'] = limit; // default 100, max 100
4430
4483
  }
4484
+ [request, params] = this.handleUntilOption('after', params, request);
4431
4485
  const response = await this.privateGetAssetDepositHistory(this.extend(request, params));
4432
4486
  //
4433
4487
  // {
@@ -4505,10 +4559,17 @@ class okx extends okx$1 {
4505
4559
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
4506
4560
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
4507
4561
  * @param {object} [params] extra parameters specific to the okx api endpoint
4562
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4563
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters] (ttps://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
4508
4564
  * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
4509
4565
  */
4510
4566
  await this.loadMarkets();
4511
- const request = {
4567
+ let paginate = false;
4568
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
4569
+ if (paginate) {
4570
+ return await this.fetchPaginatedCallDynamic('fetchWithdrawals', code, since, limit, params);
4571
+ }
4572
+ let request = {
4512
4573
  // 'ccy': currency['id'],
4513
4574
  // 'state': 2, // -3: pending cancel, -2 canceled, -1 failed, 0, pending, 1 sending, 2 sent, 3 awaiting email verification, 4 awaiting manual verification, 5 awaiting identity verification
4514
4575
  // 'after': since,
@@ -4526,6 +4587,7 @@ class okx extends okx$1 {
4526
4587
  if (limit !== undefined) {
4527
4588
  request['limit'] = limit; // default 100, max 100
4528
4589
  }
4590
+ [request, params] = this.handleUntilOption('after', request, params);
4529
4591
  const response = await this.privateGetAssetWithdrawalHistory(this.extend(request, params));
4530
4592
  //
4531
4593
  // {
@@ -397,11 +397,18 @@ class poloniex extends poloniex$1 {
397
397
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
398
398
  * @param {int} [limit] the maximum amount of candles to fetch
399
399
  * @param {object} [params] extra parameters specific to the poloniex api endpoint
400
+ * @param {int} [params.until] timestamp in ms
401
+ * @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)
400
402
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
401
403
  */
402
404
  await this.loadMarkets();
405
+ let paginate = false;
406
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
407
+ if (paginate) {
408
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 500);
409
+ }
403
410
  const market = this.market(symbol);
404
- const request = {
411
+ let request = {
405
412
  'symbol': market['id'],
406
413
  'interval': this.safeString(this.timeframes, timeframe, timeframe),
407
414
  };
@@ -412,6 +419,7 @@ class poloniex extends poloniex$1 {
412
419
  // limit should in between 100 and 500
413
420
  request['limit'] = limit;
414
421
  }
422
+ [request, params] = this.handleUntilOption('endTime', request, params);
415
423
  const response = await this.publicGetMarketsSymbolCandles(this.extend(request, params));
416
424
  //
417
425
  // [
@@ -951,14 +959,21 @@ class poloniex extends poloniex$1 {
951
959
  * @param {int} [since] the earliest time in ms to fetch trades for
952
960
  * @param {int} [limit] the maximum number of trades structures to retrieve
953
961
  * @param {object} [params] extra parameters specific to the poloniex api endpoint
962
+ * @param {int} [params.until] the latest time in ms to fetch entries for
963
+ * @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)
954
964
  * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
955
965
  */
956
966
  await this.loadMarkets();
967
+ let paginate = false;
968
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
969
+ if (paginate) {
970
+ return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
971
+ }
957
972
  let market = undefined;
958
973
  if (symbol !== undefined) {
959
974
  market = this.market(symbol);
960
975
  }
961
- const request = {
976
+ let request = {
962
977
  // 'from': 12345678, // A 'trade Id'. The query begins at ‘from'.
963
978
  // 'direction': 'PRE', // PRE, NEXT The direction before or after ‘from'.
964
979
  };
@@ -968,6 +983,7 @@ class poloniex extends poloniex$1 {
968
983
  if (limit !== undefined) {
969
984
  request['limit'] = limit;
970
985
  }
986
+ [request, params] = this.handleUntilOption('endTime', request, params);
971
987
  const response = await this.privateGetTrades(this.extend(request, params));
972
988
  //
973
989
  // [
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.4";
7
+ declare const version = "4.1.5";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.5';
41
+ const version = '4.1.6';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -805,5 +805,12 @@ export default class Exchange {
805
805
  resolvePromiseIfMessagehashMatches(client: any, prefix: string, symbol: string, data: any): void;
806
806
  resolveMultipleOHLCV(client: any, prefix: string, symbol: string, timeframe: string, data: any): void;
807
807
  createOHLCVObject(symbol: string, timeframe: string, data: any): Dictionary<Dictionary<OHLCV[]>>;
808
+ handleMaxEntriesPerRequestAndParams(method: string, maxEntriesPerRequest?: Int, params?: {}): [Int, any];
809
+ fetchPaginatedCallDynamic(method: string, symbol?: string, since?: Int, limit?: Int, params?: {}, maxEntriesPerRequest?: Int): Promise<any>;
810
+ safeDeterministicCall(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}): Promise<any>;
811
+ fetchPaginatedCallDeterministic(method: string, symbol?: string, since?: Int, limit?: Int, timeframe?: string, params?: {}, maxEntriesPerRequest?: any): Promise<any>;
812
+ fetchPaginatedCallCursor(method: string, symbol?: string, since?: any, limit?: any, params?: {}, cursorReceived?: any, cursorSent?: any, cursorIncrement?: any, maxEntriesPerRequest?: any): Promise<any>;
813
+ removeRepeatedElementsFromArray(input: any): any;
814
+ handleUntilOption(key: any, request: any, params: any, multiplier?: number): any[];
808
815
  }
809
816
  export { Exchange, };
@@ -4094,5 +4094,221 @@ export default class Exchange {
4094
4094
  res[symbol][timeframe] = data;
4095
4095
  return res;
4096
4096
  }
4097
+ handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest = undefined, params = {}) {
4098
+ let newMaxEntriesPerRequest = undefined;
4099
+ [newMaxEntriesPerRequest, params] = this.handleOptionAndParams(params, method, 'maxEntriesPerRequest');
4100
+ if ((newMaxEntriesPerRequest !== undefined) && (newMaxEntriesPerRequest !== maxEntriesPerRequest)) {
4101
+ maxEntriesPerRequest = newMaxEntriesPerRequest;
4102
+ }
4103
+ if (maxEntriesPerRequest === undefined) {
4104
+ maxEntriesPerRequest = 1000; // default to 1000
4105
+ }
4106
+ return [maxEntriesPerRequest, params];
4107
+ }
4108
+ async fetchPaginatedCallDynamic(method, symbol = undefined, since = undefined, limit = undefined, params = {}, maxEntriesPerRequest = undefined) {
4109
+ let maxCalls = undefined;
4110
+ [maxCalls, params] = this.handleOptionAndParams(params, method, 'paginationCalls', 10);
4111
+ let maxRetries = undefined;
4112
+ [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
4113
+ let paginationDirection = undefined;
4114
+ [paginationDirection, params] = this.handleOptionAndParams(params, method, 'paginationDirection', 'backward');
4115
+ let paginationTimestamp = undefined;
4116
+ let calls = 0;
4117
+ let result = [];
4118
+ let errors = 0;
4119
+ const until = this.safeInteger2(params, 'untill', 'till'); // do not omit it from params here
4120
+ [maxEntriesPerRequest, params] = this.handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest, params);
4121
+ if ((paginationDirection === 'forward')) {
4122
+ if (since === undefined) {
4123
+ throw new ArgumentsRequired(this.id + ' pagination requires a since argument when paginationDirection set to forward');
4124
+ }
4125
+ paginationTimestamp = since;
4126
+ }
4127
+ while ((calls < maxCalls)) {
4128
+ calls += 1;
4129
+ try {
4130
+ if (paginationDirection === 'backward') {
4131
+ // do it backwards, starting from the last
4132
+ // UNTIL filtering is required in order to work
4133
+ if (paginationTimestamp !== undefined) {
4134
+ params['until'] = paginationTimestamp - 1;
4135
+ }
4136
+ const response = await this[method](symbol, undefined, maxEntriesPerRequest, params);
4137
+ const responseLength = response.length;
4138
+ if (this.verbose) {
4139
+ this.log('Dynamic pagination call', calls, 'method', method, 'response length', responseLength, 'timestamp', paginationTimestamp);
4140
+ }
4141
+ if (responseLength === 0) {
4142
+ break;
4143
+ }
4144
+ errors = 0;
4145
+ result = this.arrayConcat(result, response);
4146
+ const firstElement = this.safeValue(response, 0);
4147
+ paginationTimestamp = this.safeInteger2(firstElement, 'timestamp', 0);
4148
+ if ((since !== undefined) && (paginationTimestamp <= since)) {
4149
+ break;
4150
+ }
4151
+ }
4152
+ else {
4153
+ // do it forwards, starting from the since
4154
+ const response = await this[method](symbol, paginationTimestamp, maxEntriesPerRequest, params);
4155
+ const responseLength = response.length;
4156
+ if (this.verbose) {
4157
+ this.log('Dynamic pagination call', calls, 'method', method, 'response length', responseLength, 'timestamp', paginationTimestamp);
4158
+ }
4159
+ if (responseLength === 0) {
4160
+ break;
4161
+ }
4162
+ errors = 0;
4163
+ result = this.arrayConcat(result, response);
4164
+ const last = this.safeValue(response, responseLength - 1);
4165
+ paginationTimestamp = this.safeInteger(last, 'timestamp') - 1;
4166
+ if ((until !== undefined) && (paginationTimestamp >= until)) {
4167
+ break;
4168
+ }
4169
+ }
4170
+ }
4171
+ catch (e) {
4172
+ errors += 1;
4173
+ if (errors > maxRetries) {
4174
+ throw e;
4175
+ }
4176
+ }
4177
+ }
4178
+ return this.removeRepeatedElementsFromArray(result);
4179
+ }
4180
+ async safeDeterministicCall(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}) {
4181
+ let maxRetries = undefined;
4182
+ [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
4183
+ let errors = 0;
4184
+ try {
4185
+ if (timeframe && method !== 'fetchFundingRateHistory') {
4186
+ return await this[method](symbol, timeframe, since, limit, params);
4187
+ }
4188
+ else {
4189
+ return await this[method](symbol, since, limit, params);
4190
+ }
4191
+ }
4192
+ catch (e) {
4193
+ if (e instanceof RateLimitExceeded) {
4194
+ throw e; // if we are rate limited, we should not retry and fail fast
4195
+ }
4196
+ errors += 1;
4197
+ if (errors > maxRetries) {
4198
+ throw e;
4199
+ }
4200
+ }
4201
+ }
4202
+ async fetchPaginatedCallDeterministic(method, symbol = undefined, since = undefined, limit = undefined, timeframe = undefined, params = {}, maxEntriesPerRequest = undefined) {
4203
+ let maxCalls = undefined;
4204
+ [maxCalls, params] = this.handleOptionAndParams(params, method, 'paginationCalls', 10);
4205
+ [maxEntriesPerRequest, params] = this.handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest, params);
4206
+ const current = this.milliseconds();
4207
+ const tasks = [];
4208
+ const time = this.parseTimeframe(timeframe) * 1000;
4209
+ const step = time * maxEntriesPerRequest;
4210
+ let currentSince = current - (maxCalls * step) - 1;
4211
+ if (since !== undefined) {
4212
+ currentSince = Math.max(currentSince, since);
4213
+ }
4214
+ const until = this.safeInteger2(params, 'until', 'till'); // do not omit it here
4215
+ if (until !== undefined) {
4216
+ const requiredCalls = Math.ceil((until - since) / step);
4217
+ if (requiredCalls > maxCalls) {
4218
+ throw new BadRequest(this.id + ' the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ' + maxCalls.toString() + ' required calls is ' + requiredCalls.toString());
4219
+ }
4220
+ }
4221
+ for (let i = 0; i < maxCalls; i++) {
4222
+ if ((until !== undefined) && (currentSince >= until)) {
4223
+ break;
4224
+ }
4225
+ tasks.push(this.safeDeterministicCall(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params));
4226
+ currentSince = this.sum(currentSince, step) - 1;
4227
+ }
4228
+ const results = await Promise.all(tasks);
4229
+ let result = [];
4230
+ for (let i = 0; i < results.length; i++) {
4231
+ result = this.arrayConcat(result, results[i]);
4232
+ }
4233
+ return this.removeRepeatedElementsFromArray(result);
4234
+ }
4235
+ async fetchPaginatedCallCursor(method, symbol = undefined, since = undefined, limit = undefined, params = {}, cursorReceived = undefined, cursorSent = undefined, cursorIncrement = undefined, maxEntriesPerRequest = undefined) {
4236
+ let maxCalls = undefined;
4237
+ [maxCalls, params] = this.handleOptionAndParams(params, method, 'paginationCalls', 10);
4238
+ let maxRetries = undefined;
4239
+ [maxRetries, params] = this.handleOptionAndParams(params, method, 'maxRetries', 3);
4240
+ [maxEntriesPerRequest, params] = this.handleMaxEntriesPerRequestAndParams(method, maxEntriesPerRequest, params);
4241
+ let cursorValue = undefined;
4242
+ let i = 0;
4243
+ let errors = 0;
4244
+ let result = [];
4245
+ while (i < maxCalls) {
4246
+ try {
4247
+ if (cursorValue !== undefined) {
4248
+ if (cursorIncrement !== undefined) {
4249
+ cursorValue = this.parseToInt(cursorValue) + cursorIncrement;
4250
+ }
4251
+ params[cursorSent] = cursorValue;
4252
+ }
4253
+ const response = await this[method](symbol, since, maxEntriesPerRequest, params);
4254
+ errors = 0;
4255
+ const responseLength = response.length;
4256
+ if (this.verbose) {
4257
+ this.log('Cursor pagination call', i + 1, 'method', method, 'response length', responseLength, 'cursor', cursorValue);
4258
+ }
4259
+ if (responseLength === 0) {
4260
+ break;
4261
+ }
4262
+ result = this.arrayConcat(result, response);
4263
+ const last = this.safeValue(response, responseLength - 1);
4264
+ cursorValue = this.safeValue(last['info'], cursorReceived);
4265
+ if (cursorValue === undefined) {
4266
+ break;
4267
+ }
4268
+ }
4269
+ catch (e) {
4270
+ errors += 1;
4271
+ if (errors > maxRetries) {
4272
+ throw e;
4273
+ }
4274
+ }
4275
+ i += 1;
4276
+ }
4277
+ return result;
4278
+ }
4279
+ removeRepeatedElementsFromArray(input) {
4280
+ const uniqueResult = {};
4281
+ for (let i = 0; i < input.length; i++) {
4282
+ const entry = input[i];
4283
+ const id = this.safeString(entry, 'id');
4284
+ if (id !== undefined) {
4285
+ if (this.safeString(uniqueResult, id) === undefined) {
4286
+ uniqueResult[id] = entry;
4287
+ }
4288
+ }
4289
+ else {
4290
+ const timestamp = this.safeInteger2(entry, 'timestamp', 0);
4291
+ if (timestamp !== undefined) {
4292
+ if (this.safeString(uniqueResult, timestamp) === undefined) {
4293
+ uniqueResult[timestamp] = entry;
4294
+ }
4295
+ }
4296
+ }
4297
+ }
4298
+ const values = Object.values(uniqueResult);
4299
+ const valuesLength = values.length;
4300
+ if (valuesLength > 0) {
4301
+ return values;
4302
+ }
4303
+ return input;
4304
+ }
4305
+ handleUntilOption(key, request, params, multiplier = 1) {
4306
+ const until = this.safeValue2(params, 'until', 'till');
4307
+ if (until !== undefined) {
4308
+ request[key] = this.parseToInt(until * multiplier);
4309
+ params = this.omit(params, ['until', 'till']);
4310
+ }
4311
+ return [request, params];
4312
+ }
4097
4313
  }
4098
4314
  export { Exchange, };
@@ -97,7 +97,7 @@ export default class binance extends Exchange {
97
97
  };
98
98
  fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
99
99
  parseOHLCV(ohlcv: any, market?: any): number[];
100
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
100
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
101
101
  parseTrade(trade: any, market?: any): import("./base/types.js").Trade | {
102
102
  id: any;
103
103
  timestamp: number;
@@ -116,7 +116,7 @@ export default class binance extends Exchange {
116
116
  };
117
117
  info: any;
118
118
  };
119
- fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
119
+ fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
120
120
  editSpotOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
121
121
  editSpotOrderRequest(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): any;
122
122
  editContractOrder(id: string, symbol: any, type: any, side: any, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
@@ -126,15 +126,15 @@ export default class binance extends Exchange {
126
126
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
127
127
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
128
128
  fetchOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
129
- fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
129
+ fetchOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
130
130
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
131
131
  fetchClosedOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any[]>;
132
132
  fetchCanceledOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
133
133
  cancelOrder(id: string, symbol?: string, params?: {}): Promise<import("./base/types.js").Order>;
134
134
  cancelAllOrders(symbol?: string, params?: {}): Promise<any>;
135
135
  cancelOrders(ids: Int[], symbol?: string, params?: {}): Promise<import("./base/types.js").Order[]>;
136
- fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
137
- fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
136
+ fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
137
+ fetchMyTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
138
138
  fetchMyDustTrades(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
139
139
  parseDustTrade(trade: any, market?: any): {
140
140
  id: any;