ccxt 4.4.9 → 4.4.11

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 (117) hide show
  1. package/README.md +131 -131
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ascendex.js +2 -1
  5. package/dist/cjs/src/binance.js +6 -9
  6. package/dist/cjs/src/bingx.js +19 -20
  7. package/dist/cjs/src/bitfinex2.js +5 -16
  8. package/dist/cjs/src/bitget.js +6 -5
  9. package/dist/cjs/src/bitmart.js +1 -0
  10. package/dist/cjs/src/bitmex.js +4 -3
  11. package/dist/cjs/src/blofin.js +4 -13
  12. package/dist/cjs/src/bybit.js +16 -14
  13. package/dist/cjs/src/coinex.js +15 -1
  14. package/dist/cjs/src/delta.js +2 -1
  15. package/dist/cjs/src/deribit.js +1 -0
  16. package/dist/cjs/src/digifinex.js +15 -1
  17. package/dist/cjs/src/gate.js +30 -9
  18. package/dist/cjs/src/hashkey.js +2 -2
  19. package/dist/cjs/src/hitbtc.js +2 -1
  20. package/dist/cjs/src/htx.js +26 -3
  21. package/dist/cjs/src/hyperliquid.js +6 -1
  22. package/dist/cjs/src/kraken.js +41 -13
  23. package/dist/cjs/src/krakenfutures.js +3 -2
  24. package/dist/cjs/src/kucoinfutures.js +11 -0
  25. package/dist/cjs/src/mexc.js +12 -4
  26. package/dist/cjs/src/oceanex.js +83 -3
  27. package/dist/cjs/src/okx.js +15 -0
  28. package/dist/cjs/src/oxfun.js +4 -4
  29. package/dist/cjs/src/phemex.js +1 -0
  30. package/dist/cjs/src/poloniexfutures.js +11 -0
  31. package/dist/cjs/src/pro/deribit.js +122 -1
  32. package/dist/cjs/src/pro/exmo.js +31 -1
  33. package/dist/cjs/src/pro/gate.js +1 -1
  34. package/dist/cjs/src/pro/okx.js +1 -1
  35. package/dist/cjs/src/vertex.js +2 -1
  36. package/dist/cjs/src/whitebit.js +10 -9
  37. package/dist/cjs/src/woo.js +42 -17
  38. package/dist/cjs/src/woofipro.js +15 -2
  39. package/dist/cjs/src/xt.js +2 -0
  40. package/js/ccxt.d.ts +1 -1
  41. package/js/ccxt.js +1 -1
  42. package/js/src/abstract/binance.d.ts +1 -0
  43. package/js/src/abstract/binancecoinm.d.ts +1 -0
  44. package/js/src/abstract/binanceus.d.ts +1 -0
  45. package/js/src/abstract/binanceusdm.d.ts +1 -0
  46. package/js/src/abstract/oceanex.d.ts +5 -0
  47. package/js/src/ascendex.d.ts +3 -21
  48. package/js/src/ascendex.js +2 -1
  49. package/js/src/base/Exchange.d.ts +3 -3
  50. package/js/src/base/types.d.ts +1 -0
  51. package/js/src/binance.d.ts +4 -40
  52. package/js/src/binance.js +6 -9
  53. package/js/src/bingx.d.ts +4 -40
  54. package/js/src/bingx.js +19 -20
  55. package/js/src/bitfinex2.d.ts +3 -22
  56. package/js/src/bitfinex2.js +5 -16
  57. package/js/src/bitget.d.ts +3 -39
  58. package/js/src/bitget.js +6 -5
  59. package/js/src/bitmart.d.ts +3 -39
  60. package/js/src/bitmart.js +1 -0
  61. package/js/src/bitmex.d.ts +3 -21
  62. package/js/src/bitmex.js +4 -3
  63. package/js/src/blofin.d.ts +3 -39
  64. package/js/src/blofin.js +4 -13
  65. package/js/src/bybit.d.ts +3 -21
  66. package/js/src/bybit.js +16 -14
  67. package/js/src/coinex.d.ts +5 -40
  68. package/js/src/coinex.js +15 -1
  69. package/js/src/delta.d.ts +4 -40
  70. package/js/src/delta.js +2 -1
  71. package/js/src/deribit.d.ts +3 -39
  72. package/js/src/deribit.js +1 -0
  73. package/js/src/digifinex.d.ts +4 -21
  74. package/js/src/digifinex.js +15 -1
  75. package/js/src/gate.d.ts +6 -41
  76. package/js/src/gate.js +30 -9
  77. package/js/src/hashkey.d.ts +4 -40
  78. package/js/src/hashkey.js +2 -2
  79. package/js/src/hitbtc.d.ts +4 -40
  80. package/js/src/hitbtc.js +2 -1
  81. package/js/src/htx.d.ts +5 -40
  82. package/js/src/htx.js +26 -3
  83. package/js/src/hyperliquid.js +6 -1
  84. package/js/src/kraken.js +41 -13
  85. package/js/src/krakenfutures.d.ts +3 -21
  86. package/js/src/krakenfutures.js +3 -2
  87. package/js/src/kucoinfutures.d.ts +3 -20
  88. package/js/src/kucoinfutures.js +11 -0
  89. package/js/src/mexc.d.ts +3 -39
  90. package/js/src/mexc.js +12 -4
  91. package/js/src/oceanex.d.ts +9 -1
  92. package/js/src/oceanex.js +83 -3
  93. package/js/src/okx.d.ts +4 -39
  94. package/js/src/okx.js +16 -1
  95. package/js/src/oxfun.d.ts +3 -21
  96. package/js/src/oxfun.js +4 -4
  97. package/js/src/phemex.d.ts +3 -39
  98. package/js/src/phemex.js +1 -0
  99. package/js/src/poloniexfutures.d.ts +3 -20
  100. package/js/src/poloniexfutures.js +11 -0
  101. package/js/src/pro/deribit.d.ts +5 -1
  102. package/js/src/pro/deribit.js +122 -1
  103. package/js/src/pro/exmo.d.ts +2 -1
  104. package/js/src/pro/exmo.js +31 -1
  105. package/js/src/pro/gate.js +1 -1
  106. package/js/src/pro/okx.js +1 -1
  107. package/js/src/vertex.d.ts +4 -40
  108. package/js/src/vertex.js +2 -1
  109. package/js/src/whitebit.d.ts +4 -21
  110. package/js/src/whitebit.js +10 -9
  111. package/js/src/woo.d.ts +4 -40
  112. package/js/src/woo.js +42 -17
  113. package/js/src/woofipro.d.ts +5 -40
  114. package/js/src/woofipro.js +15 -2
  115. package/js/src/xt.d.ts +3 -39
  116. package/js/src/xt.js +2 -0
  117. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.4.9';
