ccxt 4.4.8 → 4.4.10

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 (127) 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/bigone.js +35 -86
  6. package/dist/cjs/src/binance.js +4 -8
  7. package/dist/cjs/src/bingx.js +26 -22
  8. package/dist/cjs/src/bitfinex2.js +5 -16
  9. package/dist/cjs/src/bitget.js +7 -3
  10. package/dist/cjs/src/bitmart.js +1 -0
  11. package/dist/cjs/src/bitmex.js +4 -3
  12. package/dist/cjs/src/blofin.js +4 -13
  13. package/dist/cjs/src/bybit.js +21 -15
  14. package/dist/cjs/src/coinex.js +15 -1
  15. package/dist/cjs/src/delta.js +2 -1
  16. package/dist/cjs/src/deribit.js +1 -0
  17. package/dist/cjs/src/digifinex.js +15 -1
  18. package/dist/cjs/src/gate.js +64 -9
  19. package/dist/cjs/src/hashkey.js +2 -2
  20. package/dist/cjs/src/hitbtc.js +2 -1
  21. package/dist/cjs/src/htx.js +21 -2
  22. package/dist/cjs/src/hyperliquid.js +6 -1
  23. package/dist/cjs/src/krakenfutures.js +3 -2
  24. package/dist/cjs/src/kucoin.js +2 -1
  25. package/dist/cjs/src/kucoinfutures.js +173 -2
  26. package/dist/cjs/src/mexc.js +1 -0
  27. package/dist/cjs/src/oceanex.js +83 -3
  28. package/dist/cjs/src/okx.js +14 -0
  29. package/dist/cjs/src/oxfun.js +4 -4
  30. package/dist/cjs/src/phemex.js +1 -0
  31. package/dist/cjs/src/poloniexfutures.js +11 -0
  32. package/dist/cjs/src/pro/binance.js +4 -4
  33. package/dist/cjs/src/pro/deribit.js +43 -1
  34. package/dist/cjs/src/pro/gate.js +1 -1
  35. package/dist/cjs/src/pro/hitbtc.js +122 -48
  36. package/dist/cjs/src/pro/hollaex.js +5 -0
  37. package/dist/cjs/src/pro/okx.js +19 -3
  38. package/dist/cjs/src/pro/p2b.js +35 -1
  39. package/dist/cjs/src/pro/whitebit.js +31 -0
  40. package/dist/cjs/src/vertex.js +2 -1
  41. package/dist/cjs/src/whitebit.js +10 -9
  42. package/dist/cjs/src/woo.js +42 -17
  43. package/dist/cjs/src/woofipro.js +15 -2
  44. package/dist/cjs/src/xt.js +2 -0
  45. package/js/ccxt.d.ts +1 -1
  46. package/js/ccxt.js +1 -1
  47. package/js/src/abstract/bigone.d.ts +1 -1
  48. package/js/src/abstract/kucoinfutures.d.ts +5 -0
  49. package/js/src/abstract/oceanex.d.ts +5 -0
  50. package/js/src/ascendex.d.ts +3 -21
  51. package/js/src/ascendex.js +2 -1
  52. package/js/src/base/Exchange.d.ts +3 -3
  53. package/js/src/base/types.d.ts +1 -0
  54. package/js/src/bigone.js +35 -86
  55. package/js/src/binance.d.ts +4 -40
  56. package/js/src/binance.js +4 -8
  57. package/js/src/bingx.d.ts +4 -40
  58. package/js/src/bingx.js +26 -22
  59. package/js/src/bitfinex2.d.ts +3 -22
  60. package/js/src/bitfinex2.js +5 -16
  61. package/js/src/bitget.d.ts +3 -39
  62. package/js/src/bitget.js +7 -3
  63. package/js/src/bitmart.d.ts +3 -39
  64. package/js/src/bitmart.js +1 -0
  65. package/js/src/bitmex.d.ts +3 -21
  66. package/js/src/bitmex.js +4 -3
  67. package/js/src/blofin.d.ts +3 -39
  68. package/js/src/blofin.js +4 -13
  69. package/js/src/bybit.d.ts +3 -21
  70. package/js/src/bybit.js +21 -15
  71. package/js/src/coinex.d.ts +5 -40
  72. package/js/src/coinex.js +15 -1
  73. package/js/src/delta.d.ts +4 -40
  74. package/js/src/delta.js +2 -1
  75. package/js/src/deribit.d.ts +3 -39
  76. package/js/src/deribit.js +1 -0
  77. package/js/src/digifinex.d.ts +4 -21
  78. package/js/src/digifinex.js +15 -1
  79. package/js/src/gate.d.ts +6 -41
  80. package/js/src/gate.js +64 -9
  81. package/js/src/hashkey.d.ts +4 -40
  82. package/js/src/hashkey.js +2 -2
  83. package/js/src/hitbtc.d.ts +4 -40
  84. package/js/src/hitbtc.js +2 -1
  85. package/js/src/htx.d.ts +5 -40
  86. package/js/src/htx.js +21 -2
  87. package/js/src/hyperliquid.js +6 -1
  88. package/js/src/krakenfutures.d.ts +3 -21
  89. package/js/src/krakenfutures.js +3 -2
  90. package/js/src/kucoin.js +2 -1
  91. package/js/src/kucoinfutures.d.ts +9 -20
  92. package/js/src/kucoinfutures.js +173 -2
  93. package/js/src/mexc.d.ts +3 -39
  94. package/js/src/mexc.js +1 -0
  95. package/js/src/oceanex.d.ts +9 -1
  96. package/js/src/oceanex.js +83 -3
  97. package/js/src/okx.d.ts +4 -39
  98. package/js/src/okx.js +14 -0
  99. package/js/src/oxfun.d.ts +3 -21
  100. package/js/src/oxfun.js +4 -4
  101. package/js/src/phemex.d.ts +3 -39
  102. package/js/src/phemex.js +1 -0
  103. package/js/src/poloniexfutures.d.ts +3 -20
  104. package/js/src/poloniexfutures.js +11 -0
  105. package/js/src/pro/binance.js +4 -4
  106. package/js/src/pro/deribit.d.ts +2 -1
  107. package/js/src/pro/deribit.js +43 -1
  108. package/js/src/pro/gate.js +1 -1
  109. package/js/src/pro/hitbtc.d.ts +4 -1
  110. package/js/src/pro/hitbtc.js +122 -48
  111. package/js/src/pro/hollaex.js +5 -0
  112. package/js/src/pro/okx.js +19 -3
  113. package/js/src/pro/p2b.d.ts +2 -1
  114. package/js/src/pro/p2b.js +35 -1
  115. package/js/src/pro/whitebit.d.ts +2 -1
  116. package/js/src/pro/whitebit.js +31 -0
  117. package/js/src/vertex.d.ts +4 -40
  118. package/js/src/vertex.js +2 -1
  119. package/js/src/whitebit.d.ts +4 -21
  120. package/js/src/whitebit.js +10 -9
  121. package/js/src/woo.d.ts +4 -40
  122. package/js/src/woo.js +42 -17
  123. package/js/src/woofipro.d.ts +5 -40
  124. package/js/src/woofipro.js +15 -2
  125. package/js/src/xt.d.ts +3 -39
  126. package/js/src/xt.js +2 -0
  127. 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.8';
