ccxt 4.4.77 → 4.4.80

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 (154) hide show
  1. package/README.md +8 -10
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +8 -4
  4. package/dist/cjs/src/abstract/ace.js +1 -1
  5. package/dist/cjs/src/abstract/apex.js +9 -0
  6. package/dist/cjs/src/ace.js +1 -1
  7. package/dist/cjs/src/apex.js +1949 -0
  8. package/dist/cjs/src/ascendex.js +25 -4
  9. package/dist/cjs/src/base/Exchange.js +42 -2
  10. package/dist/cjs/src/binance.js +9 -1
  11. package/dist/cjs/src/bingx.js +3 -3
  12. package/dist/cjs/src/bitfinex.js +64 -36
  13. package/dist/cjs/src/bitget.js +191 -138
  14. package/dist/cjs/src/bitmart.js +7 -2
  15. package/dist/cjs/src/bitmex.js +16 -8
  16. package/dist/cjs/src/bitopro.js +5 -1
  17. package/dist/cjs/src/bitrue.js +2 -1
  18. package/dist/cjs/src/bitso.js +1 -1
  19. package/dist/cjs/src/bitteam.js +2 -0
  20. package/dist/cjs/src/bitvavo.js +28 -10
  21. package/dist/cjs/src/btcalpha.js +1 -1
  22. package/dist/cjs/src/btcmarkets.js +1 -1
  23. package/dist/cjs/src/btcturk.js +1 -1
  24. package/dist/cjs/src/bybit.js +32 -16
  25. package/dist/cjs/src/cex.js +1 -1
  26. package/dist/cjs/src/coinbase.js +18 -2
  27. package/dist/cjs/src/coincatch.js +68 -0
  28. package/dist/cjs/src/coinex.js +1 -0
  29. package/dist/cjs/src/coinlist.js +1 -0
  30. package/dist/cjs/src/coinone.js +1 -0
  31. package/dist/cjs/src/delta.js +4 -0
  32. package/dist/cjs/src/deribit.js +1 -0
  33. package/dist/cjs/src/hitbtc.js +3 -0
  34. package/dist/cjs/src/hollaex.js +1 -0
  35. package/dist/cjs/src/htx.js +7 -3
  36. package/dist/cjs/src/huobijp.js +1 -0
  37. package/dist/cjs/src/hyperliquid.js +14 -4
  38. package/dist/cjs/src/kraken.js +2 -0
  39. package/dist/cjs/src/mexc.js +50 -57
  40. package/dist/cjs/src/okx.js +1 -1
  41. package/dist/cjs/src/phemex.js +2 -1
  42. package/dist/cjs/src/poloniex.js +2 -1
  43. package/dist/cjs/src/pro/apex.js +1043 -0
  44. package/dist/cjs/src/pro/binance.js +3 -3
  45. package/dist/cjs/src/pro/coinbase.js +45 -68
  46. package/dist/cjs/src/pro/gate.js +27 -2
  47. package/dist/cjs/src/pro/hollaex.js +2 -2
  48. package/dist/cjs/src/pro/p2b.js +2 -2
  49. package/dist/cjs/src/pro/tradeogre.js +283 -0
  50. package/dist/cjs/src/pro/upbit.js +43 -0
  51. package/dist/cjs/src/probit.js +1 -0
  52. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2639 -0
  53. package/dist/cjs/src/timex.js +2 -2
  54. package/dist/cjs/src/tradeogre.js +2 -1
  55. package/dist/cjs/src/upbit.js +277 -67
  56. package/dist/cjs/src/whitebit.js +66 -12
  57. package/dist/cjs/src/woo.js +3 -1
  58. package/dist/cjs/src/xt.js +9 -0
  59. package/js/ccxt.d.ts +11 -5
  60. package/js/ccxt.js +8 -4
  61. package/js/src/abstract/apex.d.ts +34 -0
  62. package/js/src/abstract/bitmart.d.ts +1 -0
  63. package/js/src/apex.d.ts +333 -0
  64. package/js/src/apex.js +1945 -0
  65. package/js/src/ascendex.d.ts +3 -3
  66. package/js/src/ascendex.js +25 -4
  67. package/js/src/base/Exchange.d.ts +2 -0
  68. package/js/src/base/Exchange.js +42 -1
  69. package/js/src/binance.d.ts +7 -7
  70. package/js/src/binance.js +9 -1
  71. package/js/src/bingx.js +3 -3
  72. package/js/src/bitfinex.d.ts +3 -3
  73. package/js/src/bitfinex.js +64 -36
  74. package/js/src/bitflyer.d.ts +2 -2
  75. package/js/src/bitget.d.ts +2 -0
  76. package/js/src/bitget.js +191 -138
  77. package/js/src/bitmart.d.ts +5 -4
  78. package/js/src/bitmart.js +7 -2
  79. package/js/src/bitmex.d.ts +3 -3
  80. package/js/src/bitmex.js +16 -8
  81. package/js/src/bitopro.js +5 -1
  82. package/js/src/bitrue.js +2 -1
  83. package/js/src/bitso.js +1 -1
  84. package/js/src/bitteam.js +2 -0
  85. package/js/src/bitvavo.js +28 -10
  86. package/js/src/btcalpha.js +1 -1
  87. package/js/src/btcmarkets.js +1 -1
  88. package/js/src/btcturk.js +1 -1
  89. package/js/src/bybit.js +32 -16
  90. package/js/src/cex.js +1 -1
  91. package/js/src/coinbase.d.ts +4 -4
  92. package/js/src/coinbase.js +18 -2
  93. package/js/src/coinbaseexchange.d.ts +1 -1
  94. package/js/src/coincatch.d.ts +11 -0
  95. package/js/src/coincatch.js +68 -0
  96. package/js/src/coinex.js +1 -0
  97. package/js/src/coinlist.js +1 -0
  98. package/js/src/coinone.js +1 -0
  99. package/js/src/cryptocom.d.ts +4 -4
  100. package/js/src/delta.js +4 -0
  101. package/js/src/deribit.d.ts +4 -4
  102. package/js/src/deribit.js +1 -0
  103. package/js/src/derive.d.ts +3 -3
  104. package/js/src/digifinex.d.ts +4 -4
  105. package/js/src/hitbtc.js +3 -0
  106. package/js/src/hollaex.js +1 -0
  107. package/js/src/htx.d.ts +4 -4
  108. package/js/src/htx.js +7 -3
  109. package/js/src/huobijp.js +1 -0
  110. package/js/src/hyperliquid.d.ts +1 -0
  111. package/js/src/hyperliquid.js +14 -4
  112. package/js/src/kraken.d.ts +3 -3
  113. package/js/src/kraken.js +2 -0
  114. package/js/src/krakenfutures.d.ts +2 -2
  115. package/js/src/kucoinfutures.d.ts +5 -5
  116. package/js/src/mexc.d.ts +1 -0
  117. package/js/src/mexc.js +50 -57
  118. package/js/src/okx.js +1 -1
  119. package/js/src/oxfun.d.ts +3 -3
  120. package/js/src/phemex.d.ts +3 -3
  121. package/js/src/phemex.js +2 -1
  122. package/js/src/poloniex.d.ts +3 -3
  123. package/js/src/poloniex.js +2 -1
  124. package/js/src/pro/apex.d.ts +160 -0
  125. package/js/src/pro/apex.js +1038 -0
  126. package/js/src/pro/binance.js +3 -3
  127. package/js/src/pro/coinbase.d.ts +4 -3
  128. package/js/src/pro/coinbase.js +45 -66
  129. package/js/src/pro/gate.js +27 -2
  130. package/js/src/pro/hollaex.js +2 -2
  131. package/js/src/pro/p2b.js +2 -2
  132. package/js/src/pro/tradeogre.d.ts +49 -0
  133. package/js/src/pro/tradeogre.js +278 -0
  134. package/js/src/pro/upbit.d.ts +16 -1
  135. package/js/src/pro/upbit.js +43 -0
  136. package/js/src/probit.js +1 -0
  137. package/js/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  138. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +4276 -0
  139. package/js/src/timex.js +2 -2
  140. package/js/src/tradeogre.js +2 -1
  141. package/js/src/upbit.d.ts +75 -23
  142. package/js/src/upbit.js +277 -67
  143. package/js/src/vertex.d.ts +3 -3
  144. package/js/src/whitebit.js +66 -12
  145. package/js/src/woo.d.ts +4 -4
  146. package/js/src/woo.js +3 -1
  147. package/js/src/woofipro.d.ts +4 -4
  148. package/js/src/xt.d.ts +4 -4
  149. package/js/src/xt.js +9 -0
  150. package/package.json +2 -2
  151. package/js/src/abstract/ace.d.ts +0 -18
  152. package/js/src/ace.d.ts +0 -158
  153. package/js/src/ace.js +0 -1175
  154. /package/js/src/abstract/{ace.js → apex.js} +0 -0
