ccxt 4.4.21 → 4.4.23

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 (86) hide show
  1. package/README.md +112 -111
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +6 -1
  4. package/dist/cjs/src/abstract/coincatch.js +9 -0
  5. package/dist/cjs/src/alpaca.js +1 -0
  6. package/dist/cjs/src/base/Exchange.js +21 -0
  7. package/dist/cjs/src/bigone.js +3 -0
  8. package/dist/cjs/src/binance.js +172 -44
  9. package/dist/cjs/src/bitfinex.js +4 -0
  10. package/dist/cjs/src/bitflyer.js +58 -0
  11. package/dist/cjs/src/bitget.js +77 -0
  12. package/dist/cjs/src/bitrue.js +3 -0
  13. package/dist/cjs/src/bybit.js +80 -2
  14. package/dist/cjs/src/cex.js +1307 -1381
  15. package/dist/cjs/src/coinbase.js +1 -1
  16. package/dist/cjs/src/coinbaseexchange.js +3 -0
  17. package/dist/cjs/src/coincatch.js +5370 -0
  18. package/dist/cjs/src/coinex.js +63 -1
  19. package/dist/cjs/src/cryptocom.js +1 -1
  20. package/dist/cjs/src/gate.js +103 -3
  21. package/dist/cjs/src/htx.js +1 -7
  22. package/dist/cjs/src/hyperliquid.js +10 -8
  23. package/dist/cjs/src/kucoin.js +27 -59
  24. package/dist/cjs/src/latoken.js +6 -0
  25. package/dist/cjs/src/mexc.js +1 -1
  26. package/dist/cjs/src/oceanex.js +2 -0
  27. package/dist/cjs/src/okcoin.js +1 -0
  28. package/dist/cjs/src/okx.js +74 -0
  29. package/dist/cjs/src/poloniex.js +5 -0
  30. package/dist/cjs/src/pro/coincatch.js +1554 -0
  31. package/js/ccxt.d.ts +9 -3
  32. package/js/ccxt.js +6 -2
  33. package/js/src/abstract/binance.d.ts +21 -0
  34. package/js/src/abstract/binancecoinm.d.ts +21 -0
  35. package/js/src/abstract/binanceus.d.ts +21 -0
  36. package/js/src/abstract/binanceusdm.d.ts +21 -0
  37. package/js/src/abstract/bitflyer.d.ts +1 -0
  38. package/js/src/abstract/bitget.d.ts +3 -0
  39. package/js/src/abstract/cex.d.ts +28 -29
  40. package/js/src/abstract/coincatch.d.ts +97 -0
  41. package/js/src/abstract/coincatch.js +11 -0
  42. package/js/src/abstract/gate.d.ts +5 -0
  43. package/js/src/abstract/gateio.d.ts +5 -0
  44. package/js/src/abstract/kucoin.d.ts +1 -0
  45. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  46. package/js/src/abstract/okx.d.ts +1 -0
  47. package/js/src/alpaca.js +1 -0
  48. package/js/src/base/Exchange.d.ts +8 -2
  49. package/js/src/base/Exchange.js +21 -0
  50. package/js/src/base/types.d.ts +8 -0
  51. package/js/src/bigone.js +3 -0
  52. package/js/src/binance.d.ts +3 -1
  53. package/js/src/binance.js +172 -44
  54. package/js/src/bitfinex.js +4 -0
  55. package/js/src/bitflyer.d.ts +3 -1
  56. package/js/src/bitflyer.js +58 -0
  57. package/js/src/bitget.d.ts +3 -1
  58. package/js/src/bitget.js +77 -0
  59. package/js/src/bitrue.js +3 -0
  60. package/js/src/bybit.d.ts +3 -1
  61. package/js/src/bybit.js +80 -2
  62. package/js/src/cex.d.ts +34 -20
  63. package/js/src/cex.js +1308 -1382
  64. package/js/src/coinbase.js +1 -1
  65. package/js/src/coinbaseexchange.js +3 -0
  66. package/js/src/coincatch.d.ts +130 -0
  67. package/js/src/coincatch.js +5371 -0
  68. package/js/src/coinex.d.ts +1 -0
  69. package/js/src/coinex.js +63 -1
  70. package/js/src/cryptocom.js +1 -1
  71. package/js/src/gate.d.ts +2 -0
  72. package/js/src/gate.js +103 -3
  73. package/js/src/htx.js +1 -7
  74. package/js/src/hyperliquid.js +10 -8
  75. package/js/src/kucoin.d.ts +0 -1
  76. package/js/src/kucoin.js +27 -59
  77. package/js/src/latoken.js +6 -0
  78. package/js/src/mexc.js +1 -1
  79. package/js/src/oceanex.js +2 -0
  80. package/js/src/okcoin.js +1 -0
  81. package/js/src/okx.d.ts +3 -1
  82. package/js/src/okx.js +74 -0
  83. package/js/src/poloniex.js +5 -0
  84. package/js/src/pro/coincatch.d.ts +57 -0
  85. package/js/src/pro/coincatch.js +1555 -0
  86. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -53,6 +53,7 @@ var coinbase = require('./src/coinbase.js');
