ccxt 4.4.75 → 4.4.78

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 (114) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +8 -4
  4. package/dist/cjs/src/abstract/apex.js +9 -0
  5. package/dist/cjs/src/apex.js +1949 -0
  6. package/dist/cjs/src/base/Exchange.js +49 -3
  7. package/dist/cjs/src/binance.js +44 -220
  8. package/dist/cjs/src/bitget.js +139 -71
  9. package/dist/cjs/src/bitmex.js +4 -4
  10. package/dist/cjs/src/bitrue.js +48 -0
  11. package/dist/cjs/src/cex.js +1 -1
  12. package/dist/cjs/src/coinbase.js +32 -3
  13. package/dist/cjs/src/coincatch.js +68 -0
  14. package/dist/cjs/src/coinex.js +3 -0
  15. package/dist/cjs/src/coinlist.js +85 -1
  16. package/dist/cjs/src/hitbtc.js +3 -0
  17. package/dist/cjs/src/hyperliquid.js +13 -4
  18. package/dist/cjs/src/mexc.js +50 -57
  19. package/dist/cjs/src/okx.js +23 -8
  20. package/dist/cjs/src/paradex.js +3 -12
  21. package/dist/cjs/src/phemex.js +2 -1
  22. package/dist/cjs/src/poloniex.js +1 -1
  23. package/dist/cjs/src/pro/apex.js +1043 -0
  24. package/dist/cjs/src/pro/coinbase.js +4 -8
  25. package/dist/cjs/src/pro/gate.js +27 -2
  26. package/dist/cjs/src/pro/hollaex.js +2 -2
  27. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  28. package/dist/cjs/src/pro/p2b.js +2 -2
  29. package/dist/cjs/src/pro/tradeogre.js +283 -0
  30. package/dist/cjs/src/probit.js +1 -0
  31. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2645 -0
  32. package/dist/cjs/src/tradeogre.js +2 -1
  33. package/dist/cjs/src/upbit.js +299 -93
  34. package/dist/cjs/src/whitebit.js +1 -0
  35. package/dist/cjs/src/woo.js +3 -1
  36. package/dist/cjs/src/xt.js +131 -4
  37. package/js/ccxt.d.ts +11 -5
  38. package/js/ccxt.js +8 -4
  39. package/js/src/abstract/apex.d.ts +34 -0
  40. package/js/src/abstract/myokx.d.ts +4 -0
  41. package/js/src/abstract/okx.d.ts +4 -0
  42. package/js/src/abstract/upbit.d.ts +15 -1
  43. package/js/src/abstract/xt.d.ts +3 -0
  44. package/js/src/apex.d.ts +333 -0
  45. package/js/src/apex.js +1951 -0
  46. package/js/src/ascendex.d.ts +3 -3
  47. package/js/src/base/Exchange.d.ts +3 -0
  48. package/js/src/base/Exchange.js +49 -2
  49. package/js/src/binance.d.ts +9 -7
  50. package/js/src/binance.js +44 -220
  51. package/js/src/bitfinex.d.ts +3 -3
  52. package/js/src/bitflyer.d.ts +2 -2
  53. package/js/src/bitget.d.ts +2 -0
  54. package/js/src/bitget.js +139 -71
  55. package/js/src/bitmart.d.ts +4 -4
  56. package/js/src/bitmex.d.ts +3 -3
  57. package/js/src/bitmex.js +4 -4
  58. package/js/src/bitrue.js +48 -0
  59. package/js/src/cex.js +1 -1
  60. package/js/src/coinbase.d.ts +6 -4
  61. package/js/src/coinbase.js +32 -3
  62. package/js/src/coinbaseexchange.d.ts +1 -1
  63. package/js/src/coincatch.d.ts +11 -0
  64. package/js/src/coincatch.js +68 -0
  65. package/js/src/coinex.js +3 -0
  66. package/js/src/coinlist.d.ts +12 -1
  67. package/js/src/coinlist.js +85 -1
  68. package/js/src/cryptocom.d.ts +4 -4
  69. package/js/src/deribit.d.ts +4 -4
  70. package/js/src/derive.d.ts +3 -3
  71. package/js/src/digifinex.d.ts +4 -4
  72. package/js/src/hitbtc.js +3 -0
  73. package/js/src/htx.d.ts +4 -4
  74. package/js/src/hyperliquid.d.ts +1 -0
  75. package/js/src/hyperliquid.js +13 -4
  76. package/js/src/kraken.d.ts +3 -3
  77. package/js/src/krakenfutures.d.ts +2 -2
  78. package/js/src/kucoinfutures.d.ts +5 -5
  79. package/js/src/mexc.d.ts +1 -0
  80. package/js/src/mexc.js +50 -57
  81. package/js/src/okx.js +23 -8
  82. package/js/src/oxfun.d.ts +3 -3
  83. package/js/src/paradex.js +3 -12
  84. package/js/src/phemex.d.ts +3 -3
  85. package/js/src/phemex.js +2 -1
  86. package/js/src/poloniex.d.ts +3 -3
  87. package/js/src/poloniex.js +1 -1
  88. package/js/src/pro/apex.d.ts +160 -0
  89. package/js/src/pro/apex.js +1044 -0
  90. package/js/src/pro/coinbase.js +4 -8
  91. package/js/src/pro/gate.js +27 -2
  92. package/js/src/pro/hollaex.js +2 -2
  93. package/js/src/pro/hyperliquid.js +1 -1
  94. package/js/src/pro/p2b.js +2 -2
  95. package/js/src/pro/tradeogre.d.ts +49 -0
  96. package/js/src/pro/tradeogre.js +284 -0
  97. package/js/src/probit.js +1 -0
  98. package/js/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  99. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  100. package/js/src/tradeogre.js +2 -1
  101. package/js/src/upbit.d.ts +34 -4
  102. package/js/src/upbit.js +299 -93
  103. package/js/src/vertex.d.ts +3 -3
  104. package/js/src/whitebit.js +1 -0
  105. package/js/src/woo.d.ts +4 -4
  106. package/js/src/woo.js +3 -1
  107. package/js/src/woofipro.d.ts +4 -4
  108. package/js/src/xt.d.ts +23 -4
  109. package/js/src/xt.js +131 -4
  110. package/package.json +2 -2
  111. package/js/src/abstract/ace.d.ts +0 -18
  112. package/js/src/ace.d.ts +0 -158
  113. package/js/src/ace.js +0 -1181
  114. /package/js/src/abstract/{ace.js → apex.js} +0 -0
