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
package/js/src/bitget.js CHANGED
@@ -1368,28 +1368,44 @@ export default class bitget extends Exchange {
1368
1368
  'fillResponseFromRequest': true,
1369
1369
  },
1370
1370
  'fetchOHLCV': {
1371
- 'spot': {
1372
- 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1373
- },
1374
- 'swap': {
1375
- 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1376
- },
1377
- 'maxDaysPerTimeframe': {
1371
+ // ### Timeframe settings ###
1372
+ // after testing, the below values are real ones, because the values provided by API DOCS are wrong
1373
+ // so, start timestamp should be within these thresholds to be able to call "recent" candles endpoint
1374
+ 'maxRecentDaysPerTimeframe': {
1378
1375
  '1m': 30,
1379
1376
  '3m': 30,
1380
1377
  '5m': 30,
1381
- '10m': 30,
1382
- '15m': 52,
1383
- '30m': 62,
1384
- '1h': 83,
1385
- '2h': 120,
1378
+ '15m': 30,
1379
+ '30m': 30,
1380
+ '1h': 60,
1386
1381
  '4h': 240,
1387
1382
  '6h': 360,
1388
- '12h': 360,
1389
- '1d': 300,
1390
- '3d': 300,
1391
- '1w': 300,
1392
- '1M': 300,
1383
+ '12h': 720,
1384
+ '1d': 1440,
1385
+ '3d': 1440 * 3,
1386
+ '1w': 1440 * 7,
1387
+ '1M': 1440 * 30,
1388
+ },
1389
+ 'spot': {
1390
+ 'maxLimitPerTimeframe': {
1391
+ '1d': 300,
1392
+ '3d': 100,
1393
+ '1w': 100,
1394
+ '1M': 100,
1395
+ },
1396
+ 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1397
+ },
1398
+ 'swap': {
1399
+ 'maxLimitPerTimeframe': {
1400
+ '4h': 540,
1401
+ '6h': 360,
1402
+ '12h': 180,
1403
+ '1d': 90,
1404
+ '3d': 30,
1405
+ '1w': 13,
1406
+ '1M': 4,
1407
+ },
1408
+ 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1393
1409
  },
1394
1410
  },
1395
1411
  'fetchTrades': {
@@ -1400,6 +1416,9 @@ export default class bitget extends Exchange {
1400
1416
  'method': 'publicMixGetV2MixMarketFillsHistory', // or publicMixGetV2MixMarketFills
1401
1417
  },
1402
1418
  },
1419
+ 'fetchFundingRate': {
1420
+ 'method': 'publicMixGetV2MixMarketCurrentFundRate', // or publicMixGetV2MixMarketFundingTime
1421
+ },
1403
1422
  'accountsByType': {
1404
1423
  'spot': 'spot',
1405
1424
  'cross': 'crossed_margin',
@@ -1521,7 +1540,9 @@ export default class bitget extends Exchange {
1521
1540
  'fetchPositions': {
1522
1541
  'method': 'privateMixGetV2MixPositionAllPosition', // or privateMixGetV2MixPositionHistoryPosition
1523
1542
  },
1524
- 'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
1543
+ 'defaultTimeInForce': 'GTC',
1544
+ // fiat currencies on deposit page
1545
+ 'fiatCurrencies': ['EUR', 'VND', 'PLN', 'CZK', 'HUF', 'DKK', 'AUD', 'CAD', 'NOK', 'SEK', 'CHF', 'MXN', 'COP', 'ARS', 'GBP', 'BRL', 'UAH', 'ZAR'],
1525
1546
  },
1526
1547
  'features': {
1527
1548
  'spot': {
@@ -1596,7 +1617,7 @@ export default class bitget extends Exchange {
1596
1617
  'symbolRequired': false,
1597
1618
  },
1598
1619
  'fetchOHLCV': {
1599
- 'limit': 1000, // variable timespans for recent endpoint, 200 for historical
1620
+ 'limit': 200, // variable timespans for recent endpoint, 200 for historical
1600
1621
  },
1601
1622
  },
1602
1623
  'forPerps': {
@@ -1671,13 +1692,12 @@ export default class bitget extends Exchange {
1671
1692
  let defaultProductType = undefined;
1672
1693
  if ((subType !== undefined) && (market === undefined)) {
1673
1694
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
1674
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1675
- if (sandboxMode) {
1676
- defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1677
- }
1678
- else {
1679
- defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1680
- }
1695
+ // const sandboxMode = this.safeBool (this.options, 'sandboxMode', false);
1696
+ // if (sandboxMode) {
1697
+ // defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1698
+ // } else {
1699
+ defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1700
+ // }
1681
1701
  }
1682
1702
  let productType = this.safeString(params, 'productType', defaultProductType);
1683
1703
  if ((productType === undefined) && (market !== undefined)) {
@@ -2009,47 +2029,47 @@ export default class bitget extends Exchange {
2009
2029
  async fetchCurrencies(params = {}) {
2010
2030
  const response = await this.publicSpotGetV2SpotPublicCoins(params);
2011
2031
  //
2012
- // {
2013
- // "code": "00000",
2014
- // "data": [
2015
- // {
2016
- // "chains": [
2017
- // {
2018
- // "browserUrl": "https://blockchair.com/bitcoin/transaction/",
2019
- // "chain": "BTC",
2020
- // "depositConfirm": "1",
2021
- // "extraWithdrawFee": "0",
2022
- // "minDepositAmount": "0.0001",
2023
- // "minWithdrawAmount": "0.005",
2024
- // "needTag": "false",
2025
- // "rechargeable": "true",
2026
- // "withdrawConfirm": "1",
2027
- // "withdrawFee": "0.0004",
2028
- // "withdrawable": "true"
2029
- // },
2030
- // ],
2031
- // "coin": "BTC",
2032
- // "coinId": "1",
2033
- // "transfer": "true""
2034
- // }
2035
- // ],
2036
- // "msg": "success",
2037
- // "requestTime": "1700120731773"
2038
- // }
2032
+ // {
2033
+ // "code": "00000",
2034
+ // "msg": "success",
2035
+ // "requestTime": "1746195617812",
2036
+ // "data": [
2037
+ // {
2038
+ // "coinId": "1456",
2039
+ // "coin": "NEIROETH",
2040
+ // "transfer": "false",
2041
+ // "chains": [
2042
+ // {
2043
+ // "chain": "ERC20",
2044
+ // "needTag": "false",
2045
+ // "withdrawable": "true",
2046
+ // "rechargeable": "true",
2047
+ // "withdrawFee": "44.91017965",
2048
+ // "extraWithdrawFee": "0",
2049
+ // "depositConfirm": "12",
2050
+ // "withdrawConfirm": "64",
2051
+ // "minDepositAmount": "0.06",
2052
+ // "minWithdrawAmount": "60",
2053
+ // "browserUrl": "https://etherscan.io/tx/",
2054
+ // "contractAddress": "0xee2a03aa6dacf51c18679c516ad5283d8e7c2637",
2055
+ // "withdrawStep": "0",
2056
+ // "withdrawMinScale": "8",
2057
+ // "congestion": "normal"
2058
+ // }
2059
+ // ],
2060
+ // "areaCoin": "no"
2061
+ // },
2062
+ // ...
2039
2063
  //
2040
2064
  const result = {};
2041
2065
  const data = this.safeValue(response, 'data', []);
2066
+ const fiatCurrencies = this.safeList(this.options, 'fiatCurrencies', []);
2042
2067
  for (let i = 0; i < data.length; i++) {
2043
2068
  const entry = data[i];
2044
2069
  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..)
2045
2070
  const code = this.safeCurrencyCode(id);
2046
2071
  const chains = this.safeValue(entry, 'chains', []);
2047
2072
  const networks = {};
2048
- let deposit = false;
2049
- let withdraw = false;
2050
- let minWithdrawString = undefined;
2051
- let minDepositString = undefined;
2052
- let minWithdrawFeeString = undefined;
2053
2073
  for (let j = 0; j < chains.length; j++) {
2054
2074
  const chain = chains[j];
2055
2075
  const networkId = this.safeString(chain, 'chain');
@@ -2057,56 +2077,39 @@ export default class bitget extends Exchange {
2057
2077
  if (network !== undefined) {
2058
2078
  network = network.toUpperCase();
2059
2079
  }
2060
- const withdrawEnabled = this.safeString(chain, 'withdrawable');
2061
- const canWithdraw = withdrawEnabled === 'true';
2062
- withdraw = (canWithdraw) ? canWithdraw : withdraw;
2063
- const depositEnabled = this.safeString(chain, 'rechargeable');
2064
- const canDeposit = depositEnabled === 'true';
2065
- deposit = (canDeposit) ? canDeposit : deposit;
2066
- const networkWithdrawFeeString = this.safeString(chain, 'withdrawFee');
2067
- if (networkWithdrawFeeString !== undefined) {
2068
- minWithdrawFeeString = (minWithdrawFeeString === undefined) ? networkWithdrawFeeString : Precise.stringMin(networkWithdrawFeeString, minWithdrawFeeString);
2069
- }
2070
- const networkMinWithdrawString = this.safeString(chain, 'minWithdrawAmount');
2071
- if (networkMinWithdrawString !== undefined) {
2072
- minWithdrawString = (minWithdrawString === undefined) ? networkMinWithdrawString : Precise.stringMin(networkMinWithdrawString, minWithdrawString);
2073
- }
2074
- const networkMinDepositString = this.safeString(chain, 'minDepositAmount');
2075
- if (networkMinDepositString !== undefined) {
2076
- minDepositString = (minDepositString === undefined) ? networkMinDepositString : Precise.stringMin(networkMinDepositString, minDepositString);
2077
- }
2078
2080
  networks[network] = {
2079
2081
  'info': chain,
2080
2082
  'id': networkId,
2081
2083
  'network': network,
2082
2084
  'limits': {
2083
2085
  'withdraw': {
2084
- 'min': this.parseNumber(networkMinWithdrawString),
2086
+ 'min': this.safeNumber(chain, 'minWithdrawAmount'),
2085
2087
  'max': undefined,
2086
2088
  },
2087
2089
  'deposit': {
2088
- 'min': this.parseNumber(networkMinDepositString),
2090
+ 'min': this.safeNumber(chain, 'minDepositAmount'),
2089
2091
  'max': undefined,
2090
2092
  },
2091
2093
  },
2092
- 'active': canWithdraw && canDeposit,
2093
- 'withdraw': canWithdraw,
2094
- 'deposit': canDeposit,
2095
- 'fee': this.parseNumber(networkWithdrawFeeString),
2096
- 'precision': undefined,
2094
+ 'active': undefined,
2095
+ 'withdraw': this.safeString(chain, 'withdrawable') === 'true',
2096
+ 'deposit': this.safeString(chain, 'rechargeable') === 'true',
2097
+ 'fee': this.safeNumber(chain, 'withdrawFee'),
2098
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'withdrawMinScale'))),
2097
2099
  };
2098
2100
  }
2099
- result[code] = {
2101
+ const isFiat = this.inArray(code, fiatCurrencies);
2102
+ result[code] = this.safeCurrencyStructure({
2100
2103
  'info': entry,
2101
2104
  'id': id,
2102
2105
  'code': code,
2103
2106
  'networks': networks,
2104
- 'type': undefined,
2107
+ 'type': isFiat ? 'fiat' : 'crypto',
2105
2108
  'name': undefined,
2106
- 'active': deposit && withdraw,
2107
- 'deposit': deposit,
2108
- 'withdraw': withdraw,
2109
- 'fee': this.parseNumber(minWithdrawFeeString),
2109
+ 'active': undefined,
2110
+ 'deposit': undefined,
2111
+ 'withdraw': undefined,
2112
+ 'fee': undefined,
2110
2113
  'precision': undefined,
2111
2114
  'limits': {
2112
2115
  'amount': {
@@ -2114,16 +2117,16 @@ export default class bitget extends Exchange {
2114
2117
  'max': undefined,
2115
2118
  },
2116
2119
  'withdraw': {
2117
- 'min': this.parseNumber(minWithdrawString),
2120
+ 'min': undefined,
2118
2121
  'max': undefined,
2119
2122
  },
2120
2123
  'deposit': {
2121
- 'min': this.parseNumber(minDepositString),
2124
+ 'min': undefined,
2122
2125
  'max': undefined,
2123
2126
  },
2124
2127
  },
2125
2128
  'created': undefined,
2126
- };
2129
+ });
2127
2130
  }
2128
2131
  return result;
2129
2132
  }
@@ -2768,7 +2771,7 @@ export default class bitget extends Exchange {
2768
2771
  const close = this.safeString(ticker, 'lastPr');
2769
2772
  const timestamp = this.safeIntegerOmitZero(ticker, 'ts'); // exchange bitget provided 0
2770
2773
  const change = this.safeString(ticker, 'change24h');
2771
- const open24 = this.safeString(ticker, 'open24');
2774
+ const open24 = this.safeString2(ticker, 'open24', 'open24h');
2772
2775
  const open = this.safeString(ticker, 'open');
2773
2776
  let symbol;
2774
2777
  let openValue;
@@ -3486,34 +3489,36 @@ export default class bitget extends Exchange {
3486
3489
  const market = this.market(symbol);
3487
3490
  const marketType = market['spot'] ? 'spot' : 'swap';
3488
3491
  const timeframes = this.options['timeframes'][marketType];
3489
- const msInDay = 86400000;
3490
- const duration = this.parseTimeframe(timeframe) * 1000;
3491
3492
  const request = {
3492
3493
  'symbol': market['id'],
3493
3494
  'granularity': this.safeString(timeframes, timeframe, timeframe),
3494
3495
  };
3496
+ const msInDay = 86400000;
3497
+ const now = this.milliseconds();
3498
+ const duration = this.parseTimeframe(timeframe) * 1000;
3495
3499
  const until = this.safeInteger(params, 'until');
3496
3500
  const limitDefined = limit !== undefined;
3497
3501
  const sinceDefined = since !== undefined;
3498
3502
  const untilDefined = until !== undefined;
3499
3503
  params = this.omit(params, ['until']);
3500
- let response = undefined;
3501
- const now = this.milliseconds();
3502
3504
  // retrievable periods listed here:
3503
3505
  // - https://www.bitget.com/api-doc/spot/market/Get-Candle-Data#request-parameters
3504
3506
  // - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
3505
- const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
3506
- const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
3507
- const maxRetrievableDaysForRecent = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
3508
- const endpointTsBoundary = now - (maxRetrievableDaysForRecent - 1) * msInDay;
3507
+ const key = market['spot'] ? 'spot' : 'swap';
3508
+ const ohlcOptions = this.safeDict(this.options['fetchOHLCV'], key, {});
3509
+ const maxLimitPerTimeframe = this.safeDict(ohlcOptions, 'maxLimitPerTimeframe', {});
3510
+ const maxLimitForThisTimeframe = this.safeInteger(maxLimitPerTimeframe, timeframe, limit);
3511
+ const recentEndpointDaysMap = this.safeDict(this.options['fetchOHLCV'], 'maxRecentDaysPerTimeframe', {});
3512
+ const recentEndpointAvailableDays = this.safeInteger(recentEndpointDaysMap, timeframe);
3513
+ const recentEndpointBoundaryTs = now - (recentEndpointAvailableDays - 1) * msInDay;
3509
3514
  if (limitDefined) {
3510
3515
  limit = Math.min(limit, maxLimitForRecentEndpoint);
3511
- request['limit'] = limit;
3516
+ limit = Math.min(limit, maxLimitForThisTimeframe);
3512
3517
  }
3513
3518
  else {
3514
3519
  limit = defaultLimit;
3515
3520
  }
3516
- const limitMultipliedDuration = limit * duration;
3521
+ let limitMultipliedDuration = limit * duration;
3517
3522
  // exchange aligns from endTime, so it's important, not startTime
3518
3523
  // startTime is supported only on "recent" endpoint, not on "historical" endpoint
3519
3524
  let calculatedStartTime = undefined;
@@ -3534,17 +3539,32 @@ export default class bitget extends Exchange {
3534
3539
  // we do not need to set "startTime" here
3535
3540
  }
3536
3541
  }
3537
- const historicalEndpointNeeded = (calculatedStartTime !== undefined) && (calculatedStartTime <= endpointTsBoundary);
3538
- if (historicalEndpointNeeded) {
3542
+ // if historical endpoint is needed, we should re-set the variables
3543
+ let historicalEndpointNeeded = false;
3544
+ if ((calculatedStartTime !== undefined && calculatedStartTime <= recentEndpointBoundaryTs) || useHistoryEndpoint) {
3545
+ historicalEndpointNeeded = true;
3539
3546
  // only for "historical-candles" - ensure we use correct max limit
3540
- if (limitDefined) {
3541
- request['limit'] = Math.min(limit, maxLimitForHistoryEndpoint);
3547
+ limit = Math.min(limit, maxLimitForHistoryEndpoint);
3548
+ limitMultipliedDuration = limit * duration;
3549
+ calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
3550
+ request['startTime'] = calculatedStartTime;
3551
+ // for contract, maximum 90 days allowed between start-end times
3552
+ if (!market['spot']) {
3553
+ const maxDistanceDaysForContracts = 90;
3554
+ // only correct if request is larger
3555
+ if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3556
+ calculatedEndTime = this.sum(calculatedStartTime, maxDistanceDaysForContracts * msInDay);
3557
+ request['endTime'] = calculatedEndTime;
3558
+ }
3542
3559
  }
3543
3560
  }
3561
+ // we need to set limit to safely cover the period
3562
+ request['limit'] = limit;
3544
3563
  // make request
3564
+ let response = undefined;
3545
3565
  if (market['spot']) {
3546
3566
  // checks if we need history endpoint
3547
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3567
+ if (historicalEndpointNeeded) {
3548
3568
  response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
3549
3569
  }
3550
3570
  else {
@@ -3552,16 +3572,6 @@ export default class bitget extends Exchange {
3552
3572
  }
3553
3573
  }
3554
3574
  else {
3555
- const maxDistanceDaysForContracts = 90; // for contract, maximum 90 days allowed between start-end times
3556
- // only correct the request to fix 90 days if until was auto-calculated
3557
- if (sinceDefined) {
3558
- if (!untilDefined) {
3559
- request['endTime'] = Math.min(calculatedEndTime, this.sum(since, maxDistanceDaysForContracts * msInDay));
3560
- }
3561
- else if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3562
- throw new BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
3563
- }
3564
- }
3565
3575
  let priceType = undefined;
3566
3576
  [priceType, params] = this.handleParamString(params, 'price');
3567
3577
  let productType = undefined;
@@ -3576,7 +3586,7 @@ export default class bitget extends Exchange {
3576
3586
  response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
3577
3587
  }
3578
3588
  else {
3579
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3589
+ if (historicalEndpointNeeded) {
3580
3590
  response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
3581
3591
  }
3582
3592
  else {
@@ -6813,8 +6823,10 @@ export default class bitget extends Exchange {
6813
6823
  * @name bitget#fetchFundingRate
6814
6824
  * @description fetch the current funding rate
6815
6825
  * @see https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
6826
+ * @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
6816
6827
  * @param {string} symbol unified market symbol
6817
6828
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6829
+ * @param {string} [params.method] either (default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
6818
6830
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
6819
6831
  */
6820
6832
  async fetchFundingRate(symbol, params = {}) {
@@ -6829,21 +6841,47 @@ export default class bitget extends Exchange {
6829
6841
  'symbol': market['id'],
6830
6842
  'productType': productType,
6831
6843
  };
6832
- const response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6833
- //
6834
- // {
6835
- // "code": "00000",
6836
- // "msg": "success",
6837
- // "requestTime": 1700811542124,
6838
- // "data": [
6839
- // {
6840
- // "symbol": "BTCUSDT",
6841
- // "fundingRate": "0.000106"
6842
- // }
6843
- // ]
6844
- // }
6845
- //
6846
- const data = this.safeValue(response, 'data', []);
6844
+ let method = undefined;
6845
+ [method, params] = this.handleOptionAndParams(params, 'fetchFundingRate', 'method', 'publicMixGetV2MixMarketCurrentFundRate');
6846
+ let response = undefined;
6847
+ if (method === 'publicMixGetV2MixMarketCurrentFundRate') {
6848
+ response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6849
+ //
6850
+ // {
6851
+ // "code": "00000",
6852
+ // "msg": "success",
6853
+ // "requestTime": 1745500709429,
6854
+ // "data": [
6855
+ // {
6856
+ // "symbol": "BTCUSDT",
6857
+ // "fundingRate": "-0.000013",
6858
+ // "fundingRateInterval": "8",
6859
+ // "nextUpdate": "1745510400000",
6860
+ // "minFundingRate": "-0.003",
6861
+ // "maxFundingRate": "0.003"
6862
+ // }
6863
+ // ]
6864
+ // }
6865
+ //
6866
+ }
6867
+ else if (method === 'publicMixGetV2MixMarketFundingTime') {
6868
+ response = await this.publicMixGetV2MixMarketFundingTime(this.extend(request, params));
6869
+ //
6870
+ // {
6871
+ // "code": "00000",
6872
+ // "msg": "success",
6873
+ // "requestTime": 1745402092428,
6874
+ // "data": [
6875
+ // {
6876
+ // "symbol": "BTCUSDT",
6877
+ // "nextFundingTime": "1745424000000",
6878
+ // "ratePeriod": "8"
6879
+ // }
6880
+ // ]
6881
+ // }
6882
+ //
6883
+ }
6884
+ const data = this.safeList(response, 'data', []);
6847
6885
  return this.parseFundingRate(data[0], market);
6848
6886
  }
6849
6887
  /**
@@ -6907,11 +6945,23 @@ export default class bitget extends Exchange {
6907
6945
  }
6908
6946
  parseFundingRate(contract, market = undefined) {
6909
6947
  //
6910
- // fetchFundingRate
6948
+ // fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate
6949
+ //
6950
+ // {
6951
+ // "symbol": "BTCUSDT",
6952
+ // "fundingRate": "-0.000013",
6953
+ // "fundingRateInterval": "8",
6954
+ // "nextUpdate": "1745510400000",
6955
+ // "minFundingRate": "-0.003",
6956
+ // "maxFundingRate": "0.003"
6957
+ // }
6958
+ //
6959
+ // fetchFundingRate: publicMixGetV2MixMarketFundingTime
6911
6960
  //
6912
6961
  // {
6913
6962
  // "symbol": "BTCUSDT",
6914
- // "fundingRate": "-0.000182"
6963
+ // "nextFundingTime": "1745424000000",
6964
+ // "ratePeriod": "8"
6915
6965
  // }
6916
6966
  //
6917
6967
  // fetchFundingInterval
@@ -6921,7 +6971,9 @@ export default class bitget extends Exchange {
6921
6971
  // "nextFundingTime": "1727942400000",
6922
6972
  // "ratePeriod": "8"
6923
6973
  // }
6974
+ //
6924
6975
  // fetchFundingRates
6976
+ //
6925
6977
  // {
6926
6978
  // "symbol": "BTCUSD",
6927
6979
  // "lastPr": "29904.5",
@@ -6947,10 +6999,11 @@ export default class bitget extends Exchange {
6947
6999
  // "open24h": "0",
6948
7000
  // "markPrice": "12345"
6949
7001
  // }
7002
+ //
6950
7003
  const marketId = this.safeString(contract, 'symbol');
6951
7004
  const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
6952
- const fundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
6953
- const interval = this.safeString(contract, 'ratePeriod');
7005
+ const fundingTimestamp = this.safeInteger2(contract, 'nextFundingTime', 'nextUpdate');
7006
+ const interval = this.safeString2(contract, 'ratePeriod', 'fundingRateInterval');
6954
7007
  const timestamp = this.safeInteger(contract, 'ts');
6955
7008
  const markPrice = this.safeNumber(contract, 'markPrice');
6956
7009
  const indexPrice = this.safeNumber(contract, 'indexPrice');
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmart.js';
2
- import type { Int, OrderSide, Balances, OrderType, OHLCV, Order, Str, Trade, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, IsolatedBorrowRates, IsolatedBorrowRate, Dict, OrderRequest, int, FundingRate, DepositAddress, BorrowInterest, MarketInterface, FundingRateHistory, FundingHistory, LedgerEntry } from './base/types.js';
2
+ import type { Int, OrderSide, Balances, OrderType, OHLCV, Order, Str, Trade, Transaction, Ticker, OrderBook, Tickers, Strings, Currency, Market, TransferEntry, Num, TradingFeeInterface, Currencies, IsolatedBorrowRates, IsolatedBorrowRate, Dict, OrderRequest, int, FundingRate, DepositAddress, BorrowInterest, MarketInterface, FundingRateHistory, FundingHistory, LedgerEntry, Position } from './base/types.js';
3
3
  /**
4
4
  * @class bitmart
5
5
  * @augments Exchange
@@ -601,18 +601,19 @@ export default class bitmart extends Exchange {
601
601
  * @param {object} [params] extra parameters specific to the exchange API endpoint
602
602
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
603
603
  */
604
- fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
604
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
605
605
  /**
606
606
  * @method
607
607
  * @name bitmart#fetchPositions
608
608
  * @description fetch all open contract positions
609
609
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-keyed
610
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-v2-keyed
610
611
  * @param {string[]|undefined} symbols list of unified market symbols
611
612
  * @param {object} [params] extra parameters specific to the exchange API endpoint
612
613
  * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
613
614
  */
614
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
615
- parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
615
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
616
+ parsePosition(position: Dict, market?: Market): Position;
616
617
  /**
617
618
  * @method
618
619
  * @name bitmart#fetchMyLiquidations
package/js/src/bitmart.js CHANGED
@@ -203,6 +203,7 @@ export default class bitmart extends Exchange {
203
203
  'contract/private/order': 1.2,
204
204
  'contract/private/order-history': 10,
205
205
  'contract/private/position': 10,
206
+ 'contract/private/position-v2': 10,
206
207
  'contract/private/get-open-orders': 1.2,
207
208
  'contract/private/current-plan-order': 1.2,
208
209
  'contract/private/trades': 10,
@@ -1200,6 +1201,7 @@ export default class bitmart extends Exchange {
1200
1201
  // {
1201
1202
  // "currency": "BTC",
1202
1203
  // "name": "Bitcoin",
1204
+ // "recharge_minsize": '0.00000001',
1203
1205
  // "contract_address": null,
1204
1206
  // "network": "BTC",
1205
1207
  // "withdraw_enabled": true,
@@ -1221,7 +1223,8 @@ export default class bitmart extends Exchange {
1221
1223
  const fullId = this.safeString(currency, 'currency');
1222
1224
  let currencyId = fullId;
1223
1225
  let networkId = this.safeString(currency, 'network');
1224
- if (fullId.indexOf('NFT') < 0) {
1226
+ const isNtf = (fullId.indexOf('NFT') >= 0);
1227
+ if (!isNtf) {
1225
1228
  const parts = fullId.split('-');
1226
1229
  currencyId = this.safeString(parts, 0);
1227
1230
  const second = this.safeString(parts, 1);
@@ -1242,6 +1245,7 @@ export default class bitmart extends Exchange {
1242
1245
  'withdraw': undefined,
1243
1246
  'active': undefined,
1244
1247
  'networks': {},
1248
+ 'type': isNtf ? 'other' : 'crypto',
1245
1249
  };
1246
1250
  }
1247
1251
  const networkCode = this.networkIdToCode(networkId);
@@ -4893,6 +4897,7 @@ export default class bitmart extends Exchange {
4893
4897
  * @name bitmart#fetchPositions
4894
4898
  * @description fetch all open contract positions
4895
4899
  * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-keyed
4900
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#get-current-position-v2-keyed
4896
4901
  * @param {string[]|undefined} symbols list of unified market symbols
4897
4902
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4898
4903
  * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
@@ -4911,7 +4916,7 @@ export default class bitmart extends Exchange {
4911
4916
  // only supports symbols as undefined or sending one symbol
4912
4917
  request['symbol'] = market['id'];
4913
4918
  }
4914
- const response = await this.privateGetContractPrivatePosition(this.extend(request, params));
4919
+ const response = await this.privateGetContractPrivatePositionV2(this.extend(request, params));
4915
4920
  //
4916
4921
  // {
4917
4922
  // "code": 1000,
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmex.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Dict, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages, Num, Currencies, int, LedgerEntry, FundingRate, FundingRates, DepositAddress } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Dict, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages, Num, Currencies, int, LedgerEntry, FundingRate, FundingRates, DepositAddress, Position } from './base/types.js';
3
3
  /**
4
4
  * @class bitmex
5
5
  * @augments Exchange
@@ -274,8 +274,8 @@ export default class bitmex extends Exchange {
274
274
  * @param {object} [params] extra parameters specific to the exchange API endpoint
275
275
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
276
276
  */
277
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
278
- parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
277
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
278
+ parsePosition(position: Dict, market?: Market): Position;
279
279
  /**
280
280
  * @method
281
281
  * @name bitmex#withdraw