53
53
  var coinbaseadvanced = require('./src/coinbaseadvanced.js');
54
54
  var coinbaseexchange = require('./src/coinbaseexchange.js');
55
55
  var coinbaseinternational = require('./src/coinbaseinternational.js');
56
+ var coincatch = require('./src/coincatch.js');
56
57
  var coincheck = require('./src/coincheck.js');
57
58
  var coinex = require('./src/coinex.js');
58
59
  var coinlist = require('./src/coinlist.js');
@@ -148,6 +149,7 @@ var coinbase$1 = require('./src/pro/coinbase.js');
148
149
  var coinbaseadvanced$1 = require('./src/pro/coinbaseadvanced.js');
149
150
  var coinbaseexchange$1 = require('./src/pro/coinbaseexchange.js');
150
151
  var coinbaseinternational$1 = require('./src/pro/coinbaseinternational.js');
152
+ var coincatch$1 = require('./src/pro/coincatch.js');
151
153
  var coincheck$1 = require('./src/pro/coincheck.js');
152
154
  var coinex$1 = require('./src/pro/coinex.js');
153
155
  var coinone$1 = require('./src/pro/coinone.js');
@@ -195,7 +197,7 @@ var xt$1 = require('./src/pro/xt.js');
195
197
 
196
198
  //-----------------------------------------------------------------------------
197
199
  // this is updated by vss.js when building
198
- const version = '4.4.21';
200
+ const version = '4.4.23';
199
201
  Exchange["default"].ccxtVersion = version;
