ccxt 4.4.21 → 4.4.22
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.
- package/README.md +4 -4
- package/dist/ccxt.browser.min.js +4 -4
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +1 -0
- package/dist/cjs/src/base/Exchange.js +21 -0
- package/dist/cjs/src/bigone.js +3 -0
- package/dist/cjs/src/binance.js +103 -0
- package/dist/cjs/src/bitflyer.js +57 -0
- package/dist/cjs/src/bitget.js +77 -0
- package/dist/cjs/src/bybit.js +78 -0
- package/dist/cjs/src/cex.js +1307 -1385
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/gate.js +103 -3
- package/dist/cjs/src/htx.js +1 -7
- package/dist/cjs/src/hyperliquid.js +10 -8
- package/dist/cjs/src/kucoin.js +27 -59
- package/dist/cjs/src/okx.js +74 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitflyer.d.ts +1 -0
- package/js/src/abstract/bitget.d.ts +3 -0
- package/js/src/abstract/cex.d.ts +28 -29
- package/js/src/abstract/gate.d.ts +5 -0
- package/js/src/abstract/gateio.d.ts +5 -0
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/alpaca.js +1 -0
- package/js/src/base/Exchange.d.ts +8 -2
- package/js/src/base/Exchange.js +21 -0
- package/js/src/base/types.d.ts +8 -0
- package/js/src/bigone.js +3 -0
- package/js/src/binance.d.ts +3 -1
- package/js/src/binance.js +103 -0
- package/js/src/bitflyer.d.ts +3 -1
- package/js/src/bitflyer.js +57 -0
- package/js/src/bitget.d.ts +3 -1
- package/js/src/bitget.js +77 -0
- package/js/src/bybit.d.ts +3 -1
- package/js/src/bybit.js +78 -0
- package/js/src/cex.d.ts +34 -20
- package/js/src/cex.js +1308 -1386
- package/js/src/cryptocom.js +1 -1
- package/js/src/gate.d.ts +2 -0
- package/js/src/gate.js +103 -3
- package/js/src/htx.js +1 -7
- package/js/src/hyperliquid.js +10 -8
- package/js/src/kucoin.d.ts +0 -1
- package/js/src/kucoin.js +27 -59
- package/js/src/okx.d.ts +3 -1
- package/js/src/okx.js +74 -0
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -195,7 +195,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
195
195
|
|
|
196
196
|
//-----------------------------------------------------------------------------
|
|
197
197
|
// this is updated by vss.js when building
|
|
198
|
-
const version = '4.4.
|
|
198
|
+
const version = '4.4.22';
|
|
199
199
|
Exchange["default"].ccxtVersion = version;
|
|
200
200
|
const exchanges = {
|
|
201
201
|
'ace': ace,
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -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) {
|
package/dist/cjs/src/bigone.js
CHANGED
|
@@ -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,
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -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,
|
|
@@ -13818,6 +13820,107 @@ class binance extends binance$1 {
|
|
|
13818
13820
|
const result = this.parseFundingRates(response, market);
|
|
13819
13821
|
return this.filterByArray(result, 'symbol', symbols);
|
|
13820
13822
|
}
|
|
13823
|
+
async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
|
|
13824
|
+
/**
|
|
13825
|
+
* @method
|
|
13826
|
+
* @name binance#fetchLongShortRatioHistory
|
|
13827
|
+
* @description fetches the long short ratio history for a unified market symbol
|
|
13828
|
+
* @see https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Long-Short-Ratio
|
|
13829
|
+
* @see https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Long-Short-Ratio
|
|
13830
|
+
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
|
|
13831
|
+
* @param {string} [timeframe] the period for the ratio, default is 24 hours
|
|
13832
|
+
* @param {int} [since] the earliest time in ms to fetch ratios for
|
|
13833
|
+
* @param {int} [limit] the maximum number of long short ratio structures to retrieve
|
|
13834
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
13835
|
+
* @param {int} [params.until] timestamp in ms of the latest ratio to fetch
|
|
13836
|
+
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
|
|
13837
|
+
*/
|
|
13838
|
+
await this.loadMarkets();
|
|
13839
|
+
const market = this.market(symbol);
|
|
13840
|
+
if (timeframe === undefined) {
|
|
13841
|
+
timeframe = '1d';
|
|
13842
|
+
}
|
|
13843
|
+
let request = {
|
|
13844
|
+
'period': timeframe,
|
|
13845
|
+
};
|
|
13846
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
13847
|
+
if (since !== undefined) {
|
|
13848
|
+
request['startTime'] = since;
|
|
13849
|
+
}
|
|
13850
|
+
if (limit !== undefined) {
|
|
13851
|
+
request['limit'] = limit;
|
|
13852
|
+
}
|
|
13853
|
+
let subType = undefined;
|
|
13854
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLongShortRatioHistory', market, params);
|
|
13855
|
+
let response = undefined;
|
|
13856
|
+
if (subType === 'linear') {
|
|
13857
|
+
request['symbol'] = market['id'];
|
|
13858
|
+
response = await this.fapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
|
|
13859
|
+
//
|
|
13860
|
+
// [
|
|
13861
|
+
// {
|
|
13862
|
+
// "symbol": "BTCUSDT",
|
|
13863
|
+
// "longAccount": "0.4558",
|
|
13864
|
+
// "longShortRatio": "0.8376",
|
|
13865
|
+
// "shortAccount": "0.5442",
|
|
13866
|
+
// "timestamp": 1726790400000
|
|
13867
|
+
// },
|
|
13868
|
+
// ]
|
|
13869
|
+
//
|
|
13870
|
+
}
|
|
13871
|
+
else if (subType === 'inverse') {
|
|
13872
|
+
request['pair'] = market['info']['pair'];
|
|
13873
|
+
response = await this.dapiDataGetGlobalLongShortAccountRatio(this.extend(request, params));
|
|
13874
|
+
//
|
|
13875
|
+
// [
|
|
13876
|
+
// {
|
|
13877
|
+
// "longAccount": "0.7262",
|
|
13878
|
+
// "longShortRatio": "2.6523",
|
|
13879
|
+
// "shortAccount": "0.2738",
|
|
13880
|
+
// "pair": "BTCUSD",
|
|
13881
|
+
// "timestamp": 1726790400000
|
|
13882
|
+
// },
|
|
13883
|
+
// ]
|
|
13884
|
+
//
|
|
13885
|
+
}
|
|
13886
|
+
else {
|
|
13887
|
+
throw new errors.BadRequest(this.id + ' fetchLongShortRatioHistory() supports linear and inverse subTypes only');
|
|
13888
|
+
}
|
|
13889
|
+
return this.parseLongShortRatioHistory(response, market);
|
|
13890
|
+
}
|
|
13891
|
+
parseLongShortRatio(info, market = undefined) {
|
|
13892
|
+
//
|
|
13893
|
+
// linear
|
|
13894
|
+
//
|
|
13895
|
+
// {
|
|
13896
|
+
// "symbol": "BTCUSDT",
|
|
13897
|
+
// "longAccount": "0.4558",
|
|
13898
|
+
// "longShortRatio": "0.8376",
|
|
13899
|
+
// "shortAccount": "0.5442",
|
|
13900
|
+
// "timestamp": 1726790400000
|
|
13901
|
+
// }
|
|
13902
|
+
//
|
|
13903
|
+
// inverse
|
|
13904
|
+
//
|
|
13905
|
+
// {
|
|
13906
|
+
// "longAccount": "0.7262",
|
|
13907
|
+
// "longShortRatio": "2.6523",
|
|
13908
|
+
// "shortAccount": "0.2738",
|
|
13909
|
+
// "pair": "BTCUSD",
|
|
13910
|
+
// "timestamp": 1726790400000
|
|
13911
|
+
// }
|
|
13912
|
+
//
|
|
13913
|
+
const marketId = this.safeString(info, 'symbol');
|
|
13914
|
+
const timestamp = this.safeIntegerOmitZero(info, 'timestamp');
|
|
13915
|
+
return {
|
|
13916
|
+
'info': info,
|
|
13917
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
13918
|
+
'timestamp': timestamp,
|
|
13919
|
+
'datetime': this.iso8601(timestamp),
|
|
13920
|
+
'timeframe': undefined,
|
|
13921
|
+
'longShortRatio': this.safeNumber(info, 'longShortRatio'),
|
|
13922
|
+
};
|
|
13923
|
+
}
|
|
13821
13924
|
}
|
|
13822
13925
|
|
|
13823
13926
|
module.exports = binance;
|
package/dist/cjs/src/bitflyer.js
CHANGED
|
@@ -34,6 +34,8 @@ class bitflyer extends bitflyer$1 {
|
|
|
34
34
|
'fetchBalance': true,
|
|
35
35
|
'fetchClosedOrders': 'emulated',
|
|
36
36
|
'fetchDeposits': true,
|
|
37
|
+
'fetchFundingRate': true,
|
|
38
|
+
'fetchFundingRateHistory': false,
|
|
37
39
|
'fetchMarginMode': false,
|
|
38
40
|
'fetchMarkets': true,
|
|
39
41
|
'fetchMyTrades': true,
|
|
@@ -73,6 +75,7 @@ class bitflyer extends bitflyer$1 {
|
|
|
73
75
|
'gethealth',
|
|
74
76
|
'getboardstate',
|
|
75
77
|
'getchats',
|
|
78
|
+
'getfundingrate',
|
|
76
79
|
],
|
|
77
80
|
},
|
|
78
81
|
'private': {
|
|
@@ -1023,6 +1026,60 @@ class bitflyer extends bitflyer$1 {
|
|
|
1023
1026
|
'fee': fee,
|
|
1024
1027
|
};
|
|
1025
1028
|
}
|
|
1029
|
+
async fetchFundingRate(symbol, params = {}) {
|
|
1030
|
+
/**
|
|
1031
|
+
* @method
|
|
1032
|
+
* @name bitflyer#fetchFundingRate
|
|
1033
|
+
* @description fetch the current funding rate
|
|
1034
|
+
* @see https://lightning.bitflyer.com/docs#funding-rate
|
|
1035
|
+
* @param {string} symbol unified market symbol
|
|
1036
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1037
|
+
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
1038
|
+
*/
|
|
1039
|
+
await this.loadMarkets();
|
|
1040
|
+
const market = this.market(symbol);
|
|
1041
|
+
const request = {
|
|
1042
|
+
'product_code': market['id'],
|
|
1043
|
+
};
|
|
1044
|
+
const response = await this.publicGetGetfundingrate(this.extend(request, params));
|
|
1045
|
+
//
|
|
1046
|
+
// {
|
|
1047
|
+
// "current_funding_rate": -0.003750000000
|
|
1048
|
+
// "next_funding_rate_settledate": "2024-04-15T13:00:00"
|
|
1049
|
+
// }
|
|
1050
|
+
//
|
|
1051
|
+
return this.parseFundingRate(response, market);
|
|
1052
|
+
}
|
|
1053
|
+
parseFundingRate(contract, market = undefined) {
|
|
1054
|
+
//
|
|
1055
|
+
// {
|
|
1056
|
+
// "current_funding_rate": -0.003750000000
|
|
1057
|
+
// "next_funding_rate_settledate": "2024-04-15T13:00:00"
|
|
1058
|
+
// }
|
|
1059
|
+
//
|
|
1060
|
+
const nextFundingDatetime = this.safeString(contract, 'next_funding_rate_settledate');
|
|
1061
|
+
const nextFundingTimestamp = this.parse8601(nextFundingDatetime);
|
|
1062
|
+
return {
|
|
1063
|
+
'info': contract,
|
|
1064
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
1065
|
+
'markPrice': undefined,
|
|
1066
|
+
'indexPrice': undefined,
|
|
1067
|
+
'interestRate': undefined,
|
|
1068
|
+
'estimatedSettlePrice': undefined,
|
|
1069
|
+
'timestamp': undefined,
|
|
1070
|
+
'datetime': undefined,
|
|
1071
|
+
'fundingRate': undefined,
|
|
1072
|
+
'fundingTimestamp': undefined,
|
|
1073
|
+
'fundingDatetime': undefined,
|
|
1074
|
+
'nextFundingRate': this.safeNumber(contract, 'current_funding_rate'),
|
|
1075
|
+
'nextFundingTimestamp': nextFundingTimestamp,
|
|
1076
|
+
'nextFundingDatetime': this.iso8601(nextFundingTimestamp),
|
|
1077
|
+
'previousFundingRate': undefined,
|
|
1078
|
+
'previousFundingTimestamp': undefined,
|
|
1079
|
+
'previousFundingDatetime': undefined,
|
|
1080
|
+
'interval': undefined,
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1026
1083
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1027
1084
|
let request = '/' + this.version + '/';
|
|
1028
1085
|
if (api === 'private') {
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -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
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -89,6 +89,8 @@ class bybit extends bybit$1 {
|
|
|
89
89
|
'fetchLedger': true,
|
|
90
90
|
'fetchLeverage': true,
|
|
91
91
|
'fetchLeverageTiers': true,
|
|
92
|
+
'fetchLongShortRatio': false,
|
|
93
|
+
'fetchLongShortRatioHistory': true,
|
|
92
94
|
'fetchMarginAdjustmentHistory': false,
|
|
93
95
|
'fetchMarketLeverageTiers': true,
|
|
94
96
|
'fetchMarkets': true,
|
|
@@ -9307,6 +9309,82 @@ class bybit extends bybit$1 {
|
|
|
9307
9309
|
'fee': undefined,
|
|
9308
9310
|
};
|
|
9309
9311
|
}
|
|
9312
|
+
async fetchLongShortRatioHistory(symbol = undefined, timeframe = undefined, since = undefined, limit = undefined, params = {}) {
|
|
9313
|
+
/**
|
|
9314
|
+
* @method
|
|
9315
|
+
* @name bybit#fetchLongShortRatioHistory
|
|
9316
|
+
* @description fetches the long short ratio history for a unified market symbol
|
|
9317
|
+
* @see https://bybit-exchange.github.io/docs/v5/market/long-short-ratio
|
|
9318
|
+
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
|
|
9319
|
+
* @param {string} [timeframe] the period for the ratio, default is 24 hours
|
|
9320
|
+
* @param {int} [since] the earliest time in ms to fetch ratios for
|
|
9321
|
+
* @param {int} [limit] the maximum number of long short ratio structures to retrieve
|
|
9322
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
9323
|
+
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/#/?id=long-short-ratio-structure}
|
|
9324
|
+
*/
|
|
9325
|
+
await this.loadMarkets();
|
|
9326
|
+
const market = this.market(symbol);
|
|
9327
|
+
let type = undefined;
|
|
9328
|
+
[type, params] = this.getBybitType('fetchLongShortRatioHistory', market, params);
|
|
9329
|
+
if (type === 'spot' || type === 'option') {
|
|
9330
|
+
throw new errors.NotSupported(this.id + ' fetchLongShortRatioHistory() only support linear and inverse markets');
|
|
9331
|
+
}
|
|
9332
|
+
if (timeframe === undefined) {
|
|
9333
|
+
timeframe = '1d';
|
|
9334
|
+
}
|
|
9335
|
+
const request = {
|
|
9336
|
+
'symbol': market['id'],
|
|
9337
|
+
'period': timeframe,
|
|
9338
|
+
'category': type,
|
|
9339
|
+
};
|
|
9340
|
+
if (limit !== undefined) {
|
|
9341
|
+
request['limit'] = limit;
|
|
9342
|
+
}
|
|
9343
|
+
const response = await this.publicGetV5MarketAccountRatio(this.extend(request, params));
|
|
9344
|
+
//
|
|
9345
|
+
// {
|
|
9346
|
+
// "retCode": 0,
|
|
9347
|
+
// "retMsg": "OK",
|
|
9348
|
+
// "result": {
|
|
9349
|
+
// "list": [
|
|
9350
|
+
// {
|
|
9351
|
+
// "symbol": "BTCUSDT",
|
|
9352
|
+
// "buyRatio": "0.5707",
|
|
9353
|
+
// "sellRatio": "0.4293",
|
|
9354
|
+
// "timestamp": "1729123200000"
|
|
9355
|
+
// },
|
|
9356
|
+
// ]
|
|
9357
|
+
// },
|
|
9358
|
+
// "retExtInfo": {},
|
|
9359
|
+
// "time": 1729147842516
|
|
9360
|
+
// }
|
|
9361
|
+
//
|
|
9362
|
+
const result = this.safeDict(response, 'result', {});
|
|
9363
|
+
const data = this.safeList(result, 'list', []);
|
|
9364
|
+
return this.parseLongShortRatioHistory(data, market);
|
|
9365
|
+
}
|
|
9366
|
+
parseLongShortRatio(info, market = undefined) {
|
|
9367
|
+
//
|
|
9368
|
+
// {
|
|
9369
|
+
// "symbol": "BTCUSDT",
|
|
9370
|
+
// "buyRatio": "0.5707",
|
|
9371
|
+
// "sellRatio": "0.4293",
|
|
9372
|
+
// "timestamp": "1729123200000"
|
|
9373
|
+
// }
|
|
9374
|
+
//
|
|
9375
|
+
const marketId = this.safeString(info, 'symbol');
|
|
9376
|
+
const timestamp = this.safeIntegerOmitZero(info, 'timestamp');
|
|
9377
|
+
const longString = this.safeString(info, 'buyRatio');
|
|
9378
|
+
const shortString = this.safeString(info, 'sellRatio');
|
|
9379
|
+
return {
|
|
9380
|
+
'info': info,
|
|
9381
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
|
|
9382
|
+
'timestamp': timestamp,
|
|
9383
|
+
'datetime': this.iso8601(timestamp),
|
|
9384
|
+
'timeframe': undefined,
|
|
9385
|
+
'longShortRatio': this.parseToNumeric(Precise["default"].stringDiv(longString, shortString)),
|
|
9386
|
+
};
|
|
9387
|
+
}
|
|
9310
9388
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
9311
9389
|
let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
|
|
9312
9390
|
if (api === 'public') {
|