197
+ const version = '4.4.11';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -2794,6 +2794,7 @@ class ascendex extends ascendex$1 {
2794
2794
  'fundingRate': nextFundingRate,
2795
2795
  'fundingTimestamp': nextFundingRateTimestamp,
2796
2796
  'fundingDatetime': this.iso8601(nextFundingRateTimestamp),
2797
+ 'interval': undefined,
2797
2798
  };
2798
2799
  }
2799
2800
  async fetchFundingRates(symbols = undefined, params = {}) {
@@ -2803,7 +2804,7 @@ class ascendex extends ascendex$1 {
2803
2804
  * @description fetch the funding rate for multiple markets
2804
2805
  * @param {string[]|undefined} symbols list of unified market symbols
2805
2806
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2806
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2807
+ * @returns {object[]} a list of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2807
2808
  */
2808
2809
  await this.loadMarkets();
2809
2810
  symbols = this.marketSymbols(symbols);
@@ -1091,7 +1091,8 @@ class binance extends binance$1 {
1091
1091
  'repay-futures-negative-balance': 150,
1092
1092
  'listenKey': 1,
1093
1093
  'asset-collection': 3,
1094
- 'margin/repay-debt': 0.4, // Weight(Order): 0.4 => (1000 / (50 * 0.4)) * 60 = 3000
1094
+ 'margin/repay-debt': 0.4,
1095
+ 'um/feeBurn': 1,
1095
1096
  },
1096
1097
  'put': {
1097
1098
  'listenKey': 1, // 1
@@ -9341,7 +9342,7 @@ class binance extends binance$1 {
9341
9342
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
9342
9343
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9343
9344
  * @param {int} [params.until] timestamp in ms of the latest funding rate
9344
- * @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](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
9345
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
9345
9346
  * @param {string} [params.subType] "linear" or "inverse"
9346
9347
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
9347
9348
  */
@@ -9417,7 +9418,7 @@ class binance extends binance$1 {
9417
9418
  * @param {string[]|undefined} symbols list of unified market symbols
9418
9419
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9419
9420
  * @param {string} [params.subType] "linear" or "inverse"
9420
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
9421
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
9421
9422
  */
9422
9423
  await this.loadMarkets();
9423
9424
  symbols = this.marketSymbols(symbols);
@@ -9436,12 +9437,7 @@ class binance extends binance$1 {
9436
9437
  else {
9437
9438
  throw new errors.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
9438
9439
  }
9439
- const result = [];
9440
- for (let i = 0; i < response.length; i++) {
9441
- const entry = response[i];
9442
- const parsed = this.parseFundingRate(entry);
9443
- result.push(parsed);
9444
- }
9440
+ const result = this.parseFundingRates(response);
9445
9441
  return this.filterByArray(result, 'symbol', symbols);
9446
9442
  }
9447
9443
  parseFundingRate(contract, market = undefined) {
@@ -9485,6 +9481,7 @@ class binance extends binance$1 {
9485
9481
  'previousFundingRate': undefined,
9486
9482
  'previousFundingTimestamp': undefined,
9487
9483
  'previousFundingDatetime': undefined,
9484
+ 'interval': undefined,
9488
9485
  };
9489
9486
  }
9490
9487
  parseAccountPositions(account, filterClosed = false) {
@@ -581,7 +581,6 @@ class bingx extends bingx$1 {
581
581
  const networkList = this.safeList(entry, 'networkList');
582
582
  const networks = {};
583
583
  let fee = undefined;
584
- let active = undefined;
585
584
  let depositEnabled = undefined;
586
585
  let withdrawEnabled = undefined;
587
586
  let defaultLimits = {};
@@ -590,8 +589,14 @@ class bingx extends bingx$1 {
590
589
  const network = this.safeString(rawNetwork, 'network');
591
590
  const networkCode = this.networkIdToCode(network);
592
591
  const isDefault = this.safeBool(rawNetwork, 'isDefault');
593
- depositEnabled = this.safeBool(rawNetwork, 'depositEnable');
594
- withdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
592
+ const networkDepositEnabled = this.safeBool(rawNetwork, 'depositEnable');
593
+ if (networkDepositEnabled) {
594
+ depositEnabled = true;
595
+ }
596
+ const networkWithdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
597
+ if (networkDepositEnabled) {
598
+ withdrawEnabled = true;
599
+ }
595
600
  const limits = {
596
601
  'withdraw': {
597
602
  'min': this.safeNumber(rawNetwork, 'withdrawMin'),
@@ -600,21 +605,22 @@ class bingx extends bingx$1 {
600
605
  };
601
606
  if (isDefault) {
602
607
  fee = this.safeNumber(rawNetwork, 'withdrawFee');
603
- active = depositEnabled || withdrawEnabled;
604
608
  defaultLimits = limits;
605
609
  }
610
+ const networkActive = networkDepositEnabled || networkWithdrawEnabled;
606
611
  networks[networkCode] = {
607
612
  'info': rawNetwork,
608
613
  'id': network,
609
614
  'network': networkCode,
610
615
  'fee': fee,
611
- 'active': active,
612
- 'deposit': depositEnabled,
613
- 'withdraw': withdrawEnabled,
616
+ 'active': networkActive,
617
+ 'deposit': networkDepositEnabled,
618
+ 'withdraw': networkWithdrawEnabled,
614
619
  'precision': undefined,
615
620
  'limits': limits,
616
621
  };
617
622
  }
623
+ const active = depositEnabled || withdrawEnabled;
618
624
  result[code] = {
619
625
  'info': entry,
620
626
  'code': code,
@@ -1377,27 +1383,19 @@ class bingx extends bingx$1 {
1377
1383
  async fetchFundingRates(symbols = undefined, params = {}) {
1378
1384
  /**
1379
1385
  * @method
1380
- * @name bingx#fetchFundingRate
1381
- * @description fetch the current funding rate
1386
+ * @name bingx#fetchFundingRates
1387
+ * @description fetch the current funding rate for multiple symbols
1382
1388
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
1383
1389
  * @param {string[]} [symbols] list of unified market symbols
1384
1390
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1385
- * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1391
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1386
1392
  */
1387
1393
  await this.loadMarkets();
1388
1394
  symbols = this.marketSymbols(symbols, 'swap', true);
1389
1395
  const response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(params));
1390
1396
  const data = this.safeList(response, 'data', []);
1391
- const filteredResponse = [];
1392
- for (let i = 0; i < data.length; i++) {
1393
- const item = data[i];
1394
- const marketId = this.safeString(item, 'symbol');
1395
- const market = this.safeMarket(marketId, undefined, undefined, 'swap');
1396
- if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
1397
- filteredResponse.push(this.parseFundingRate(item, market));
1398
- }
1399
- }
1400
- return filteredResponse;
1397
+ const result = this.parseFundingRates(data);
1398
+ return this.filterByArray(result, 'symbol', symbols);
1401
1399
  }
1402
1400
  parseFundingRate(contract, market = undefined) {
1403
1401
  //
@@ -1429,6 +1427,7 @@ class bingx extends bingx$1 {
1429
1427
  'previousFundingRate': undefined,
1430
1428
  'previousFundingTimestamp': undefined,
1431
1429
  'previousFundingDatetime': undefined,
1430
+ 'interval': undefined,
1432
1431
  };
1433
1432
  }
1434
1433
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -63,7 +63,7 @@ class bitfinex2 extends bitfinex2$1 {
63
63
  'fetchDepositAddress': true,
64
64
  'fetchDepositsWithdrawals': true,
65
65
  'fetchFundingHistory': false,
66
- 'fetchFundingRate': true,
66
+ 'fetchFundingRate': 'emulated',
67
67
  'fetchFundingRateHistory': true,
68
68
  'fetchFundingRates': true,
69
69
  'fetchIndexOHLCV': false,
@@ -3005,27 +3005,15 @@ class bitfinex2 extends bitfinex2$1 {
3005
3005
  }
3006
3006
  return this.parseLedger(ledgerObjects, currency, since, limit);
3007
3007
  }
3008
- async fetchFundingRate(symbol, params = {}) {
3009
- /**
3010
- * @method
3011
- * @name bitfinex2#fetchFundingRate
3012
- * @description fetch the current funding rate
3013
- * @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
3014
- * @param {string} symbol unified market symbol
3015
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3016
- * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3017
- */
3018
- return await this.fetchFundingRates([symbol], params);
3019
- }
3020
3008
  async fetchFundingRates(symbols = undefined, params = {}) {
3021
3009
  /**
3022
3010
  * @method
3023
- * @name bitfinex2#fetchFundingRate
3024
- * @description fetch the current funding rate
3011
+ * @name bitfinex2#fetchFundingRates
3012
+ * @description fetch the current funding rate for multiple symbols
3025
3013
  * @see https://docs.bitfinex.com/reference/rest-public-derivatives-status
3026
3014
  * @param {string[]} symbols list of unified market symbols
3027
3015
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3028
- * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3016
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
3029
3017
  */
3030
3018
  if (symbols === undefined) {
3031
3019
  throw new errors.ArgumentsRequired(this.id + ' fetchFundingRates() requires a symbols argument');
@@ -3196,6 +3184,7 @@ class bitfinex2 extends bitfinex2$1 {
3196
3184
  'previousFundingRate': undefined,
3197
3185
  'previousFundingTimestamp': undefined,
3198
3186
  'previousFundingDatetime': undefined,
3187
+ 'interval': undefined,
3199
3188
  };
3200
3189
  }
3201
3190
  parseFundingRateHistory(contract, market = undefined) {
@@ -1413,16 +1413,16 @@ class bitget extends bitget$1 {
1413
1413
  },
1414
1414
  'sandboxMode': false,
1415
1415
  'networks': {
1416
- 'TRX': 'TRC20',
1417
- 'ETH': 'ERC20',
1416
+ 'TRC20': 'TRC20',
1417
+ 'ERC20': 'ERC20',
1418
1418
  'BEP20': 'BSC',
1419
+ 'ARB': 'ArbitrumOne',
1419
1420
  'ZKSYNC': 'zkSyncEra',
1420
1421
  'STARKNET': 'Starknet',
1421
- 'OPTIMISM': 'Optimism',
1422
- 'ARBITRUM': 'Arbitrum',
1423
1422
  'APT': 'APTOS',
1424
- 'MATIC': 'POLYGON',
1423
+ 'MATIC': 'Polygon',
1425
1424
  'VIC': 'VICTION',
1425
+ 'AVAXC': 'C-Chain',
1426
1426
  },
1427
1427
  'networksById': {},
1428
1428
  'fetchPositions': {
@@ -6817,6 +6817,7 @@ class bitget extends bitget$1 {
6817
6817
  'previousFundingRate': undefined,
6818
6818
  'previousFundingTimestamp': undefined,
6819
6819
  'previousFundingDatetime': undefined,
6820
+ 'interval': undefined,
6820
6821
  };
6821
6822
  }
6822
6823
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -4496,6 +4496,7 @@ class bitmart extends bitmart$1 {
4496
4496
  'previousFundingRate': this.safeNumber(contract, 'rate_value'),
4497
4497
  'previousFundingTimestamp': undefined,
4498
4498
  'previousFundingDatetime': undefined,
4499
+ 'interval': undefined,
4499
4500
  };
4500
4501
  }
4501
4502
  async fetchPosition(symbol, params = {}) {
@@ -56,7 +56,7 @@ class bitmex extends bitmex$1 {
56
56
  'fetchDepositWithdrawFee': 'emulated',
57
57
  'fetchDepositWithdrawFees': true,
58
58
  'fetchFundingHistory': false,
59
- 'fetchFundingRate': false,
59
+ 'fetchFundingRate': 'emulated',
60
60
  'fetchFundingRateHistory': true,
61
61
  'fetchFundingRates': true,
62
62
  'fetchIndexOHLCV': false,
@@ -2489,7 +2489,7 @@ class bitmex extends bitmex$1 {
2489
2489
  * @see https://www.bitmex.com/api/explorer/#!/Instrument/Instrument_getActiveAndIndices
2490
2490
  * @param {string[]|undefined} symbols list of unified market symbols
2491
2491
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2492
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2492
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
2493
2493
  */
2494
2494
  await this.loadMarkets();
2495
2495
  const response = await this.publicGetInstrumentActiveAndIndices(params);
@@ -2523,7 +2523,7 @@ class bitmex extends bitmex$1 {
2523
2523
  'timestamp': this.parse8601(datetime),
2524
2524
  'datetime': datetime,
2525
2525
  'fundingRate': this.safeNumber(contract, 'fundingRate'),
2526
- 'fundingTimestamp': this.iso8601(fundingDatetime),
2526
+ 'fundingTimestamp': this.parseToNumeric(this.iso8601(fundingDatetime)),
2527
2527
  'fundingDatetime': fundingDatetime,
2528
2528
  'nextFundingRate': this.safeNumber(contract, 'indicativeFundingRate'),
2529
2529
  'nextFundingTimestamp': undefined,
@@ -2531,6 +2531,7 @@ class bitmex extends bitmex$1 {
2531
2531
  'previousFundingRate': undefined,
2532
2532
  'previousFundingTimestamp': undefined,
2533
2533
  'previousFundingDatetime': undefined,
2534
+ 'interval': undefined,
2534
2535
  };
2535
2536
  }
2536
2537
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -793,17 +793,10 @@ class blofin extends blofin$1 {
793
793
  // "fundingRate": "0.00027815",
794
794
  // "fundingTime": "1634256000000",
795
795
  // "instId": "BTC-USD-SWAP",
796
- // "instType": "SWAP",
797
- // "nextFundingRate": "0.00017",
798
- // "nextFundingTime": "1634284800000"
799
796
  // }
800
797
  //
801
- // in the response above nextFundingRate is actually two funding rates from now
802
- //
803
- const nextFundingRateTimestamp = this.safeInteger(contract, 'nextFundingTime');
804
798
  const marketId = this.safeString(contract, 'instId');
805
799
  const symbol = this.safeSymbol(marketId, market);
806
- const nextFundingRate = this.safeNumber(contract, 'nextFundingRate');
807
800
  const fundingTime = this.safeInteger(contract, 'fundingTime');
808
801
  // > The current interest is 0.
809
802
  return {
@@ -818,12 +811,13 @@ class blofin extends blofin$1 {
818
811
  'fundingRate': this.safeNumber(contract, 'fundingRate'),
819
812
  'fundingTimestamp': fundingTime,
820
813
  'fundingDatetime': this.iso8601(fundingTime),
821
- 'nextFundingRate': nextFundingRate,
822
- 'nextFundingTimestamp': nextFundingRateTimestamp,
823
- 'nextFundingDatetime': this.iso8601(nextFundingRateTimestamp),
814
+ 'nextFundingRate': undefined,
815
+ 'nextFundingTimestamp': undefined,
816
+ 'nextFundingDatetime': undefined,
824
817
  'previousFundingRate': undefined,
825
818
  'previousFundingTimestamp': undefined,
826
819
  'previousFundingDatetime': undefined,
820
+ 'interval': undefined,
827
821
  };
828
822
  }
829
823
  async fetchFundingRate(symbol, params = {}) {
@@ -853,9 +847,6 @@ class blofin extends blofin$1 {
853
847
  // "fundingRate": "0.00027815",
854
848
  // "fundingTime": "1634256000000",
855
849
  // "instId": "BTC-USD-SWAP",
856
- // "instType": "SWAP",
857
- // "nextFundingRate": "0.00017",
858
- // "nextFundingTime": "1634284800000"
859
850
  // }
860
851
  // ],
861
852
  // "msg": ""
@@ -79,7 +79,7 @@ class bybit extends bybit$1 {
79
79
  'fetchDepositWithdrawFee': 'emulated',
80
80
  'fetchDepositWithdrawFees': true,
81
81
  'fetchFundingHistory': true,
82
- 'fetchFundingRate': true,
82
+ 'fetchFundingRate': 'emulated',
83
83
  'fetchFundingRateHistory': true,
84
84
  'fetchFundingRates': true,
85
85
  'fetchGreeks': true,
@@ -2435,6 +2435,7 @@ class bybit extends bybit$1 {
2435
2435
  return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
2436
2436
  }
2437
2437
  parseFundingRate(ticker, market = undefined) {
2438
+ //
2438
2439
  // {
2439
2440
  // "symbol": "BTCUSDT",
2440
2441
  // "bidPrice": "19255",
@@ -2485,6 +2486,7 @@ class bybit extends bybit$1 {
2485
2486
  'previousFundingRate': undefined,
2486
2487
  'previousFundingTimestamp': undefined,
2487
2488
  'previousFundingDatetime': undefined,
2489
+ 'interval': undefined,
2488
2490
  };
2489
2491
  }
2490
2492
  async fetchFundingRates(symbols = undefined, params = {}) {
@@ -2495,7 +2497,7 @@ class bybit extends bybit$1 {
2495
2497
  * @see https://bybit-exchange.github.io/docs/v5/market/tickers
2496
2498
  * @param {string[]} symbols unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
2497
2499
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2498
- * @returns {object} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2500
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2499
2501
  */
2500
2502
  await this.loadMarkets();
2501
2503
  let market = undefined;
@@ -2555,18 +2557,10 @@ class bybit extends bybit$1 {
2555
2557
  // "time": 1663670053454
2556
2558
  // }
2557
2559
  //
2558
- let tickerList = this.safeValue(response, 'result', []);
2559
- const timestamp = this.safeInteger(response, 'time');
2560
- tickerList = this.safeValue(tickerList, 'list');
2561
- const fundingRates = {};
2562
- for (let i = 0; i < tickerList.length; i++) {
2563
- const rawTicker = tickerList[i];
2564
- rawTicker['timestamp'] = timestamp; // will be removed inside the parser
2565
- const ticker = this.parseFundingRate(tickerList[i], undefined);
2566
- const symbol = ticker['symbol'];
2567
- fundingRates[symbol] = ticker;
2568
- }
2569
- return this.filterByArray(fundingRates, 'symbol', symbols);
2560
+ const data = this.safeDict(response, 'result', {});
2561
+ const tickerList = this.safeList(data, 'list', []);
2562
+ const result = this.parseFundingRates(tickerList);
2563
+ return this.filterByArray(result, 'symbol', symbols);
2570
2564
  }
2571
2565
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2572
2566
  /**
@@ -3710,6 +3704,7 @@ class bybit extends bybit$1 {
3710
3704
  // 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3711
3705
  };
3712
3706
  const hedged = this.safeBool(params, 'hedged', false);
3707
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
3713
3708
  let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
3714
3709
  const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
3715
3710
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
@@ -3909,6 +3904,10 @@ class bybit extends bybit$1 {
3909
3904
  }
3910
3905
  }
3911
3906
  if (!market['spot'] && hedged) {
3907
+ if (reduceOnly) {
3908
+ params = this.omit(params, 'reduceOnly');
3909
+ side = (side === 'buy') ? 'sell' : 'buy';
3910
+ }
3912
3911
  request['positionIdx'] = (side === 'buy') ? 1 : 2;
3913
3912
  }
3914
3913
  params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged']);
@@ -6828,6 +6827,8 @@ class bybit extends bybit$1 {
6828
6827
  }
6829
6828
  const maintenanceMarginPercentage = Precise["default"].stringDiv(maintenanceMarginString, notional);
6830
6829
  const marginRatio = Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4);
6830
+ const positionIdx = this.safeString(position, 'positionIdx');
6831
+ const hedged = (positionIdx !== undefined) && (positionIdx !== '0');
6831
6832
  return this.safePosition({
6832
6833
  'info': position,
6833
6834
  'id': undefined,
@@ -6856,6 +6857,7 @@ class bybit extends bybit$1 {
6856
6857
  'percentage': undefined,
6857
6858
  'stopLossPrice': this.safeNumber2(position, 'stop_loss', 'stopLoss'),
6858
6859
  'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
6860
+ 'hedged': hedged,
6859
6861
  });
6860
6862
  }
6861
6863
  async fetchLeverage(symbol, params = {}) {
@@ -4570,6 +4570,9 @@ class coinex extends coinex$1 {
4570
4570
  //
4571
4571
  const currentFundingTimestamp = this.safeInteger(contract, 'latest_funding_time');
4572
4572
  const futureFundingTimestamp = this.safeInteger(contract, 'next_funding_time');
4573
+ const fundingTimeString = this.safeString(contract, 'latest_funding_time');
4574
+ const nextFundingTimeString = this.safeString(contract, 'next_funding_time');
4575
+ const millisecondsInterval = Precise["default"].stringSub(nextFundingTimeString, fundingTimeString);
4573
4576
  const marketId = this.safeString(contract, 'market');
4574
4577
  return {
4575
4578
  'info': contract,
@@ -4589,13 +4592,24 @@ class coinex extends coinex$1 {
4589
4592
  'previousFundingRate': undefined,
4590
4593
  'previousFundingTimestamp': undefined,
4591
4594
  'previousFundingDatetime': undefined,
4595
+ 'interval': this.parseFundingInterval(millisecondsInterval),
4592
4596
  };
4593
4597
  }
4598
+ parseFundingInterval(interval) {
4599
+ const intervals = {
4600
+ '3600000': '1h',
4601
+ '14400000': '4h',
4602
+ '28800000': '8h',
4603
+ '57600000': '16h',
4604
+ '86400000': '24h',
4605
+ };
4606
+ return this.safeString(intervals, interval, interval);
4607
+ }
4594
4608
  async fetchFundingRates(symbols = undefined, params = {}) {
4595
4609
  /**
4596
4610
  * @method
4597
4611
  * @name coinex#fetchFundingRates
4598
- * @description fetch the current funding rates
4612
+ * @description fetch the current funding rates for multiple markets
4599
4613
  * @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4600
4614
  * @param {string[]} symbols unified market symbols
4601
4615
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2452,7 +2452,7 @@ class delta extends delta$1 {
2452
2452
  * @see https://docs.delta.exchange/#get-tickers-for-products
2453
2453
  * @param {string[]|undefined} symbols list of unified market symbols
2454
2454
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2455
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2455
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
2456
2456
  */
2457
2457
  await this.loadMarkets();
2458
2458
  symbols = this.marketSymbols(symbols);
@@ -2576,6 +2576,7 @@ class delta extends delta$1 {
2576
2576
  'previousFundingRate': undefined,
2577
2577
  'previousFundingTimestamp': undefined,
2578
2578
  'previousFundingDatetime': undefined,
2579
+ 'interval': undefined,
2579
2580
  };
2580
2581
  }
2581
2582
  async addMargin(symbol, amount, params = {}) {
@@ -3137,6 +3137,7 @@ class deribit extends deribit$1 {
3137
3137
  'previousFundingRate': undefined,
3138
3138
  'previousFundingTimestamp': undefined,
3139
3139
  'previousFundingDatetime': undefined,
3140
+ 'interval': '8h',
3140
3141
  };
3141
3142
  }
3142
3143
  async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
@@ -3263,6 +3263,9 @@ class digifinex extends digifinex$1 {
3263
3263
  const marketId = this.safeString(contract, 'instrument_id');
3264
3264
  const timestamp = this.safeInteger(contract, 'funding_time');
3265
3265
  const nextTimestamp = this.safeInteger(contract, 'next_funding_time');
3266
+ const fundingTimeString = this.safeString(contract, 'funding_time');
3267
+ const nextFundingTimeString = this.safeString(contract, 'next_funding_time');
3268
+ const millisecondsInterval = Precise["default"].stringSub(nextFundingTimeString, fundingTimeString);
3266
3269
  return {
3267
3270
  'info': contract,
3268
3271
  'symbol': this.safeSymbol(marketId, market),
@@ -3275,14 +3278,25 @@ class digifinex extends digifinex$1 {
3275
3278
  'fundingRate': this.safeNumber(contract, 'funding_rate'),
3276
3279
  'fundingTimestamp': timestamp,
3277
3280
  'fundingDatetime': this.iso8601(timestamp),
3278
- 'nextFundingRate': this.safeString(contract, 'next_funding_rate'),
3281
+ 'nextFundingRate': this.safeNumber(contract, 'next_funding_rate'),
3279
3282
  'nextFundingTimestamp': nextTimestamp,
3280
3283
  'nextFundingDatetime': this.iso8601(nextTimestamp),
3281
3284
  'previousFundingRate': undefined,
3282
3285
  'previousFundingTimestamp': undefined,
3283
3286
  'previousFundingDatetime': undefined,
3287
+ 'interval': this.parseFundingInterval(millisecondsInterval),
3284
3288
  };
3285
3289
  }
3290
+ parseFundingInterval(interval) {
3291
+ const intervals = {
3292
+ '3600000': '1h',
3293
+ '14400000': '4h',
3294
+ '28800000': '8h',
3295
+ '57600000': '16h',
3296
+ '86400000': '24h',
3297
+ };
3298
+ return this.safeString(intervals, interval, interval);
3299
+ }
3286
3300
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3287
3301
  /**
3288
3302
  * @method
@@ -1747,7 +1747,7 @@ class gate extends gate$1 {
1747
1747
  * @see https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
1748
1748
  * @param {string[]|undefined} symbols list of unified market symbols
1749
1749
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1750
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
1750
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
1751
1751
  */
1752
1752
  await this.loadMarkets();
1753
1753
  symbols = this.marketSymbols(symbols);
@@ -1851,6 +1851,7 @@ class gate extends gate$1 {
1851
1851
  const fundingRate = this.safeNumber(contract, 'funding_rate');
1852
1852
  const fundingTime = this.safeTimestamp(contract, 'funding_next_apply');
1853
1853
  const fundingRateIndicative = this.safeNumber(contract, 'funding_rate_indicative');
1854
+ const fundingInterval = Precise["default"].stringMul('1000', this.safeString(contract, 'funding_interval'));
1854
1855
  return {
1855
1856
  'info': contract,
1856
1857
  'symbol': symbol,
@@ -1869,8 +1870,19 @@ class gate extends gate$1 {
1869
1870
  'previousFundingRate': undefined,
1870
1871
  'previousFundingTimestamp': undefined,
1871
1872
  'previousFundingDatetime': undefined,
1873
+ 'interval': this.parseFundingInterval(fundingInterval),
1872
1874
  };
1873
1875
  }
1876
+ parseFundingInterval(interval) {
1877
+ const intervals = {
1878
+ '3600000': '1h',
1879
+ '14400000': '4h',
1880
+ '28800000': '8h',
1881
+ '57600000': '16h',
1882
+ '86400000': '24h',
1883
+ };
1884
+ return this.safeString(intervals, interval, interval);
1885
+ }
1874
1886
  async fetchNetworkDepositAddress(code, params = {}) {
1875
1887
  await this.loadMarkets();
1876
1888
  const currency = this.currency(code);
@@ -4726,7 +4738,6 @@ class gate extends gate$1 {
4726
4738
  */
4727
4739
  await this.loadMarkets();
4728
4740
  const until = this.safeInteger(params, 'until');
4729
- params = this.omit(params, 'until');
4730
4741
  let market = undefined;
4731
4742
  if (symbol !== undefined) {
4732
4743
  market = this.market(symbol);
@@ -4746,6 +4757,7 @@ class gate extends gate$1 {
4746
4757
  request['from'] = this.parseToInt(since / 1000);
4747
4758
  }
4748
4759
  if (until !== undefined) {
4760
+ params = this.omit(params, 'until');
4749
4761
  request['to'] = this.parseToInt(until / 1000);
4750
4762
  }
4751
4763
  if (limit !== undefined) {
@@ -4754,7 +4766,7 @@ class gate extends gate$1 {
4754
4766
  const response = await this.privateFuturesGetSettleOrdersTimerange(this.extend(request, params));
4755
4767
  return this.parseOrders(response, market, since, limit);
4756
4768
  }
4757
- fetchOrdersByStatusRequest(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
4769
+ prepareOrdersByStatusRequest(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
4758
4770
  let market = undefined;
4759
4771
  if (symbol !== undefined) {
4760
4772
  market = this.market(symbol);
@@ -4762,9 +4774,11 @@ class gate extends gate$1 {
4762
4774
  }
4763
4775
  const stop = this.safeBool2(params, 'stop', 'trigger');
4764
4776
  params = this.omit(params, ['stop', 'trigger']);
4765
- const [type, query] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
4777
+ let type = undefined;
4778
+ [type, params] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
4766
4779
  const spot = (type === 'spot') || (type === 'margin');
4767
- const [request, requestParams] = spot ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
4780
+ let request = {};
4781
+ [request, params] = spot ? this.multiOrderSpotPrepareRequest(market, stop, params) : this.prepareRequest(market, type, params);
4768
4782
  if (status === 'closed') {
4769
4783
  status = 'finished';
4770
4784
  }
@@ -4772,10 +4786,17 @@ class gate extends gate$1 {
4772
4786
  if (limit !== undefined) {
4773
4787
  request['limit'] = limit;
4774
4788
  }
4775
- if (since !== undefined && spot) {
4776
- request['from'] = this.parseToInt(since / 1000);
4789
+ if (spot) {
4790
+ if (since !== undefined) {
4791
+ request['from'] = this.parseToInt(since / 1000);
4792
+ }
4793
+ const until = this.safeInteger(params, 'until');
4794
+ if (until !== undefined) {
4795
+ params = this.omit(params, 'until');
4796
+ request['to'] = this.parseToInt(until / 1000);
4797
+ }
4777
4798
  }
4778
- const [lastId, finalParams] = this.handleParamString2(requestParams, 'lastId', 'last_id');
4799
+ const [lastId, finalParams] = this.handleParamString2(params, 'lastId', 'last_id');
4779
4800
  if (lastId !== undefined) {
4780
4801
  request['last_id'] = lastId;
4781
4802
  }
@@ -4793,7 +4814,7 @@ class gate extends gate$1 {
4793
4814
  const res = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
4794
4815
  const type = this.safeString(res, 0);
4795
4816
  params['type'] = type;
4796
- const [request, requestParams] = this.fetchOrdersByStatusRequest(status, symbol, since, limit, params);
4817
+ const [request, requestParams] = this.prepareOrdersByStatusRequest(status, symbol, since, limit, params);
4797
4818
  const spot = (type === 'spot') || (type === 'margin');
4798
4819
  const openSpotOrders = spot && (status === 'open') && !stop;
4799
4820
  let response = undefined;