200
202
  const exchanges = {
201
203
  'ace': ace,
@@ -239,6 +241,7 @@ const exchanges = {
239
241
  'coinbaseadvanced': coinbaseadvanced,
240
242
  'coinbaseexchange': coinbaseexchange,
241
243
  'coinbaseinternational': coinbaseinternational,
244
+ 'coincatch': coincatch,
242
245
  'coincheck': coincheck,
243
246
  'coinex': coinex,
244
247
  'coinlist': coinlist,
@@ -336,6 +339,7 @@ const pro = {
336
339
  'coinbaseadvanced': coinbaseadvanced$1,
337
340
  'coinbaseexchange': coinbaseexchange$1,
338
341
  'coinbaseinternational': coinbaseinternational$1,
342
+ 'coincatch': coincatch$1,
339
343
  'coincheck': coincheck$1,
340
344
  'coinex': coinex$1,
341
345
  'coinone': coinone$1,
@@ -472,6 +476,7 @@ exports.coinbase = coinbase;
472
476
  exports.coinbaseadvanced = coinbaseadvanced;
473
477
  exports.coinbaseexchange = coinbaseexchange;
474
478
  exports.coinbaseinternational = coinbaseinternational;
479
+ exports.coincatch = coincatch;
475
480
  exports.coincheck = coincheck;
476
481
  exports.coinex = coinex;
477
482
  exports.coinlist = coinlist;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var Exchange$1 = require('../base/Exchange.js');
4
+
5
+ // -------------------------------------------------------------------------------
6
+ class Exchange extends Exchange$1["default"] {
7
+ }
8
+
9
+ module.exports = Exchange;
@@ -60,6 +60,7 @@ class alpaca extends alpaca$1 {
60
60
  'fetchDepositsWithdrawals': false,
61
61
  'fetchFundingHistory': false,
62
62
  'fetchFundingRate': false,
63
+ 'fetchFundingRateHistory': false,
63
64
  'fetchFundingRates': false,
64
65
  'fetchL1OrderBook': true,
65
66
  'fetchL2OrderBook': false,
@@ -1419,6 +1419,8 @@ class Exchange {
1419
1419
  'fetchLeverages': undefined,
1420
1420
  'fetchLeverageTiers': undefined,
1421
1421
  'fetchLiquidations': undefined,
1422
+ 'fetchLongShortRatio': undefined,
1423
+ 'fetchLongShortRatioHistory': undefined,
1422
1424
  'fetchMarginMode': undefined,
1423
1425
  'fetchMarginModes': undefined,
1424
1426
  'fetchMarketLeverageTiers': undefined,
@@ -2212,6 +2214,12 @@ class Exchange {
2212
2214
  async setMargin(symbol, amount, params = {}) {
2213
2215
  throw new errors.NotSupported(this.id + ' setMargin() is not supported yet');
2214
2216
  }
2217
+ async fetchLongShortRatio(symbol, timeframe = undefined, params = {}) {
2218
+ throw new errors.NotSupported(this.id + ' fetchLongShortRatio() is not supported yet');
2219
+ }
2220
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
2221
+ throw new errors.NotSupported(this.id + ' fetchLongShortRatioHistory() is not supported yet');
2222
+ }
2215
2223
  async fetchMarginAdjustmentHistory(symbol = undefined, type = undefined, since = undefined, limit = undefined, params = {}) {
2216
2224
  /**
2217
2225
  * @method
@@ -5572,6 +5580,19 @@ class Exchange {
5572
5580
  }
5573
5581
  return result;
5574
5582
  }
5583
+ parseLongShortRatio(info, market = undefined) {
5584
+ throw new errors.NotSupported(this.id + ' parseLongShortRatio() is not supported yet');
5585
+ }
5586
+ parseLongShortRatioHistory(response, market = undefined, since = undefined, limit = undefined) {
5587
+ const rates = [];
5588
+ for (let i = 0; i < response.length; i++) {
5589
+ const entry = response[i];
5590
+ rates.push(this.parseLongShortRatio(entry, market));
5591
+ }
5592
+ const sorted = this.sortBy(rates, 'timestamp');
5593
+ const symbol = (market === undefined) ? undefined : market['symbol'];
5594
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
5595
+ }
5575
5596
  handleTriggerAndParams(params) {
5576
5597
  const isTrigger = this.safeBool2(params, 'trigger', 'stop');
5577
5598
  if (isTrigger) {
@@ -45,7 +45,10 @@ class bigone extends bigone$1 {
45
45
  'fetchDepositAddresses': false,
46
46
  'fetchDepositAddressesByNetwork': false,
47
47
  'fetchDeposits': true,
48
+ 'fetchFundingHistory': false,
48
49
  'fetchFundingRate': false,
50
+ 'fetchFundingRateHistory': false,
51
+ 'fetchFundingRates': false,
49
52
  'fetchMarkets': true,
50
53
  'fetchMyTrades': true,
51
54
  'fetchOHLCV': true,
@@ -105,6 +105,8 @@ class binance extends binance$1 {
105
105
  'fetchLeverages': true,
106
106
  'fetchLeverageTiers': true,
107
107
  'fetchLiquidations': false,
108
+ 'fetchLongShortRatio': false,
109
+ 'fetchLongShortRatioHistory': true,
108
110
  'fetchMarginAdjustmentHistory': true,
109
111
  'fetchMarginMode': 'emulated',
110
112
  'fetchMarginModes': true,
@@ -469,6 +471,7 @@ class binance extends binance$1 {
469
471
  'portfolio/asset-index-price': 0.1,
470
472
  'portfolio/repay-futures-switch': 3,
471
473
  'portfolio/margin-asset-leverage': 5,
474
+ 'portfolio/balance': 2,
472
475
  // staking
473
476
  'staking/productList': 0.1,
474
477
  'staking/position': 0.1,
@@ -670,7 +673,8 @@ class binance extends binance$1 {
670
673
  'loan/flexible/repay/history': 40,
671
674
  'loan/flexible/ltv/adjustment/history': 40,
672
675
  'loan/flexible/loanable/data': 40,
673
- 'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
676
+ 'loan/flexible/collateral/data': 40,
677
+ 'portfolio/account': 2,
674
678
  },
675
679
  'post': {
676
680
  'eth-staking/eth/stake': 15,
@@ -748,6 +752,10 @@ class binance extends binance$1 {
748
752
  'commissionRate': 20,
749
753
  'income/asyn': 5,
750
754
  'income/asyn/id': 5,
755
+ 'trade/asyn': 0.5,
756
+ 'trade/asyn/id': 0.5,
757
+ 'order/asyn': 0.5,
758
+ 'order/asyn/id': 0.5,
751
759
  'pmExchangeInfo': 0.5,
752
760
  'pmAccountInfo': 0.5, // Weight(IP): 5 => cost = 0.1 * 5 = 0.5
753
761
  },
@@ -1026,8 +1034,12 @@ class binance extends binance$1 {
1026
1034
  },
1027
1035
  },
1028
1036
  'papi': {
1037
+ // IP (papi) request rate limit of 6000 per minute
1038
+ // 1 IP (papi) => cost = 0.2 => (1000 / (50 * 0.2)) * 60 = 6000
1039
+ // Order (papi) request rate limit of 1200 per minute
1040
+ // 1 Order (papi) => cost = 1 => (1000 / (50 * 1)) * 60 = 1200
1029
1041
  'get': {
1030
- 'ping': 1,
1042
+ 'ping': 0.2,
1031
1043
  'um/order': 1,
1032
1044
  'um/openOrder': 1,
1033
1045
  'um/openOrders': { 'cost': 1, 'noSymbol': 40 },
@@ -1039,72 +1051,87 @@ class binance extends binance$1 {
1039
1051
  'um/conditional/openOrder': 1,
1040
1052
  'um/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1041
1053
  'um/conditional/orderHistory': 1,
1042
- 'um/conditional/allOrders': 40,
1054
+ 'um/conditional/allOrders': { 'cost': 1, 'noSymbol': 40 },
1043
1055
  'cm/conditional/openOrder': 1,
1044
1056
  'cm/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1045
1057
  'cm/conditional/orderHistory': 1,
1046
1058
  'cm/conditional/allOrders': 40,
1047
- 'margin/order': 5,
1059
+ 'margin/order': 10,
1048
1060
  'margin/openOrders': 5,
1049
1061
  'margin/allOrders': 100,
1050
1062
  'margin/orderList': 5,
1051
1063
  'margin/allOrderList': 100,
1052
1064
  'margin/openOrderList': 5,
1053
1065
  'margin/myTrades': 5,
1054
- 'balance': 20,
1055
- 'account': 20,
1056
- 'margin/maxBorrowable': 5,
1057
- 'margin/maxWithdraw': 5,
1058
- 'um/positionRisk': 5,
1059
- 'cm/positionRisk': 1,
1060
- 'um/positionSide/dual': 30,
1061
- 'cm/positionSide/dual': 30,
1066
+ 'balance': 4,
1067
+ 'account': 4,
1068
+ 'margin/maxBorrowable': 1,
1069
+ 'margin/maxWithdraw': 1,
1070
+ 'um/positionRisk': 1,
1071
+ 'cm/positionRisk': 0.2,
1072
+ 'um/positionSide/dual': 6,
1073
+ 'cm/positionSide/dual': 6,
1062
1074
  'um/userTrades': 5,
1063
1075
  'cm/userTrades': 20,
1064
- 'um/leverageBracket': 1,
1065
- 'cm/leverageBracket': 1,
1076
+ 'um/leverageBracket': 0.2,
1077
+ 'cm/leverageBracket': 0.2,
1066
1078
  'margin/forceOrders': 1,
1067
- 'um/forceOrders': 20,
1068
- 'cm/forceOrders': 20,
1069
- 'um/apiTradingStatus': 1,
1070
- 'um/commissionRate': 20,
1071
- 'cm/commissionRate': 20,
1072
- 'margin/marginLoan': 10,
1073
- 'margin/repayLoan': 10,
1074
- 'margin/marginInterestHistory': 1,
1075
- 'portfolio/interest-history': 50,
1076
- 'um/income': 30,
1077
- 'cm/income': 30,
1078
- 'um/account': 5,
1079
- 'cm/account': 5,
1080
- 'repay-futures-switch': 3,
1079
+ 'um/forceOrders': { 'cost': 20, 'noSymbol': 50 },
1080
+ 'cm/forceOrders': { 'cost': 20, 'noSymbol': 50 },
1081
+ 'um/apiTradingStatus': { 'cost': 0.2, 'noSymbol': 2 },
1082
+ 'um/commissionRate': 4,
1083
+ 'cm/commissionRate': 4,
1084
+ 'margin/marginLoan': 2,
1085
+ 'margin/repayLoan': 2,
1086
+ 'margin/marginInterestHistory': 0.2,
1087
+ 'portfolio/interest-history': 10,
1088
+ 'um/income': 6,
1089
+ 'cm/income': 6,
1090
+ 'um/account': 1,
1091
+ 'cm/account': 1,
1092
+ 'repay-futures-switch': 6,
1081
1093
  'um/adlQuantile': 5,
1082
1094
  'cm/adlQuantile': 5,
1095
+ 'um/trade/asyn': 300,
1096
+ 'um/trade/asyn/id': 2,
1097
+ 'um/order/asyn/': 300,
1098
+ 'um/order/asyn/id': 2,
1099
+ 'um/income/asyn': 300,
1100
+ 'um/income/asyn/id': 2,
1101
+ 'um/orderAmendment': 1,
1102
+ 'cm/orderAmendment': 1,
1103
+ 'um/feeBurn': 30,
1104
+ 'um/accountConfig': 1,
1105
+ 'um/symbolConfig': 1,
1106
+ 'cm/accountConfig': 1,
1107
+ 'cm/symbolConfig': 1,
1083
1108
  },
1084
1109
  'post': {
1085
1110
  'um/order': 1,
1086
1111
  'um/conditional/order': 1,
1087
1112
  'cm/order': 1,
1088
1113
  'cm/conditional/order': 1,
1089
- 'margin/order': 0.0133,
1090
- 'marginLoan': 0.1333,
1091
- 'repayLoan': 0.1333,
1092
- 'margin/order/oco': 0.0400,
1093
- 'um/leverage': 1,
1094
- 'cm/leverage': 1,
1095
- 'um/positionSide/dual': 1,
1096
- 'cm/positionSide/dual': 1,
1097
- 'auto-collection': 0.6667,
1098
- 'bnb-transfer': 0.6667,
1114
+ 'margin/order': 1,
1115
+ 'marginLoan': 100,
1116
+ 'repayLoan': 100,
1117
+ 'margin/order/oco': 1,
1118
+ 'um/leverage': 0.2,
1119
+ 'cm/leverage': 0.2,
1120
+ 'um/positionSide/dual': 0.2,
1121
+ 'cm/positionSide/dual': 0.2,
1122
+ 'auto-collection': 150,
1123
+ 'bnb-transfer': 150,
1099
1124
  'repay-futures-switch': 150,
1100
1125
  'repay-futures-negative-balance': 150,
1101
- 'listenKey': 1,
1102
- 'asset-collection': 3,
1103
- 'margin/repay-debt': 0.4,
1126
+ 'listenKey': 0.2,
1127
+ 'asset-collection': 6,
1128
+ 'margin/repay-debt': 3000,
1104
1129
  'um/feeBurn': 1,
1105
1130
  },
1106
1131
  'put': {
1107
- 'listenKey': 1, // 1
1132
+ 'listenKey': 0.2,
1133
+ 'um/order': 1,
1134
+ 'cm/order': 1,
1108
1135
  },
1109
1136
  'delete': {
1110
1137
  'um/order': 1,
@@ -1115,10 +1142,10 @@ class binance extends binance$1 {
1115
1142
  'cm/conditional/order': 1,
1116
1143
  'cm/allOpenOrders': 1,
1117
1144
  'cm/conditional/allOpenOrders': 1,
1118
- 'margin/order': 1,
1145
+ 'margin/order': 2,
1119
1146
  'margin/allOpenOrders': 5,
1120
1147
  'margin/orderList': 2,
1121
- 'listenKey': 1, // 1
1148
+ 'listenKey': 0.2,
1122
1149
  },
1123
1150
  },
1124
1151
  },
@@ -13818,6 +13845,107 @@ class binance extends binance$1 {
13818
13845
  const result = this.parseFundingRates(response, market);
13819
13846
  return this.filterByArray(result, 'symbol', symbols);
13820
13847
  }
13848
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
13849
+ /**
13850
+ * @method
13851
+ * @name binance#fetchLongShortRatioHistory
13852
+ * @description fetches the long short ratio history for a unified market symbol
13853
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
13854
+ * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Long-Short-Ratio
13855
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
13856
+ * @param {string} [timeframe] the period for the ratio, default is 24 hours
13857
+ * @param {int} [since] the earliest time in ms to fetch ratios for
13858
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
13859
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
13860
+ * @param {int} [params.until] timestamp in ms of the latest ratio to fetch
13861
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
13862
+ */
13863
+ await this.loadMarkets();
13864
+ const market = this.market(symbol);
13865
+ if (timeframe === undefined) {
13866
+ timeframe = '1d';
13867
+ }
13868
+ let request = {
13869
+ 'period': timeframe,
13870
+ };
13871
+ [request, params] = this.handleUntilOption('endTime', request, params);
13872
+ if (since !== undefined) {
13873
+ request['startTime'] = since;
13874
+ }
13875
+ if (limit !== undefined) {
13876
+ request['limit'] = limit;
13877
+ }
13878
+ let subType = undefined;
13879
+ [subType, params] = this.handleSubTypeAndParams('fetchLongShortRatioHistory', market, params);
13880
+ let response = undefined;
13881
+ if (subType === 'linear') {
13882
+ request['symbol'] = market['id'];
13883
+ response = await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13884
+ //
13885
+ // [
13886
+ // {
13887
+ // "symbol": "BTCUSDT",
13888
+ // "longAccount": "0.4558",
13889
+ // "longShortRatio": "0.8376",
13890
+ // "shortAccount": "0.5442",
13891
+ // "timestamp": 1726790400000
13892
+ // },
13893
+ // ]
13894
+ //
13895
+ }
13896
+ else if (subType === 'inverse') {
13897
+ request['pair'] = market['info']['pair'];
13898
+ response = await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
13899
+ //
13900
+ // [
13901
+ // {
13902
+ // "longAccount": "0.7262",
13903
+ // "longShortRatio": "2.6523",
13904
+ // "shortAccount": "0.2738",
13905
+ // "pair": "BTCUSD",
13906
+ // "timestamp": 1726790400000
13907
+ // },
13908
+ // ]
13909
+ //
13910
+ }
13911
+ else {
13912
+ throw new errors.BadRequest(this.id + ' fetchLongShortRatioHistory() supports linear and inverse subTypes only');
13913
+ }
13914
+ return this.parseLongShortRatioHistory(response, market);
13915
+ }
13916
+ parseLongShortRatio(info, market = undefined) {
13917
+ //
13918
+ // linear
13919
+ //
13920
+ // {
13921
+ // "symbol": "BTCUSDT",
13922
+ // "longAccount": "0.4558",
13923
+ // "longShortRatio": "0.8376",
13924
+ // "shortAccount": "0.5442",
13925
+ // "timestamp": 1726790400000
13926
+ // }
13927
+ //
13928
+ // inverse
13929
+ //
13930
+ // {
13931
+ // "longAccount": "0.7262",
13932
+ // "longShortRatio": "2.6523",
13933
+ // "shortAccount": "0.2738",
13934
+ // "pair": "BTCUSD",
13935
+ // "timestamp": 1726790400000
13936
+ // }
13937
+ //
13938
+ const marketId = this.safeString(info, 'symbol');
13939
+ const timestamp = this.safeIntegerOmitZero(info, 'timestamp');
13940
+ return {
13941
+ 'info': info,
13942
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
13943
+ 'timestamp': timestamp,
13944
+ 'datetime': this.iso8601(timestamp),
13945
+ 'timeframe': undefined,
13946
+ 'longShortRatio': this.safeNumber(info, 'longShortRatio'),
13947
+ };
13948
+ }
13821
13949
  }
13822
13950
 
13823
13951
  module.exports = binance;
@@ -44,6 +44,10 @@ class bitfinex extends bitfinex$1 {
44
44
  'fetchDepositsWithdrawals': true,
45
45
  'fetchDepositWithdrawFee': 'emulated',
46
46
  'fetchDepositWithdrawFees': true,
47
+ 'fetchFundingHistory': false,
48
+ 'fetchFundingRate': false,
49
+ 'fetchFundingRateHistory': false,
50
+ 'fetchFundingRates': false,
47
51
  'fetchIndexOHLCV': false,
48
52
  'fetchLeverageTiers': false,
49
53
  'fetchMarginMode': false,
@@ -34,6 +34,9 @@ class bitflyer extends bitflyer$1 {
34
34
  'fetchBalance': true,
35
35
  'fetchClosedOrders': 'emulated',
36
36
  'fetchDeposits': true,
37
+ 'fetchFundingRate': true,
38
+ 'fetchFundingRateHistory': false,
39
+ 'fetchFundingRates': false,
37
40
  'fetchMarginMode': false,
38
41
  'fetchMarkets': true,
39
42
  'fetchMyTrades': true,
@@ -73,6 +76,7 @@ class bitflyer extends bitflyer$1 {
73
76
  'gethealth',
74
77
  'getboardstate',
75
78
  'getchats',
79
+ 'getfundingrate',
76
80
  ],
77
81
  },
78
82
  'private': {
@@ -1023,6 +1027,60 @@ class bitflyer extends bitflyer$1 {
1023
1027
  'fee': fee,
1024
1028
  };
1025
1029
  }
1030
+ async fetchFundingRate(symbol, params = {}) {
1031
+ /**
1032
+ * @method
1033
+ * @name bitflyer#fetchFundingRate
1034
+ * @description fetch the current funding rate
1035
+ * @see https://lightning.bitflyer.com/docs#funding-rate
1036
+ * @param {string} symbol unified market symbol
1037
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1038
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
1039
+ */
1040
+ await this.loadMarkets();
1041
+ const market = this.market(symbol);
1042
+ const request = {
1043
+ 'product_code': market['id'],
1044
+ };
1045
+ const response = await this.publicGetGetfundingrate(this.extend(request, params));
1046
+ //
1047
+ // {
1048
+ // "current_funding_rate": -0.003750000000
1049
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1050
+ // }
1051
+ //
1052
+ return this.parseFundingRate(response, market);
1053
+ }
1054
+ parseFundingRate(contract, market = undefined) {
1055
+ //
1056
+ // {
1057
+ // "current_funding_rate": -0.003750000000
1058
+ // "next_funding_rate_settledate": "2024-04-15T13:00:00"
1059
+ // }
1060
+ //
1061
+ const nextFundingDatetime = this.safeString(contract, 'next_funding_rate_settledate');
1062
+ const nextFundingTimestamp = this.parse8601(nextFundingDatetime);
1063
+ return {
1064
+ 'info': contract,
1065
+ 'symbol': this.safeString(market, 'symbol'),
1066
+ 'markPrice': undefined,
1067
+ 'indexPrice': undefined,
1068
+ 'interestRate': undefined,
1069
+ 'estimatedSettlePrice': undefined,
1070
+ 'timestamp': undefined,
1071
+ 'datetime': undefined,
1072
+ 'fundingRate': undefined,
1073
+ 'fundingTimestamp': undefined,
1074
+ 'fundingDatetime': undefined,
1075
+ 'nextFundingRate': this.safeNumber(contract, 'current_funding_rate'),
1076
+ 'nextFundingTimestamp': nextFundingTimestamp,
1077
+ 'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
1078
+ 'previousFundingRate': undefined,
1079
+ 'previousFundingTimestamp': undefined,
1080
+ 'previousFundingDatetime': undefined,
1081
+ 'interval': undefined,
1082
+ };
1083
+ }
1026
1084
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1027
1085
  let request = '/' + this.version + '/';
1028
1086
  if (api === 'private') {
@@ -92,6 +92,8 @@ class bitget extends bitget$1 {
92
92
  'fetchLeverage': true,
93
93
  'fetchLeverageTiers': false,
94
94
  'fetchLiquidations': false,
95
+ 'fetchLongShortRatio': false,
96
+ 'fetchLongShortRatioHistory': true,
95
97
  'fetchMarginAdjustmentHistory': false,
96
98
  'fetchMarginMode': true,
97
99
  'fetchMarketLeverageTiers': true,
@@ -267,6 +269,7 @@ class bitget extends bitget$1 {
267
269
  'v2/mix/market/current-fund-rate': 1,
268
270
  'v2/mix/market/contracts': 1,
269
271
  'v2/mix/market/query-position-lever': 2,
272
+ 'v2/mix/market/account-long-short': 20,
270
273
  },
271
274
  },
272
275
  'margin': {
@@ -277,6 +280,7 @@ class bitget extends bitget$1 {
277
280
  'margin/v1/isolated/public/tierData': 2,
278
281
  'margin/v1/public/currencies': 1,
279
282
  'v2/margin/currencies': 2,
283
+ 'v2/margin/market/long-short-ratio': 20,
280
284
  },
281
285
  },
282
286
  'earn': {
@@ -439,6 +443,7 @@ class bitget extends bitget$1 {
439
443
  'v2/mix/order/orders-history': 2,
440
444
  'v2/mix/order/orders-plan-pending': 2,
441
445
  'v2/mix/order/orders-plan-history': 2,
446
+ 'v2/mix/market/position-long-short': 20,
442
447
  },
443
448
  'post': {
444
449
  'mix/v1/account/sub-account-contract-assets': 200,
@@ -8900,6 +8905,78 @@ class bitget extends bitget$1 {
8900
8905
  const first = this.safeDict(data, 0, {});
8901
8906
  return this.parseFundingRate(first, market);
8902
8907
  }
8908
+ async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
8909
+ /**
8910
+ * @method
8911
+ * @name bitget#fetchLongShortRatioHistory
8912
+ * @description fetches the long short ratio history for a unified market symbol
8913
+ * @see https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
8914
+ * @see https://www.bitget.com/api-doc/common/apidata/Account-Long-Short
8915
+ * @param {string} symbol unified symbol of the market to fetch the long short ratio for
8916
+ * @param {string} [timeframe] the period for the ratio
8917
+ * @param {int} [since] the earliest time in ms to fetch ratios for
8918
+ * @param {int} [limit] the maximum number of long short ratio structures to retrieve
8919
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
8920
+ * @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
8921
+ */
8922
+ await this.loadMarkets();
8923
+ const market = this.market(symbol);
8924
+ const request = {
8925
+ 'symbol': market['id'],
8926
+ };
8927
+ if (timeframe !== undefined) {
8928
+ request['period'] = timeframe;
8929
+ }
8930
+ let response = undefined;
8931
+ if (market['swap'] || market['future']) {
8932
+ response = await this.publicMixGetV2MixMarketAccountLongShort(this.extend(request, params));
8933
+ //
8934
+ // {
8935
+ // "code": "00000",
8936
+ // "msg": "success",
8937
+ // "requestTime": 1729321233281,
8938
+ // "data": [
8939
+ // {
8940
+ // "longAccountRatio": "0.58",
8941
+ // "shortAccountRatio": "0.42",
8942
+ // "longShortAccountRatio": "0.0138",
8943
+ // "ts": "1729312200000"
8944
+ // },
8945
+ // ]
8946
+ // }
8947
+ //
8948
+ }
8949
+ else {
8950
+ response = await this.publicMarginGetV2MarginMarketLongShortRatio(this.extend(request, params));
8951
+ //
8952
+ // {
8953
+ // "code": "00000",
8954
+ // "msg": "success",
8955
+ // "requestTime": 1729306974712,
8956
+ // "data": [
8957
+ // {
8958
+ // "longShortRatio": "40.66",
8959
+ // "ts": "1729306800000"
8960
+ // },
8961
+ // ]
8962
+ // }
8963
+ //
8964
+ }
8965
+ const data = this.safeList(response, 'data', []);
8966
+ return this.parseLongShortRatioHistory(data, market);
8967
+ }
8968
+ parseLongShortRatio(info, market = undefined) {
8969
+ const marketId = this.safeString(info, 'symbol');
8970
+ const timestamp = this.safeIntegerOmitZero(info, 'ts');
8971
+ return {
8972
+ 'info': info,
8973
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
8974
+ 'timestamp': timestamp,
8975
+ 'datetime': this.iso8601(timestamp),
8976
+ 'timeframe': undefined,
8977
+ 'longShortRatio': this.safeNumber2(info, 'longShortRatio', 'longShortAccountRatio'),
8978
+ };
8979
+ }
8903
8980
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
8904
8981
  if (!response) {
8905
8982
  return undefined; // fallback to default error handler
@@ -52,7 +52,10 @@ class bitrue extends bitrue$1 {
52
52
  'fetchDepositsWithdrawals': false,
53
53
  'fetchDepositWithdrawFee': 'emulated',
54
54
  'fetchDepositWithdrawFees': true,
55
+ 'fetchFundingHistory': false,
55
56
  'fetchFundingRate': false,
57
+ 'fetchFundingRateHistory': false,
58
+ 'fetchFundingRates': false,
56
59
  'fetchIsolatedBorrowRate': false,
57
60
  'fetchIsolatedBorrowRates': false,
58
61
  'fetchMarginMode': false,