package/js/src/bitget.js CHANGED
@@ -1374,28 +1374,44 @@ export default class bitget extends Exchange {
1374
1374
  'fillResponseFromRequest': true,
1375
1375
  },
1376
1376
  'fetchOHLCV': {
1377
- 'spot': {
1378
- 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1379
- },
1380
- 'swap': {
1381
- 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1382
- },
1383
- 'maxDaysPerTimeframe': {
1377
+ // ### Timeframe settings ###
1378
+ // after testing, the below values are real ones, because the values provided by API DOCS are wrong
1379
+ // so, start timestamp should be within these thresholds to be able to call "recent" candles endpoint
1380
+ 'maxRecentDaysPerTimeframe': {
1384
1381
  '1m': 30,
1385
1382
  '3m': 30,
1386
1383
  '5m': 30,
1387
- '10m': 30,
1388
- '15m': 52,
1389
- '30m': 62,
1390
- '1h': 83,
1391
- '2h': 120,
1384
+ '15m': 30,
1385
+ '30m': 30,
1386
+ '1h': 60,
1392
1387
  '4h': 240,
1393
1388
  '6h': 360,
1394
- '12h': 360,
1395
- '1d': 300,
1396
- '3d': 300,
1397
- '1w': 300,
1398
- '1M': 300,
1389
+ '12h': 720,
1390
+ '1d': 1440,
1391
+ '3d': 1440 * 3,
1392
+ '1w': 1440 * 7,
1393
+ '1M': 1440 * 30,
1394
+ },
1395
+ 'spot': {
1396
+ 'maxLimitPerTimeframe': {
1397
+ '1d': 300,
1398
+ '3d': 100,
1399
+ '1w': 100,
1400
+ '1M': 100,
1401
+ },
1402
+ 'method': 'publicSpotGetV2SpotMarketCandles', // publicSpotGetV2SpotMarketCandles or publicSpotGetV2SpotMarketHistoryCandles
1403
+ },
1404
+ 'swap': {
1405
+ 'maxLimitPerTimeframe': {
1406
+ '4h': 540,
1407
+ '6h': 360,
1408
+ '12h': 180,
1409
+ '1d': 90,
1410
+ '3d': 30,
1411
+ '1w': 13,
1412
+ '1M': 4,
1413
+ },
1414
+ 'method': 'publicMixGetV2MixMarketCandles', // publicMixGetV2MixMarketCandles or publicMixGetV2MixMarketHistoryCandles or publicMixGetV2MixMarketHistoryIndexCandles or publicMixGetV2MixMarketHistoryMarkCandles
1399
1415
  },
1400
1416
  },
1401
1417
  'fetchTrades': {
@@ -1406,6 +1422,9 @@ export default class bitget extends Exchange {
1406
1422
  'method': 'publicMixGetV2MixMarketFillsHistory', // or publicMixGetV2MixMarketFills
1407
1423
  },
1408
1424
  },
1425
+ 'fetchFundingRate': {
1426
+ 'method': 'publicMixGetV2MixMarketCurrentFundRate', // or publicMixGetV2MixMarketFundingTime
1427
+ },
1409
1428
  'accountsByType': {
1410
1429
  'spot': 'spot',
1411
1430
  'cross': 'crossed_margin',
@@ -1602,7 +1621,7 @@ export default class bitget extends Exchange {
1602
1621
  'symbolRequired': false,
1603
1622
  },
1604
1623
  'fetchOHLCV': {
1605
- 'limit': 1000, // variable timespans for recent endpoint, 200 for historical
1624
+ 'limit': 200, // variable timespans for recent endpoint, 200 for historical
1606
1625
  },
1607
1626
  },
1608
1627
  'forPerps': {
@@ -1677,13 +1696,12 @@ export default class bitget extends Exchange {
1677
1696
  let defaultProductType = undefined;
1678
1697
  if ((subType !== undefined) && (market === undefined)) {
1679
1698
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
1680
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1681
- if (sandboxMode) {
1682
- defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1683
- }
1684
- else {
1685
- defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1686
- }
1699
+ // const sandboxMode = this.safeBool (this.options, 'sandboxMode', false);
1700
+ // if (sandboxMode) {
1701
+ // defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1702
+ // } else {
1703
+ defaultProductType = (subType === 'linear') ? 'USDT-FUTURES' : 'COIN-FUTURES';
1704
+ // }
1687
1705
  }
1688
1706
  let productType = this.safeString(params, 'productType', defaultProductType);
1689
1707
  if ((productType === undefined) && (market !== undefined)) {
@@ -3287,7 +3305,7 @@ export default class bitget extends Exchange {
3287
3305
  }
3288
3306
  }
3289
3307
  else {
3290
- request['businessType'] = 'contract';
3308
+ request['businessType'] = 'mix';
3291
3309
  }
3292
3310
  const response = await this.privateCommonGetV2CommonTradeRate(this.extend(request, params));
3293
3311
  //
@@ -3492,34 +3510,36 @@ export default class bitget extends Exchange {
3492
3510
  const market = this.market(symbol);
3493
3511
  const marketType = market['spot'] ? 'spot' : 'swap';
3494
3512
  const timeframes = this.options['timeframes'][marketType];
3495
- const msInDay = 86400000;
3496
- const duration = this.parseTimeframe(timeframe) * 1000;
3497
3513
  const request = {
3498
3514
  'symbol': market['id'],
3499
3515
  'granularity': this.safeString(timeframes, timeframe, timeframe),
3500
3516
  };
3517
+ const msInDay = 86400000;
3518
+ const now = this.milliseconds();
3519
+ const duration = this.parseTimeframe(timeframe) * 1000;
3501
3520
  const until = this.safeInteger(params, 'until');
3502
3521
  const limitDefined = limit !== undefined;
3503
3522
  const sinceDefined = since !== undefined;
3504
3523
  const untilDefined = until !== undefined;
3505
3524
  params = this.omit(params, ['until']);
3506
- let response = undefined;
3507
- const now = this.milliseconds();
3508
3525
  // retrievable periods listed here:
3509
3526
  // - https://www.bitget.com/api-doc/spot/market/Get-Candle-Data#request-parameters
3510
3527
  // - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
3511
- const ohlcOptions = this.safeDict(this.options, 'fetchOHLCV', {});
3512
- const retrievableDaysMap = this.safeDict(ohlcOptions, 'maxDaysPerTimeframe', {});
3513
- const maxRetrievableDaysForRecent = this.safeInteger(retrievableDaysMap, timeframe, 30); // default to safe minimum
3514
- const endpointTsBoundary = now - (maxRetrievableDaysForRecent - 1) * msInDay;
3528
+ const key = market['spot'] ? 'spot' : 'swap';
3529
+ const ohlcOptions = this.safeDict(this.options['fetchOHLCV'], key, {});
3530
+ const maxLimitPerTimeframe = this.safeDict(ohlcOptions, 'maxLimitPerTimeframe', {});
3531
+ const maxLimitForThisTimeframe = this.safeInteger(maxLimitPerTimeframe, timeframe, limit);
3532
+ const recentEndpointDaysMap = this.safeDict(this.options['fetchOHLCV'], 'maxRecentDaysPerTimeframe', {});
3533
+ const recentEndpointAvailableDays = this.safeInteger(recentEndpointDaysMap, timeframe);
3534
+ const recentEndpointBoundaryTs = now - (recentEndpointAvailableDays - 1) * msInDay;
3515
3535
  if (limitDefined) {
3516
3536
  limit = Math.min(limit, maxLimitForRecentEndpoint);
3517
- request['limit'] = limit;
3537
+ limit = Math.min(limit, maxLimitForThisTimeframe);
3518
3538
  }
3519
3539
  else {
3520
3540
  limit = defaultLimit;
3521
3541
  }
3522
- const limitMultipliedDuration = limit * duration;
3542
+ let limitMultipliedDuration = limit * duration;
3523
3543
  // exchange aligns from endTime, so it's important, not startTime
3524
3544
  // startTime is supported only on "recent" endpoint, not on "historical" endpoint
3525
3545
  let calculatedStartTime = undefined;
@@ -3540,17 +3560,32 @@ export default class bitget extends Exchange {
3540
3560
  // we do not need to set "startTime" here
3541
3561
  }
3542
3562
  }
3543
- const historicalEndpointNeeded = (calculatedStartTime !== undefined) && (calculatedStartTime <= endpointTsBoundary);
3544
- if (historicalEndpointNeeded) {
3563
+ // if historical endpoint is needed, we should re-set the variables
3564
+ let historicalEndpointNeeded = false;
3565
+ if ((calculatedStartTime !== undefined && calculatedStartTime <= recentEndpointBoundaryTs) || useHistoryEndpoint) {
3566
+ historicalEndpointNeeded = true;
3545
3567
  // only for "historical-candles" - ensure we use correct max limit
3546
- if (limitDefined) {
3547
- request['limit'] = Math.min(limit, maxLimitForHistoryEndpoint);
3568
+ limit = Math.min(limit, maxLimitForHistoryEndpoint);
3569
+ limitMultipliedDuration = limit * duration;
3570
+ calculatedStartTime = calculatedEndTime - limitMultipliedDuration;
3571
+ request['startTime'] = calculatedStartTime;
3572
+ // for contract, maximum 90 days allowed between start-end times
3573
+ if (!market['spot']) {
3574
+ const maxDistanceDaysForContracts = 90;
3575
+ // only correct if request is larger
3576
+ if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3577
+ calculatedEndTime = this.sum(calculatedStartTime, maxDistanceDaysForContracts * msInDay);
3578
+ request['endTime'] = calculatedEndTime;
3579
+ }
3548
3580
  }
3549
3581
  }
3582
+ // we need to set limit to safely cover the period
3583
+ request['limit'] = limit;
3550
3584
  // make request
3585
+ let response = undefined;
3551
3586
  if (market['spot']) {
3552
3587
  // checks if we need history endpoint
3553
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3588
+ if (historicalEndpointNeeded) {
3554
3589
  response = await this.publicSpotGetV2SpotMarketHistoryCandles(this.extend(request, params));
3555
3590
  }
3556
3591
  else {
@@ -3558,16 +3593,6 @@ export default class bitget extends Exchange {
3558
3593
  }
3559
3594
  }
3560
3595
  else {
3561
- const maxDistanceDaysForContracts = 90; // for contract, maximum 90 days allowed between start-end times
3562
- // only correct the request to fix 90 days if until was auto-calculated
3563
- if (sinceDefined) {
3564
- if (!untilDefined) {
3565
- request['endTime'] = Math.min(calculatedEndTime, this.sum(since, maxDistanceDaysForContracts * msInDay));
3566
- }
3567
- else if (calculatedEndTime - calculatedStartTime > maxDistanceDaysForContracts * msInDay) {
3568
- throw new BadRequest(this.id + ' fetchOHLCV() between start and end must be less than ' + maxDistanceDaysForContracts.toString() + ' days');
3569
- }
3570
- }
3571
3596
  let priceType = undefined;
3572
3597
  [priceType, params] = this.handleParamString(params, 'price');
3573
3598
  let productType = undefined;
@@ -3582,7 +3607,7 @@ export default class bitget extends Exchange {
3582
3607
  response = await this.publicMixGetV2MixMarketHistoryIndexCandles(extended);
3583
3608
  }
3584
3609
  else {
3585
- if (historicalEndpointNeeded || useHistoryEndpoint) {
3610
+ if (historicalEndpointNeeded) {
3586
3611
  response = await this.publicMixGetV2MixMarketHistoryCandles(extended);
3587
3612
  }
3588
3613
  else {
@@ -6819,8 +6844,10 @@ export default class bitget extends Exchange {
6819
6844
  * @name bitget#fetchFundingRate
6820
6845
  * @description fetch the current funding rate
6821
6846
  * @see https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
6847
+ * @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
6822
6848
  * @param {string} symbol unified market symbol
6823
6849
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6850
+ * @param {string} [params.method] either (default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
6824
6851
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
6825
6852
  */
6826
6853
  async fetchFundingRate(symbol, params = {}) {
@@ -6835,21 +6862,47 @@ export default class bitget extends Exchange {
6835
6862
  'symbol': market['id'],
6836
6863
  'productType': productType,
6837
6864
  };
6838
- const response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6839
- //
6840
- // {
6841
- // "code": "00000",
6842
- // "msg": "success",
6843
- // "requestTime": 1700811542124,
6844
- // "data": [
6845
- // {
6846
- // "symbol": "BTCUSDT",
6847
- // "fundingRate": "0.000106"
6848
- // }
6849
- // ]
6850
- // }
6851
- //
6852
- const data = this.safeValue(response, 'data', []);
6865
+ let method = undefined;
6866
+ [method, params] = this.handleOptionAndParams(params, 'fetchFundingRate', 'method', 'publicMixGetV2MixMarketCurrentFundRate');
6867
+ let response = undefined;
6868
+ if (method === 'publicMixGetV2MixMarketCurrentFundRate') {
6869
+ response = await this.publicMixGetV2MixMarketCurrentFundRate(this.extend(request, params));
6870
+ //
6871
+ // {
6872
+ // "code": "00000",
6873
+ // "msg": "success",
6874
+ // "requestTime": 1745500709429,
6875
+ // "data": [
6876
+ // {
6877
+ // "symbol": "BTCUSDT",
6878
+ // "fundingRate": "-0.000013",
6879
+ // "fundingRateInterval": "8",
6880
+ // "nextUpdate": "1745510400000",
6881
+ // "minFundingRate": "-0.003",
6882
+ // "maxFundingRate": "0.003"
6883
+ // }
6884
+ // ]
6885
+ // }
6886
+ //
6887
+ }
6888
+ else if (method === 'publicMixGetV2MixMarketFundingTime') {
6889
+ response = await this.publicMixGetV2MixMarketFundingTime(this.extend(request, params));
6890
+ //
6891
+ // {
6892
+ // "code": "00000",
6893
+ // "msg": "success",
6894
+ // "requestTime": 1745402092428,
6895
+ // "data": [
6896
+ // {
6897
+ // "symbol": "BTCUSDT",
6898
+ // "nextFundingTime": "1745424000000",
6899
+ // "ratePeriod": "8"
6900
+ // }
6901
+ // ]
6902
+ // }
6903
+ //
6904
+ }
6905
+ const data = this.safeList(response, 'data', []);
6853
6906
  return this.parseFundingRate(data[0], market);
6854
6907
  }
6855
6908
  /**
@@ -6913,11 +6966,23 @@ export default class bitget extends Exchange {
6913
6966
  }
6914
6967
  parseFundingRate(contract, market = undefined) {
6915
6968
  //
6916
- // fetchFundingRate
6969
+ // fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate
6917
6970
  //
6918
6971
  // {
6919
6972
  // "symbol": "BTCUSDT",
6920
- // "fundingRate": "-0.000182"
6973
+ // "fundingRate": "-0.000013",
6974
+ // "fundingRateInterval": "8",
6975
+ // "nextUpdate": "1745510400000",
6976
+ // "minFundingRate": "-0.003",
6977
+ // "maxFundingRate": "0.003"
6978
+ // }
6979
+ //
6980
+ // fetchFundingRate: publicMixGetV2MixMarketFundingTime
6981
+ //
6982
+ // {
6983
+ // "symbol": "BTCUSDT",
6984
+ // "nextFundingTime": "1745424000000",
6985
+ // "ratePeriod": "8"
6921
6986
  // }
6922
6987
  //
6923
6988
  // fetchFundingInterval
@@ -6927,7 +6992,9 @@ export default class bitget extends Exchange {
6927
6992
  // "nextFundingTime": "1727942400000",
6928
6993
  // "ratePeriod": "8"
6929
6994
  // }
6995
+ //
6930
6996
  // fetchFundingRates
6997
+ //
6931
6998
  // {
6932
6999
  // "symbol": "BTCUSD",
6933
7000
  // "lastPr": "29904.5",
@@ -6953,10 +7020,11 @@ export default class bitget extends Exchange {
6953
7020
  // "open24h": "0",
6954
7021
  // "markPrice": "12345"
6955
7022
  // }
7023
+ //
6956
7024
  const marketId = this.safeString(contract, 'symbol');
6957
7025
  const symbol = this.safeSymbol(marketId, market, undefined, 'swap');
6958
- const fundingTimestamp = this.safeInteger(contract, 'nextFundingTime');
6959
- const interval = this.safeString(contract, 'ratePeriod');
7026
+ const fundingTimestamp = this.safeInteger2(contract, 'nextFundingTime', 'nextUpdate');
7027
+ const interval = this.safeString2(contract, 'ratePeriod', 'fundingRateInterval');
6960
7028
  const timestamp = this.safeInteger(contract, 'ts');
6961
7029
  const markPrice = this.safeNumber(contract, 'markPrice');
6962
7030
  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,7 +601,7 @@ 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
@@ -611,8 +611,8 @@ export default class bitmart extends Exchange {
611
611
  * @param {object} [params] extra parameters specific to the exchange API endpoint
612
612
  * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
613
613
  */
614
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
615
- parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
614
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
615
+ parsePosition(position: Dict, market?: Market): Position;
616
616
  /**
617
617
  * @method
618
618
  * @name bitmart#fetchMyLiquidations
@@ -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
package/js/src/bitmex.js CHANGED
@@ -735,7 +735,7 @@ export default class bitmex extends Exchange {
735
735
  const isQuanto = this.safeValue(market, 'isQuanto'); // this is true when BASE and SETTLE are different, i.e. AXS/XXX:BTC
736
736
  const linear = contract ? (!isInverse && !isQuanto) : undefined;
737
737
  const status = this.safeString(market, 'state');
738
- const active = status !== 'Unlisted';
738
+ const active = status === 'Open'; // Open, Settled, Unlisted
739
739
  let expiry = undefined;
740
740
  let expiryDatetime = undefined;
741
741
  let symbol = undefined;
@@ -752,9 +752,9 @@ export default class bitmex extends Exchange {
752
752
  const multiplierString = Precise.stringAbs(this.safeString(market, 'multiplier'));
753
753
  contractSize = this.parseNumber(multiplierString);
754
754
  }
755
- if (future) {
756
- expiryDatetime = this.safeString(market, 'expiry');
757
- expiry = this.parse8601(expiryDatetime);
755
+ expiryDatetime = this.safeString(market, 'expiry');
756
+ expiry = this.parse8601(expiryDatetime);
757
+ if (expiry !== undefined) {
758
758
  symbol = symbol + '-' + this.yymmdd(expiry);
759
759
  }
760
760
  }
package/js/src/bitrue.js CHANGED
@@ -33,20 +33,32 @@ export default class bitrue extends Exchange {
33
33
  'swap': true,
34
34
  'future': false,
35
35
  'option': false,
36
+ 'addMargin': false,
37
+ 'borrowCrossMargin': false,
38
+ 'borrowIsolatedMargin': false,
39
+ 'borrowMargin': false,
36
40
  'cancelAllOrders': true,
37
41
  'cancelOrder': true,
42
+ 'closeAllPositions': false,
43
+ 'closePosition': false,
38
44
  'createMarketBuyOrderWithCost': true,
39
45
  'createMarketOrderWithCost': false,
40
46
  'createMarketSellOrderWithCost': false,
41
47
  'createOrder': true,
48
+ 'createOrderWithTakeProfitAndStopLoss': false,
49
+ 'createOrderWithTakeProfitAndStopLossWs': false,
42
50
  'createReduceOnlyOrder': true,
43
51
  'createStopLimitOrder': true,
44
52
  'createStopMarketOrder': true,
45
53
  'createStopOrder': true,
46
54
  'fetchBalance': true,
47
55
  'fetchBidsAsks': true,
56
+ 'fetchBorrowInterest': false,
57
+ 'fetchBorrowRate': false,
48
58
  'fetchBorrowRateHistories': false,
49
59
  'fetchBorrowRateHistory': false,
60
+ 'fetchBorrowRates': false,
61
+ 'fetchBorrowRatesPerSymbol': false,
50
62
  'fetchClosedOrders': true,
51
63
  'fetchCrossBorrowRate': false,
52
64
  'fetchCrossBorrowRates': false,
@@ -57,20 +69,50 @@ export default class bitrue extends Exchange {
57
69
  'fetchDepositWithdrawFee': 'emulated',
58
70
  'fetchDepositWithdrawFees': true,
59
71
  'fetchFundingHistory': false,
72
+ 'fetchFundingInterval': false,
73
+ 'fetchFundingIntervals': false,
60
74
  'fetchFundingRate': false,
61
75
  'fetchFundingRateHistory': false,
62
76
  'fetchFundingRates': false,
77
+ 'fetchGreeks': false,
78
+ 'fetchIndexOHLCV': false,
63
79
  'fetchIsolatedBorrowRate': false,
64
80
  'fetchIsolatedBorrowRates': false,
81
+ 'fetchIsolatedPositions': false,
82
+ 'fetchLeverage': false,
83
+ 'fetchLeverages': false,
84
+ 'fetchLeverageTiers': false,
85
+ 'fetchLiquidations': false,
86
+ 'fetchLongShortRatio': false,
87
+ 'fetchLongShortRatioHistory': false,
88
+ 'fetchMarginAdjustmentHistory': false,
65
89
  'fetchMarginMode': false,
90
+ 'fetchMarginModes': false,
91
+ 'fetchMarketLeverageTiers': false,
66
92
  'fetchMarkets': true,
93
+ 'fetchMarkOHLCV': false,
94
+ 'fetchMarkPrices': false,
95
+ 'fetchMyLiquidations': false,
96
+ 'fetchMySettlementHistory': false,
67
97
  'fetchMyTrades': true,
68
98
  'fetchOHLCV': true,
99
+ 'fetchOpenInterest': false,
100
+ 'fetchOpenInterestHistory': false,
101
+ 'fetchOpenInterests': false,
69
102
  'fetchOpenOrders': true,
103
+ 'fetchOption': false,
104
+ 'fetchOptionChain': false,
70
105
  'fetchOrder': true,
71
106
  'fetchOrderBook': true,
72
107
  'fetchOrders': false,
108
+ 'fetchPosition': false,
109
+ 'fetchPositionHistory': false,
73
110
  'fetchPositionMode': false,
111
+ 'fetchPositions': false,
112
+ 'fetchPositionsHistory': false,
113
+ 'fetchPositionsRisk': false,
114
+ 'fetchPremiumIndexOHLCV': false,
115
+ 'fetchSettlementHistory': false,
74
116
  'fetchStatus': true,
75
117
  'fetchTicker': true,
76
118
  'fetchTickers': true,
@@ -81,9 +123,15 @@ export default class bitrue extends Exchange {
81
123
  'fetchTransactionFees': false,
82
124
  'fetchTransactions': false,
83
125
  'fetchTransfers': true,
126
+ 'fetchVolatilityHistory': false,
84
127
  'fetchWithdrawals': true,
128
+ 'reduceMargin': false,
129
+ 'repayCrossMargin': false,
130
+ 'repayIsolatedMargin': false,
85
131
  'setLeverage': true,
86
132
  'setMargin': true,
133
+ 'setMarginMode': false,
134
+ 'setPositionMode': false,
87
135
  'transfer': true,
88
136
  'withdraw': true,
89
137
  },
package/js/src/cex.js CHANGED
@@ -553,7 +553,7 @@ export default class cex extends Exchange {
553
553
  'askVolume': undefined,
554
554
  'vwap': undefined,
555
555
  'open': undefined,
556
- 'close': this.safeString(ticker, 'lastTradePrice'),
556
+ 'close': this.safeString(ticker, 'last'),
557
557
  'previousClose': undefined,
558
558
  'change': this.safeNumber(ticker, 'priceChange'),
559
559
  'percentage': this.safeNumber(ticker, 'priceChangePercentage'),
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinbase.js';
2
- import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int, TradingFees, LedgerEntry, DepositAddress } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Order, Trade, OHLCV, Ticker, OrderBook, Str, Transaction, Balances, Tickers, Strings, Market, Currency, Num, Account, Currencies, MarketInterface, Conversion, Dict, int, TradingFees, LedgerEntry, DepositAddress, Position } from './base/types.js';
3
3
  /**
4
4
  * @class coinbase
5
5
  * @augments Exchange
@@ -136,6 +136,8 @@ export default class coinbase extends Exchange {
136
136
  fetchMarkets(params?: {}): Promise<Market[]>;
137
137
  fetchMarketsV2(params?: {}): Promise<Market[]>;
138
138
  fetchMarketsV3(params?: {}): Promise<Market[]>;
139
+ market(symbol: string): MarketInterface;
140
+ safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
139
141
  parseSpotMarket(market: any, feeTier: any): MarketInterface;
140
142
  parseContractMarket(market: any, feeTier: any): MarketInterface;
141
143
  fetchCurrenciesFromCache(params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
@@ -575,7 +577,7 @@ export default class coinbase extends Exchange {
575
577
  * @param {string} [params.portfolio] the portfolio UUID to fetch positions for
576
578
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
577
579
  */
578
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
580
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
579
581
  /**
580
582
  * @method
581
583
  * @name coinbase#fetchPosition
@@ -588,8 +590,8 @@ export default class coinbase extends Exchange {
588
590
  * @param {string} [params.portfolio] *perpetual/swaps only* the portfolio UUID to fetch the position for, required for perpetual/swaps markets only
589
591
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
590
592
  */
591
- fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
592
- parsePosition(position: Dict, market?: Market): import("./base/types.js").Position;
593
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
594
+ parsePosition(position: Dict, market?: Market): Position;
593
595
  /**
594
596
  * @method
595
597
  * @name coinbase#fetchTradingFees
@@ -378,7 +378,8 @@ export default class coinbase extends Exchange {
378
378
  'fetchAccounts': 'fetchAccountsV3',
379
379
  'fetchBalance': 'v2PrivateGetAccounts',
380
380
  'fetchTime': 'v2PublicGetTime',
381
- 'user_native_currency': 'USD', // needed to get fees for v3
381
+ 'user_native_currency': 'USD',
382
+ 'aliasCbMarketIds': {},
382
383
  },
383
384
  'features': {
384
385
  'default': {
@@ -1512,7 +1513,33 @@ export default class coinbase extends Exchange {
1512
1513
  for (let i = 0; i < perpetualData.length; i++) {
1513
1514
  result.push(this.parseContractMarket(perpetualData[i], perpetualFeeTier));
1514
1515
  }
1515
- return result;
1516
+ // remove aliases
1517
+ this.options['aliasCbMarketIds'] = {};
1518
+ const newMarkets = [];
1519
+ for (let i = 0; i < result.length; i++) {
1520
+ const market = result[i];
1521
+ const info = this.safeValue(market, 'info', {});
1522
+ const realMarketIds = this.safeList(info, 'alias_to', []);
1523
+ const length = realMarketIds.length;
1524
+ if (length > 0) {
1525
+ this.options['aliasCbMarketIds'][market['id']] = realMarketIds[0];
1526
+ this.options['aliasCbMarketIds'][market['symbol']] = realMarketIds[0];
1527
+ }
1528
+ else {
1529
+ newMarkets.push(market);
1530
+ }
1531
+ }
1532
+ return newMarkets;
1533
+ }
1534
+ market(symbol) {
1535
+ const finalSymbol = this.safeString(this.options['aliasCbMarketIds'], symbol, symbol);
1536
+ return super.market(finalSymbol);
1537
+ }
1538
+ safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
1539
+ if (marketId in this.options['aliasCbMarketIds']) {
1540
+ return this.market(marketId);
1541
+ }
1542
+ return super.safeMarket(marketId, market, delimiter, marketType);
1516
1543
  }
1517
1544
  parseSpotMarket(market, feeTier) {
1518
1545
  //
@@ -1924,6 +1951,7 @@ export default class coinbase extends Exchange {
1924
1951
  'withdraw': undefined,
1925
1952
  'fee': undefined,
1926
1953
  'precision': undefined,
1954
+ 'networks': {},
1927
1955
  'limits': {
1928
1956
  'amount': {
1929
1957
  'min': this.safeNumber(currency, 'min_size'),
@@ -2248,10 +2276,11 @@ export default class coinbase extends Exchange {
2248
2276
  askVolume = this.safeNumber(asks[0], 'size');
2249
2277
  }
2250
2278
  const marketId = this.safeString(ticker, 'product_id');
2279
+ market = this.safeMarket(marketId, market);
2251
2280
  const last = this.safeNumber(ticker, 'price');
2252
2281
  const datetime = this.safeString(ticker, 'time');
2253
2282
  return this.safeTicker({
2254
- 'symbol': this.safeSymbol(marketId, market),
2283
+ 'symbol': market['symbol'],
2255
2284
  'timestamp': this.parse8601(datetime),
2256
2285
  'datetime': datetime,
2257
2286
  'bid': bid,
@@ -311,7 +311,7 @@ export default class coinbaseexchange extends Exchange {
311
311
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
312
312
  */
313
313
  fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
314
- parseTransactionStatus(transaction: any): "canceled" | "pending" | "ok" | "failed";
314
+ parseTransactionStatus(transaction: any): "pending" | "ok" | "failed" | "canceled";
315
315
  parseTransaction(transaction: Dict, currency?: Currency): Transaction;
316
316
  /**
317
317
  * @method