@@ -1371,28 +1371,44 @@ class bitget extends bitget$1 {
1371
1371
  'fillResponseFromRequest': true,
1372
1372
  },
1373
1373
  'fetchOHLCV': {
1374
- 'spot': {
1375
- 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1376
- },
1377
- 'swap': {
1378
- 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1379
- },
1380
- 'maxDaysPerTimeframe': {
1374
+ // ### Timeframe settings ###
1375
+ // after testing, the below values are real ones, because the values provided by API DOCS are wrong
1376
+ // so, start timestamp should be within these thresholds to be able to call "recent" candles endpoint
1377
+ 'maxRecentDaysPerTimeframe': {
1381
1378
  '1m': 30,
1382
1379
  '3m': 30,
1383
1380
  '5m': 30,
1384
- '10m': 30,
1385
- '15m': 52,
1386
- '30m': 62,
1387
- '1h': 83,
1388
- '2h': 120,
1381
+ '15m': 30,
1382
+ '30m': 30,
1383
+ '1h': 60,
1389
1384
  '4h': 240,
1390
1385
  '6h': 360,
1391
- '12h': 360,
1392
- '1d': 300,
1393
- '3d': 300,
1394
- '1w': 300,
1395
- '1M': 300,
1386
+ '12h': 720,
1387
+ '1d': 1440,
1388
+ '3d': 1440 * 3,
1389
+ '1w': 1440 * 7,
1390
+ '1M': 1440 * 30,
1391
+ },
1392
+ 'spot': {
1393
+ 'maxLimitPerTimeframe': {
1394
+ '1d': 300,
1395
+ '3d': 100,
1396
+ '1w': 100,
1397
+ '1M': 100,
1398
+ },
1399
+ 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1400
+ },
1401
+ 'swap': {
1402
+ 'maxLimitPerTimeframe': {
1403
+ '4h': 540,
1404
+ '6h': 360,
1405
+ '12h': 180,
1406
+ '1d': 90,
1407
+ '3d': 30,
1408
+ '1w': 13,
1409
+ '1M': 4,
1410
+ },
1411
+ 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1396
1412
  },
1397
1413
  },
1398
1414
  'fetchTrades': {
@@ -1403,6 +1419,9 @@ class bitget extends bitget$1 {
1403
1419
  'method': 'publicMixGetV2MixMarketFillsHistory', // or publicMixGetV2MixMarketFills
1404
1420
  },
1405
1421
  },
1422
+ 'fetchFundingRate': {
1423
+ 'method': 'publicMixGetV2MixMarketCurrentFundRate', // or publicMixGetV2MixMarketFundingTime
1424
+ },
1406
1425
  'accountsByType': {
1407
1426
  'spot': 'spot',
1408
1427
  'cross': 'crossed_margin',
@@ -1524,7 +1543,9 @@ class bitget extends bitget$1 {
1524
1543
  'fetchPositions': {
1525
1544
  'method': 'privateMixGetV2MixPositionAllPosition', // or privateMixGetV2MixPositionHistoryPosition
1526
1545
  },
1527
- 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
1546
+ 'defaultTimeInForce': 'GTC',
1547
+ // fiat currencies on deposit page
1548
+ 'fiatCurrencies': ['EUR', 'VND', 'PLN', 'CZK', 'HUF', 'DKK', 'AUD', 'CAD', 'NOK', 'SEK', 'CHF', 'MXN', 'COP', 'ARS', 'GBP', 'BRL', 'UAH', 'ZAR'],
1528
1549
  },
1529
1550
  'features': {
1530
1551
  'spot': {
@@ -1599,7 +1620,7 @@ class bitget extends bitget$1 {
1599
1620
  'symbolRequired': false,
1600
1621
  },
1601
1622
  'fetchOHLCV': {
1602
- 'limit': 1000, // variable timespans for recent endpoint, 200 for historical
1623
+ 'limit': 200, // variable timespans for recent endpoint, 200 for historical
1603
1624
  },
1604
1625
  },
1605
1626
  'forPerps': {
@@ -1674,13 +1695,12 @@ class bitget extends bitget$1 {
1674
1695
  let defaultProductType = undefined;
1675
1696
  if ((subType !== undefined) && (market === undefined)) {
1676
1697
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
1677
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1678
- if (sandboxMode) {
1679
- defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1680
- }
1681
- else {
1682
- defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1683
- }
1698
+ // const sandboxMode = this.safeBool (this.options, 'sandboxMode', false);
1699
+ // if (sandboxMode) {
1700
+ // defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1701
+ // } else {
1702
+ defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1703
+ // }
1684
1704
  }
1685
1705
  let productType = this.safeString(params, 'productType', defaultProductType);
1686
1706
  if ((productType === undefined) && (market !== undefined)) {
@@ -2012,47 +2032,47 @@ class bitget extends bitget$1 {
2012
2032
  async fetchCurrencies(params = {}) {
2013
2033
  const response = await this.publicSpotGetV2SpotPublicCoins(params);
2014
2034
  //
2015
- // {
2016
- // "code": "00000",
2017
- // "data": [
2018
- // {
2019
- // "chains": [
2020
- // {
2021
- // "browserUrl": "https://blockchair.com/bitcoin/transaction/",
2022
- // "chain": "BTC",
2023
- // "depositConfirm": "1",
2024
- // "extraWithdrawFee": "0",
2025
- // "minDepositAmount": "0.0001",
2026
- // "minWithdrawAmount": "0.005",
2027
- // "needTag": "false",
2028
- // "rechargeable": "true",
2029
- // "withdrawConfirm": "1",
2030
- // "withdrawFee": "0.0004",
2031
- // "withdrawable": "true"
2032
- // },
2033
- // ],
2034
- // "coin": "BTC",
2035
- // "coinId": "1",
2036
- // "transfer": "true""
2037
- // }
2038
- // ],
2039
- // "msg": "success",
2040
- // "requestTime": "1700120731773"
2041
- // }
2035
+ // {
2036
+ // "code": "00000",
2037
+ // "msg": "success",
2038
+ // "requestTime": "1746195617812",
2039
+ // "data": [
2040
+ // {
2041
+ // "coinId": "1456",
2042
+ // "coin": "NEIROETH",
2043
+ // "transfer": "false",
2044
+ // "chains": [
2045
+ // {
2046
+ // "chain": "ERC20",
2047
+ // "needTag": "false",
2048
+ // "withdrawable": "true",
2049
+ // "rechargeable": "true",
2050
+ // "withdrawFee": "44.91017965",
2051
+ // "extraWithdrawFee": "0",
2052
+ // "depositConfirm": "12",
2053
+ // "withdrawConfirm": "64",
2054
+ // "minDepositAmount": "0.06",
2055
+ // "minWithdrawAmount": "60",
2056
+ // "browserUrl": "https://etherscan.io/tx/",
2057
+ // "contractAddress": "0xee2a03aa6dacf51c18679c516ad5283d8e7c2637",
2058
+ // "withdrawStep": "0",
2059
+ // "withdrawMinScale": "8",
2060
+ // "congestion": "normal"
2061
+ // }
2062
+ // ],
2063
+ // "areaCoin": "no"
2064
+ // },
2065
+ // ...
2042
2066
  //
2043
2067
  const result = {};
2044
2068
  const data = this.safeValue(response, 'data', []);
2069
+ const fiatCurrencies = this.safeList(this.options, 'fiatCurrencies', []);
2045
2070
  for (let i = 0; i < data.length; i++) {
2046
2071
  const entry = data[i];
2047
2072
  const id = this.safeString(entry, 'coin'); // we don't use 'coinId' as it has no use. it is 'coin' field that needs to be used in currency related endpoints (deposit, withdraw, etc..)
2048
2073
  const code = this.safeCurrencyCode(id);
2049
2074
  const chains = this.safeValue(entry, 'chains', []);
2050
2075
  const networks = {};
2051
- let deposit = false;
2052
- let withdraw = false;
2053
- let minWithdrawString = undefined;
2054
- let minDepositString = undefined;
2055
- let minWithdrawFeeString = undefined;
2056
2076
  for (let j = 0; j < chains.length; j++) {
2057
2077
  const chain = chains[j];
2058
2078
  const networkId = this.safeString(chain, 'chain');
@@ -2060,56 +2080,39 @@ class bitget extends bitget$1 {
2060
2080
  if (network !== undefined) {
2061
2081
  network = network.toUpperCase();
2062
2082
  }
2063
- const withdrawEnabled = this.safeString(chain, 'withdrawable');
2064
- const canWithdraw = withdrawEnabled === 'true';
2065
- withdraw = (canWithdraw) ? canWithdraw : withdraw;
2066
- const depositEnabled = this.safeString(chain, 'rechargeable');
2067
- const canDeposit = depositEnabled === 'true';
2068
- deposit = (canDeposit) ? canDeposit : deposit;
2069
- const networkWithdrawFeeString = this.safeString(chain, 'withdrawFee');
2070
- if (networkWithdrawFeeString !== undefined) {
2071
- minWithdrawFeeString = (minWithdrawFeeString === undefined) ? networkWithdrawFeeString : Precise["default"].stringMin(networkWithdrawFeeString, minWithdrawFeeString);
2072
- }
2073
- const networkMinWithdrawString = this.safeString(chain, 'minWithdrawAmount');
2074
- if (networkMinWithdrawString !== undefined) {
2075
- minWithdrawString = (minWithdrawString === undefined) ? networkMinWithdrawString : Precise["default"].stringMin(networkMinWithdrawString, minWithdrawString);
2076
- }
2077
- const networkMinDepositString = this.safeString(chain, 'minDepositAmount');
2078
- if (networkMinDepositString !== undefined) {
2079
- minDepositString = (minDepositString === undefined) ? networkMinDepositString : Precise["default"].stringMin(networkMinDepositString, minDepositString);
2080
- }
2081
2083
  networks[network] = {
2082
2084
  'info': chain,
2083
2085
  'id': networkId,
2084
2086
  'network': network,
2085
2087
  'limits': {
2086
2088
  'withdraw': {
2087
- 'min': this.parseNumber(networkMinWithdrawString),
2089
+ 'min': this.safeNumber(chain, 'minWithdrawAmount'),
2088
2090
  'max': undefined,
2089
2091
  },
2090
2092
  'deposit': {
2091
- 'min': this.parseNumber(networkMinDepositString),
2093
+ 'min': this.safeNumber(chain, 'minDepositAmount'),
2092
2094
  'max': undefined,
2093
2095
  },
2094
2096
  },
2095
- 'active': canWithdraw && canDeposit,
2096
- 'withdraw': canWithdraw,
2097
- 'deposit': canDeposit,
2098
- 'fee': this.parseNumber(networkWithdrawFeeString),
2099
- 'precision': undefined,
2097
+ 'active': undefined,
2098
+ 'withdraw': this.safeString(chain, 'withdrawable') === 'true',
2099
+ 'deposit': this.safeString(chain, 'rechargeable') === 'true',
2100
+ 'fee': this.safeNumber(chain, 'withdrawFee'),
2101
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawMinScale'))),
2100
2102
  };
2101
2103
  }
2102
- result[code] = {
2104
+ const isFiat = this.inArray(code, fiatCurrencies);
2105
+ result[code] = this.safeCurrencyStructure({
2103
2106
  'info': entry,
2104
2107
  'id': id,
2105
2108
  'code': code,
2106
2109
  'networks': networks,
2107
- 'type': undefined,
2110
+ 'type': isFiat ? 'fiat' : 'crypto',
2108
2111
  'name': undefined,
2109
- 'active': deposit && withdraw,
2110
- 'deposit': deposit,
2111
- 'withdraw': withdraw,
2112
- 'fee': this.parseNumber(minWithdrawFeeString),
2112
+ 'active': undefined,
2113
+ 'deposit': undefined,
2114
+ 'withdraw': undefined,
2115
+ 'fee': undefined,
2113
2116
  'precision': undefined,
2114
2117
  'limits': {
2115
2118
  'amount': {
@@ -2117,16 +2120,16 @@ class bitget extends bitget$1 {
2117
2120
  'max': undefined,
2118
2121
  },
2119
2122
  'withdraw': {
2120
- 'min': this.parseNumber(minWithdrawString),
2123
+ 'min': undefined,
2121
2124
  'max': undefined,
2122
2125
  },
2123
2126
  'deposit': {
2124
- 'min': this.parseNumber(minDepositString),
2127
+ 'min': undefined,
2125
2128
  'max': undefined,
2126
2129
  },
2127
2130
  },
2128
2131
  'created': undefined,
2129
- };
2132
+ });
2130
2133
  }
2131
2134
  return result;
2132
2135
  }
@@ -2771,7 +2774,7 @@ class bitget extends bitget$1 {
2771
2774
  const close = this.safeString(ticker, 'lastPr');
2772
2775
  const timestamp = this.safeIntegerOmitZero(ticker, 'ts'); // exchange bitget provided 0
2773
2776
  const change = this.safeString(ticker, 'change24h');
2774
- const open24 = this.safeString(ticker, 'open24');
2777
+ const open24 = this.safeString2(ticker, 'open24', 'open24h');
2775
2778
  const open = this.safeString(ticker, 'open');
2776
2779
  let symbol;
2777
2780
  let openValue;
@@ -3489,34 +3492,36 @@ class bitget extends bitget$1 {
3489
3492
  const market = this.market(symbol);
3490
3493
  const marketType = market['spot'] ? 'spot' : 'swap';
3491
3494
  const timeframes = this.options['timeframes'][marketType];
3492
- const msInDay = 86400000;
3493
- const duration = this.parseTimeframe(timeframe) * 1000;
3494
3495
  const request = {
3495
3496
  'symbol': market['id'],
3496
3497
  'granularity': this.safeString(timeframes, timeframe, timeframe),
3497
3498
  };
3499
+ const msInDay = 86400000;
3500
+ const now = this.milliseconds();
3501
+ const duration = this.parseTimeframe(timeframe) * 1000;
3498
3502
  const until = this.safeInteger(params, 'until');
3499
3503
  const limitDefined = limit !== undefined;
3500
3504
  const sinceDefined = since !== undefined;
3501
3505
  const untilDefined = until !== undefined;
3502
3506
  params = this.omit(params, ['until']);
3503
- let response = undefined;
3504
- const now = this.milliseconds();
3505
3507
  // retrievable periods listed here:
3506
3508
  // - https://www.bitget.com/api-doc/spot/market/Get-Candle-Data#request-parameters
3507
3509
  // - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
3508
- const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
3509
- const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
3510
- const maxRetrievableDaysForRecent = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
3511
- const endpointTsBoundary = now - (maxRetrievableDaysForRecent - 1) * msInDay;
3510
+ const key = market['spot'] ? 'spot' : 'swap';
3511
+ const ohlcOptions = this.safeDict(this.options['fetchOHLCV'], key, {});
3512
+ const maxLimitPerTimeframe = this.safeDict(ohlcOptions, 'maxLimitPerTimeframe', {});
3513
+ const maxLimitForThisTimeframe = this.safeInteger(maxLimitPerTimeframe, timeframe, limit);
3514
+ const recentEndpointDaysMap = this.safeDict(this.options['fetchOHLCV'], 'maxRecentDaysPerTimeframe', {});
3515
+ const recentEndpointAvailableDays = this.safeInteger(recentEndpointDaysMap, timeframe);
3516
+ const recentEndpointBoundaryTs = now - (recentEndpointAvailableDays - 1) * msInDay;
3512
3517
  if (limitDefined) {
3513
3518
  limit = Math.min(limit, maxLimitForRecentEndpoint);
3514
- request['limit'] = limit;
3519
+ limit = Math.min(limit, maxLimitForThisTimeframe);
3515
3520
  }
3516
3521
  else {
3517
3522
  limit = defaultLimit;
3518
3523
  }
3519
- const limitMultipliedDuration = limit * duration;
3524
+ let limitMultipliedDuration = limit * duration;
3520
3525
  // exchange aligns from endTime, so it's important, not startTime
3521
3526
  // startTime is supported only on "recent" endpoint, not on "historical" endpoint
3522
3527
  let calculatedStartTime = undefined;
@@ -3537,17 +3542,32 @@ class bitget extends bitget$1 {
3537
3542
  // we do not need to set "startTime" here
3538
3543
  }
3539
3544
  }
3540
- const historicalEndpointNeeded = (calculatedStartTime !== undefined) && (calculatedStartTime <= endpointTsBoundary);
3541
- if (historicalEndpointNeeded) {
3545
+ // if historical endpoint is needed, we should re-set the variables
3546
+ let historicalEndpointNeeded = false;
3547
+ if ((calculatedStartTime !== undefined && calculatedStartTime <= recentEndpointBoundaryTs) || useHistoryEndpoint) {
3548
+ historicalEndpointNeeded = true;
3542
3549
  // only for "historical-candles" - ensure we use correct max limit
3543
- if (limitDefined) {
3544
- request['limit'] = Math.min(limit, maxLimitForHistoryEndpoint);
3550
+ limit = Math.min(limit, maxLimitForHistoryEndpoint);
3551
+ limitMultipliedDuration = limit * duration;
3552
+ calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
3553
+ request['startTime'] = calculatedStartTime;
3554
+ // for contract, maximum 90 days allowed between start-end times
3555
+ if (!market['spot']) {
3556
+ const maxDistanceDaysForContracts = 90;
3557
+ // only correct if request is larger
3558
+ if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3559
+ calculatedEndTime = this.sum(calculatedStartTime, maxDistanceDaysForContracts * msInDay);
3560
+ request['endTime'] = calculatedEndTime;
3561
+ }
3545
3562
  }
3546
3563
  }
3564
+ // we need to set limit to safely cover the period
3565
+ request['limit'] = limit;
3547
3566
  // make request
3567
+ let response = undefined;
3548
3568
  if (market['spot']) {
3549
3569
  // checks if we need history endpoint
3550
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3570
+ if (historicalEndpointNeeded) {
3551
3571
  response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
3552
3572
  }
3553
3573
  else {
@@ -3555,16 +3575,6 @@ class bitget extends bitget$1 {
3555
3575
  }
3556
3576
  }
3557
3577
  else {
3558
- const maxDistanceDaysForContracts = 90; // for contract, maximum 90 days allowed between start-end times
3559
- // only correct the request to fix 90 days if until was auto-calculated
3560
- if (sinceDefined) {
3561
- if (!untilDefined) {
3562
- request['endTime'] = Math.min(calculatedEndTime, this.sum(since, maxDistanceDaysForContracts * msInDay));
3563
- }
3564
- else if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3565
- throw new errors.BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
3566
- }
3567
- }
3568
3578
  let priceType = undefined;
3569
3579
  [priceType, params] = this.handleParamString(params, 'price');
3570
3580
  let productType = undefined;
@@ -3579,7 +3589,7 @@ class bitget extends bitget$1 {
3579
3589
  response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
3580
3590
  }
3581
3591
  else {
3582
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3592
+ if (historicalEndpointNeeded) {
3583
3593
  response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
3584
3594
  }
3585
3595
  else {
@@ -6816,8 +6826,10 @@ class bitget extends bitget$1 {
6816
6826
  * @name bitget#fetchFundingRate
6817
6827
  * @description fetch the current funding rate
6818
6828
  * @see https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
6829
+ * @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
6819
6830
  * @param {string} symbol unified market symbol
6820
6831
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6832
+ * @param {string} [params.method] either (default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
6821
6833
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
6822
6834
  */
6823
6835
  async fetchFundingRate(symbol, params = {}) {
@@ -6832,21 +6844,47 @@ class bitget extends bitget$1 {
6832
6844
  'symbol': market['id'],
6833
6845
  'productType': productType,
6834
6846
  };
6835
- const response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6836
- //
6837
- // {
6838
- // "code": "00000",
6839
- // "msg": "success",
6840
- // "requestTime": 1700811542124,
6841
- // "data": [
6842
- // {
6843
- // "symbol": "BTCUSDT",
6844
- // "fundingRate": "0.000106"
6845
- // }
6846
- // ]
6847
- // }
6848
- //
6849
- const data = this.safeValue(response, 'data', []);
6847
+ let method = undefined;
6848
+ [method, params] = this.handleOptionAndParams(params, 'fetchFundingRate', 'method', 'publicMixGetV2MixMarketCurrentFundRate');
6849
+ let response = undefined;
6850
+ if (method === 'publicMixGetV2MixMarketCurrentFundRate') {
6851
+ response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6852
+ //
6853
+ // {
6854
+ // "code": "00000",
6855
+ // "msg": "success",
6856
+ // "requestTime": 1745500709429,
6857
+ // "data": [
6858
+ // {
6859
+ // "symbol": "BTCUSDT",
6860
+ // "fundingRate": "-0.000013",
6861
+ // "fundingRateInterval": "8",
6862
+ // "nextUpdate": "1745510400000",
6863
+ // "minFundingRate": "-0.003",
6864
+ // "maxFundingRate": "0.003"
6865
+ // }
6866
+ // ]
6867
+ // }
6868
+ //
6869
+ }
6870
+ else if (method === 'publicMixGetV2MixMarketFundingTime') {
6871
+ response = await this.publicMixGetV2MixMarketFundingTime(this.extend(request, params));
6872
+ //
6873
+ // {
6874
+ // "code": "00000",
6875
+ // "msg": "success",
6876
+ // "requestTime": 1745402092428,
6877
+ // "data": [
6878
+ // {
6879
+ // "symbol": "BTCUSDT",
6880
+ // "nextFundingTime": "1745424000000",
6881
+ // "ratePeriod": "8"
6882
+ // }
6883
+ // ]
6884
+ // }
6885
+ //
6886
+ }
6887
+ const data = this.safeList(response, 'data', []);
6850
6888
  return this.parseFundingRate(data[0], market);
6851
6889
  }
6852
6890
  /**
@@ -6910,11 +6948,23 @@ class bitget extends bitget$1 {
6910
6948
  }
6911
6949
  parseFundingRate(contract, market = undefined) {
6912
6950
  //
6913
- // fetchFundingRate
6951
+ // fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate
6952
+ //
6953
+ // {
6954
+ // "symbol": "BTCUSDT",
6955
+ // "fundingRate": "-0.000013",
6956
+ // "fundingRateInterval": "8",
6957
+ // "nextUpdate": "1745510400000",
6958
+ // "minFundingRate": "-0.003",
6959
+ // "maxFundingRate": "0.003"
6960
+ // }
6961
+ //
6962
+ // fetchFundingRate: publicMixGetV2MixMarketFundingTime
6914
6963
  //
6915
6964
  // {
6916
6965
  // "symbol": "BTCUSDT",
6917
- // "fundingRate": "-0.000182"
6966
+ // "nextFundingTime": "1745424000000",
6967
+ // "ratePeriod": "8"
6918
6968
  // }
6919
6969
  //
6920
6970
  // fetchFundingInterval
@@ -6924,7 +6974,9 @@ class bitget extends bitget$1 {
6924
6974
  // "nextFundingTime": "1727942400000",
6925
6975
  // "ratePeriod": "8"
6926
6976
  // }
6977
+ //
6927
6978
  // fetchFundingRates
6979
+ //
6928
6980
  // {
6929
6981
  // "symbol": "BTCUSD",
6930
6982
  // "lastPr": "29904.5",
@@ -6950,10 +7002,11 @@ class bitget extends bitget$1 {
6950
7002
  // "open24h": "0",
6951
7003
  // "markPrice": "12345"
6952
7004
  // }
7005
+ //
6953
7006
  const marketId = this.safeString(contract, 'symbol');
6954
7007
  const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
6955
- const fundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
6956
- const interval = this.safeString(contract, 'ratePeriod');
7008
+ const fundingTimestamp = this.safeInteger2(contract, 'nextFundingTime', 'nextUpdate');
7009
+ const interval = this.safeString2(contract, 'ratePeriod', 'fundingRateInterval');
6957
7010
  const timestamp = this.safeInteger(contract, 'ts');
6958
7011
  const markPrice = this.safeNumber(contract, 'markPrice');
6959
7012
  const indexPrice = this.safeNumber(contract, 'indexPrice');
@@ -206,6 +206,7 @@ class bitmart extends bitmart$1 {
206
206
  'contract/private/order': 1.2,
207
207
  'contract/private/order-history': 10,
208
208
  'contract/private/position': 10,
209
+ 'contract/private/position-v2': 10,
209
210
  'contract/private/get-open-orders': 1.2,
210
211
  'contract/private/current-plan-order': 1.2,
211
212
  'contract/private/trades': 10,
@@ -1203,6 +1204,7 @@ class bitmart extends bitmart$1 {
1203
1204
  // {
1204
1205
  // "currency": "BTC",
1205
1206
  // "name": "Bitcoin",
1207
+ // "recharge_minsize": '0.00000001',
1206
1208
  // "contract_address": null,
1207
1209
  // "network": "BTC",
1208
1210
  // "withdraw_enabled": true,
@@ -1224,7 +1226,8 @@ class bitmart extends bitmart$1 {
1224
1226
  const fullId = this.safeString(currency, 'currency');
1225
1227
  let currencyId = fullId;
1226
1228
  let networkId = this.safeString(currency, 'network');
1227
- if (fullId.indexOf('NFT') < 0) {
1229
+ const isNtf = (fullId.indexOf('NFT') >= 0);
1230
+ if (!isNtf) {
1228
1231
  const parts = fullId.split('-');
1229
1232
  currencyId = this.safeString(parts, 0);
1230
1233
  const second = this.safeString(parts, 1);
@@ -1245,6 +1248,7 @@ class bitmart extends bitmart$1 {
1245
1248
  'withdraw': undefined,
1246
1249
  'active': undefined,
1247
1250
  'networks': {},
1251
+ 'type': isNtf ? 'other' : 'crypto',
1248
1252
  };
1249
1253
  }
1250
1254
  const networkCode = this.networkIdToCode(networkId);
@@ -4896,6 +4900,7 @@ class bitmart extends bitmart$1 {
4896
4900
  * @name bitmart#fetchPositions
4897
4901
  * @description fetch all open contract positions
4898
4902
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-keyed
4903
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-v2-keyed
4899
4904
  * @param {string[]|undefined} symbols list of unified market symbols
4900
4905
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4901
4906
  * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -4914,7 +4919,7 @@ class bitmart extends bitmart$1 {
4914
4919
  // only supports symbols as undefined or sending one symbol
4915
4920
  request['symbol'] = market['id'];
4916
4921
  }
4917
- const response = await this.privateGetContractPrivatePosition(this.extend(request, params));
4922
+ const response = await this.privateGetContractPrivatePositionV2(this.extend(request, params));
4918
4923
  //
4919
4924
  // {
4920
4925
  // "code": 1000,
@@ -495,6 +495,7 @@ class bitmex extends bitmex$1 {
495
495
  const maxWithdrawal = this.parseNumber(Precise["default"].stringMul(maxWithdrawalString, precisionString));
496
496
  const minDepositString = this.safeString(currency, 'minDepositAmount');
497
497
  const minDeposit = this.parseNumber(Precise["default"].stringMul(minDepositString, precisionString));
498
+ const isCrypto = this.safeString(currency, 'currencyType') === 'Crypto';
498
499
  result[code] = {
499
500
  'id': id,
500
501
  'code': code,
@@ -520,6 +521,7 @@ class bitmex extends bitmex$1 {
520
521
  },
521
522
  },
522
523
  'networks': networks,
524
+ 'type': isCrypto ? 'crypto' : 'other',
523
525
  };
524
526
  }
525
527
  return result;
@@ -728,11 +730,11 @@ class bitmex extends bitmex$1 {
728
730
  const quote = this.safeCurrencyCode(quoteId);
729
731
  const contract = swap || future;
730
732
  let contractSize = undefined;
731
- const isInverse = this.safeValue(market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC
732
- const isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
733
- const linear = contract ? (!isInverse && !isQuanto) : undefined;
733
+ let isInverse = this.safeValue(market, 'isInverse'); // this is true when BASE and SETTLE are same, i.e. BTC/XXX:BTC
734
+ let isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
735
+ let linear = contract ? (!isInverse && !isQuanto) : undefined;
734
736
  const status = this.safeString(market, 'state');
735
- const active = status !== 'Unlisted';
737
+ const active = status === 'Open'; // Open, Settled, Unlisted
736
738
  let expiry = undefined;
737
739
  let expiryDatetime = undefined;
738
740
  let symbol = undefined;
@@ -749,9 +751,9 @@ class bitmex extends bitmex$1 {
749
751
  const multiplierString = Precise["default"].stringAbs(this.safeString(market, 'multiplier'));
750
752
  contractSize = this.parseNumber(multiplierString);
751
753
  }
752
- if (future) {
753
- expiryDatetime = this.safeString(market, 'expiry');
754
- expiry = this.parse8601(expiryDatetime);
754
+ expiryDatetime = this.safeString(market, 'expiry');
755
+ expiry = this.parse8601(expiryDatetime);
756
+ if (expiry !== undefined) {
755
757
  symbol = symbol + '-' + this.yymmdd(expiry);
756
758
  }
757
759
  }
@@ -765,6 +767,12 @@ class bitmex extends bitmex$1 {
765
767
  const maxOrderQty = this.safeNumber(market, 'maxOrderQty');
766
768
  const initMargin = this.safeString(market, 'initMargin', '1');
767
769
  const maxLeverage = this.parseNumber(Precise["default"].stringDiv('1', initMargin));
770
+ // subtype should be undefined for spot markets
771
+ if (spot) {
772
+ isInverse = undefined;
773
+ isQuanto = undefined;
774
+ linear = undefined;
775
+ }
768
776
  return {
769
777
  'id': id,
770
778
  'symbol': symbol,
@@ -814,7 +822,7 @@ class bitmex extends bitmex$1 {
814
822
  'max': positionIsQuote ? maxOrderQty : undefined,
815
823
  },
816
824
  },
817
- 'created': this.parse8601(this.safeString(market, 'listing')),
825
+ 'created': undefined,
818
826
  'info': market,
819
827
  };
820
828
  }