197
+ const version = '4.4.10';
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);
@@ -158,7 +158,7 @@ class bigone extends bigone$1 {
158
158
  },
159
159
  'webExchange': {
160
160
  'get': [
161
- 'uc/v2/assets',
161
+ 'v3/assets',
162
162
  ],
163
163
  },
164
164
  },
@@ -338,7 +338,7 @@ class bigone extends bigone$1 {
338
338
  * @returns {dict} an associative dictionary of currencies
339
339
  */
340
340
  // we use undocumented link (possible, less informative alternative is : https://big.one/api/uc/v3/assets/accounts)
341
- const data = await this.fetchWebEndpoint('fetchCurrencies', 'webExchangeGetUcV2Assets', true);
341
+ const data = await this.fetchWebEndpoint('fetchCurrencies', 'webExchangeGetV3Assets', true);
342
342
  if (data === undefined) {
343
343
  return undefined;
344
344
  }
@@ -348,91 +348,40 @@ class bigone extends bigone$1 {
348
348
  // "message": "",
349
349
  // "data": [
350
350
  // {
351
- // "name": "TetherUS",
352
- // "symbol": "USDT",
353
- // "contract_address": "31",
354
- // "is_deposit_enabled": true,
355
- // "is_withdrawal_enabled": true,
356
- // "is_stub": false,
357
- // "withdrawal_fee": "5.0",
358
- // "is_fiat": false,
359
- // "is_memo_required": false,
360
- // "logo": {
361
- // "default": "https://assets.peatio.com/assets/v1/color/normal/usdt.png",
362
- // "white": "https://assets.peatio.com/assets/v1/white/normal/usdt.png",
351
+ // "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
352
+ // "symbol": "USDT",
353
+ // "name": "TetherUS",
354
+ // "scale": 12,
355
+ // "is_fiat": false,
356
+ // "is_transfer_enabled": true,
357
+ // "transfer_scale": 12,
358
+ // "binding_gateways": [
359
+ // {
360
+ // "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
361
+ // "is_deposit_enabled": true,
362
+ // "gateway_name": "Ethereum",
363
+ // "min_withdrawal_amount": "0.000001",
364
+ // "withdrawal_fee": "5.71",
365
+ // "is_withdrawal_enabled": true,
366
+ // "min_deposit_amount": "0.000001",
367
+ // "is_memo_required": false,
368
+ // "withdrawal_scale": 6,
369
+ // "scale": 12
370
+ // },
371
+ // {
372
+ // "guid": "4e387a9a-a480-40a3-b4ae-ed1773c2db5a",
373
+ // "is_deposit_enabled": true,
374
+ // "gateway_name": "BinanceSmartChain",
375
+ // "min_withdrawal_amount": "10",
376
+ // "withdrawal_fee": "5",
377
+ // "is_withdrawal_enabled": false,
378
+ // "min_deposit_amount": "1",
379
+ // "is_memo_required": false,
380
+ // "withdrawal_scale": 8,
381
+ // "scale": 12
382
+ // }
383
+ // ]
363
384
  // },
364
- // "info_link": null,
365
- // "scale": "12",
366
- // "default_gateway": ..., // one object from "gateways"
367
- // "gateways": [
368
- // {
369
- // "uuid": "f0fa5a85-7f65-428a-b7b7-13aad55c2837",
370
- // "name": "Mixin",
371
- // "kind": "CHAIN",
372
- // "required_confirmations": "0",
373
- // },
374
- // {
375
- // "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
376
- // "name": "Ethereum",
377
- // "kind": "CHAIN",
378
- // "required_confirmations": "18",
379
- // },
380
- // {
381
- // "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
382
- // "name": "Tron",
383
- // "kind": "CHAIN",
384
- // "required_confirmations": "1",
385
- // },
386
- // ...
387
- // ],
388
- // "payments": [],
389
- // "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
390
- // "binding_gateways": [
391
- // {
392
- // "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
393
- // "contract_address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
394
- // "is_deposit_enabled": true,
395
- // "display_name": "Ethereum(ERC20)",
396
- // "gateway_name": "Ethereum",
397
- // "min_withdrawal_amount": "0.000001",
398
- // "min_internal_withdrawal_amount": "0.00000001",
399
- // "withdrawal_fee": "14",
400
- // "is_withdrawal_enabled": true,
401
- // "min_deposit_amount": "0.000001",
402
- // "is_memo_required": false,
403
- // "withdrawal_scale": "2",
404
- // "gateway": {
405
- // "uuid": "b75446c6-1446-4c8d-b3d1-39f385b0a926",
406
- // "name": "Ethereum",
407
- // "kind": "CHAIN",
408
- // "required_confirmations": "18",
409
- // },
410
- // "scale": "12",
411
- // },
412
- // {
413
- // "guid": "b80a4d13-cac7-4319-842d-b33c3bfab8ec",
414
- // "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
415
- // "is_deposit_enabled": true,
416
- // "display_name": "Tron(TRC20)",
417
- // "gateway_name": "Tron",
418
- // "min_withdrawal_amount": "0.000001",
419
- // "min_internal_withdrawal_amount": "0.00000001",
420
- // "withdrawal_fee": "1",
421
- // "is_withdrawal_enabled": true,
422
- // "min_deposit_amount": "0.000001",
423
- // "is_memo_required": false,
424
- // "withdrawal_scale": "6",
425
- // "gateway": {
426
- // "uuid": "fe9b1b0b-e55c-4017-b5ce-16f524df5fc0",
427
- // "name": "Tron",
428
- // "kind": "CHAIN",
429
- // "required_confirmations": "1",
430
- // },
431
- // "scale": "12",
432
- // },
433
- // ...
434
- // ],
435
- // },
436
385
  // ...
437
386
  // ],
438
387
  // }
@@ -9341,7 +9341,7 @@ class binance extends binance$1 {
9341
9341
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
9342
9342
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9343
9343
  * @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)
9344
+ * @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
9345
  * @param {string} [params.subType] "linear" or "inverse"
9346
9346
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
9347
9347
  */
@@ -9417,7 +9417,7 @@ class binance extends binance$1 {
9417
9417
  * @param {string[]|undefined} symbols list of unified market symbols
9418
9418
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9419
9419
  * @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
9420
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexed by market symbols
9421
9421
  */
9422
9422
  await this.loadMarkets();
9423
9423
  symbols = this.marketSymbols(symbols);
@@ -9436,12 +9436,7 @@ class binance extends binance$1 {
9436
9436
  else {
9437
9437
  throw new errors.NotSupported(this.id + ' fetchFundingRates() supports linear and inverse contracts only');
9438
9438
  }
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
- }
9439
+ const result = this.parseFundingRates(response);
9445
9440
  return this.filterByArray(result, 'symbol', symbols);
9446
9441
  }
9447
9442
  parseFundingRate(contract, market = undefined) {
@@ -9485,6 +9480,7 @@ class binance extends binance$1 {
9485
9480
  'previousFundingRate': undefined,
9486
9481
  'previousFundingTimestamp': undefined,
9487
9482
  'previousFundingDatetime': undefined,
9483
+ 'interval': undefined,
9488
9484
  };
9489
9485
  }
9490
9486
  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,
@@ -648,7 +654,12 @@ class bingx extends bingx$1 {
648
654
  // "maxNotional": 20000,
649
655
  // "status": 1,
650
656
  // "tickSize": 0.000001,
651
- // "stepSize": 1
657
+ // "stepSize": 1,
658
+ // "apiStateSell": true,
659
+ // "apiStateBuy": true,
660
+ // "timeOnline": 0,
661
+ // "offTime": 0,
662
+ // "maintainTime": 0
652
663
  // },
653
664
  // ...
654
665
  // ]
@@ -757,7 +768,7 @@ class bingx extends bingx$1 {
757
768
  if ((this.safeString(market, 'apiStateOpen') === 'true') && (this.safeString(market, 'apiStateClose') === 'true')) {
758
769
  isActive = true; // swap active
759
770
  }
760
- else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy')) {
771
+ else if (this.safeBool(market, 'apiStateSell') && this.safeBool(market, 'apiStateBuy') && (this.safeNumber(market, 'status') === 1)) {
761
772
  isActive = true; // spot active
762
773
  }
763
774
  const isInverse = (spot) ? undefined : checkIsInverse;
@@ -1372,27 +1383,19 @@ class bingx extends bingx$1 {
1372
1383
  async fetchFundingRates(symbols = undefined, params = {}) {
1373
1384
  /**
1374
1385
  * @method
1375
- * @name bingx#fetchFundingRate
1376
- * @description fetch the current funding rate
1386
+ * @name bingx#fetchFundingRates
1387
+ * @description fetch the current funding rate for multiple symbols
1377
1388
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
1378
1389
  * @param {string[]} [symbols] list of unified market symbols
1379
1390
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1380
- * @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}
1381
1392
  */
1382
1393
  await this.loadMarkets();
1383
1394
  symbols = this.marketSymbols(symbols, 'swap', true);
1384
1395
  const response = await this.swapV2PublicGetQuotePremiumIndex(this.extend(params));
1385
1396
  const data = this.safeList(response, 'data', []);
1386
- const filteredResponse = [];
1387
- for (let i = 0; i < data.length; i++) {
1388
- const item = data[i];
1389
- const marketId = this.safeString(item, 'symbol');
1390
- const market = this.safeMarket(marketId, undefined, undefined, 'swap');
1391
- if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
1392
- filteredResponse.push(this.parseFundingRate(item, market));
1393
- }
1394
- }
1395
- return filteredResponse;
1397
+ const result = this.parseFundingRates(data);
1398
+ return this.filterByArray(result, 'symbol', symbols);
1396
1399
  }
1397
1400
  parseFundingRate(contract, market = undefined) {
1398
1401
  //
@@ -1424,6 +1427,7 @@ class bingx extends bingx$1 {
1424
1427
  'previousFundingRate': undefined,
1425
1428
  'previousFundingTimestamp': undefined,
1426
1429
  'previousFundingDatetime': undefined,
1430
+ 'interval': undefined,
1427
1431
  };
1428
1432
  }
1429
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) {
@@ -1414,12 +1414,15 @@ class bitget extends bitget$1 {
1414
1414
  'sandboxMode': false,
1415
1415
  'networks': {
1416
1416
  'TRX': 'TRC20',
1417
- 'ETH': 'ERC20',
1417
+ 'ERC20': 'ERC20',
1418
1418
  'BEP20': 'BSC',
1419
+ 'ARB': 'ArbitrumOne',
1419
1420
  'ZKSYNC': 'zkSyncEra',
1420
1421
  'STARKNET': 'Starknet',
1421
- 'OPTIMISM': 'Optimism',
1422
- 'ARBITRUM': 'Arbitrum',
1422
+ 'APT': 'APTOS',
1423
+ 'MATIC': 'Polygon',
1424
+ 'VIC': 'VICTION',
1425
+ 'AVAXC': 'C-Chain',
1423
1426
  },
1424
1427
  'networksById': {},
1425
1428
  'fetchPositions': {
@@ -6814,6 +6817,7 @@ class bitget extends bitget$1 {
6814
6817
  'previousFundingRate': undefined,
6815
6818
  'previousFundingTimestamp': undefined,
6816
6819
  'previousFundingDatetime': undefined,
6820
+ 'interval': undefined,
6817
6821
  };
6818
6822
  }
6819
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
  /**
@@ -3709,6 +3703,8 @@ class bybit extends bybit$1 {
3709
3703
  // Valid for option only.
3710
3704
  // 'orderIv': '0', // Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
3711
3705
  };
3706
+ const hedged = this.safeBool(params, 'hedged', false);
3707
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
3712
3708
  let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
3713
3709
  const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
3714
3710
  const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
@@ -3907,7 +3903,14 @@ class bybit extends bybit$1 {
3907
3903
  }
3908
3904
  }
3909
3905
  }
3910
- params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice']);
3906
+ if (!market['spot'] && hedged) {
3907
+ if (reduceOnly) {
3908
+ params = this.omit(params, 'reduceOnly');
3909
+ side = (side === 'buy') ? 'sell' : 'buy';
3910
+ }
3911
+ request['positionIdx'] = (side === 'buy') ? 1 : 2;
3912
+ }
3913
+ params = this.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged']);
3911
3914
  return this.extend(request, params);
3912
3915
  }
3913
3916
  async createOrders(orders, params = {}) {
@@ -6824,6 +6827,8 @@ class bybit extends bybit$1 {
6824
6827
  }
6825
6828
  const maintenanceMarginPercentage = Precise["default"].stringDiv(maintenanceMarginString, notional);
6826
6829
  const marginRatio = Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4);
6830
+ const positionIdx = this.safeString(position, 'positionIdx');
6831
+ const hedged = (positionIdx !== undefined) && (positionIdx !== '0');
6827
6832
  return this.safePosition({
6828
6833
  'info': position,
6829
6834
  'id': undefined,
@@ -6852,6 +6857,7 @@ class bybit extends bybit$1 {
6852
6857
  'percentage': undefined,
6853
6858
  'stopLossPrice': this.safeNumber2(position, 'stop_loss', 'stopLoss'),
6854
6859
  'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
6860
+ 'hedged': hedged,
6855
6861
  });
6856
6862
  }
6857
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