ccxt 4.2.57 → 4.2.59
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/CHANGELOG.md +83 -0
- package/README.md +4 -5
- package/build.sh +1 -1
- package/cleanup.sh +3 -0
- package/dist/ccxt.browser.js +772 -497
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +90 -88
- package/dist/cjs/src/base/Exchange.js +24 -1
- package/dist/cjs/src/binance.js +43 -30
- package/dist/cjs/src/bingx.js +15 -4
- package/dist/cjs/src/bitget.js +72 -57
- package/dist/cjs/src/bitmex.js +13 -29
- package/dist/cjs/src/bitrue.js +24 -15
- package/dist/cjs/src/blofin.js +25 -2
- package/dist/cjs/src/bybit.js +11 -3
- package/dist/cjs/src/coinbase.js +24 -14
- package/dist/cjs/src/currencycom.js +15 -5
- package/dist/cjs/src/delta.js +14 -1
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/hitbtc.js +12 -1
- package/dist/cjs/src/krakenfutures.js +22 -7
- package/dist/cjs/src/kuna.js +14 -11
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/mexc.js +20 -20
- package/dist/cjs/src/okx.js +32 -2
- package/dist/cjs/src/phemex.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +1 -1
- package/dist/cjs/src/pro/binance.js +1 -1
- package/dist/cjs/src/pro/bitfinex2.js +1 -1
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bitmart.js +51 -89
- package/dist/cjs/src/pro/bitvavo.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinex.js +1 -1
- package/dist/cjs/src/pro/cryptocom.js +1 -1
- package/dist/cjs/src/pro/deribit.js +201 -84
- package/dist/cjs/src/pro/gate.js +1 -1
- package/dist/cjs/src/pro/independentreserve.js +1 -1
- package/dist/cjs/src/pro/kraken.js +1 -1
- package/dist/cjs/src/pro/kucoinfutures.js +1 -1
- package/dist/cjs/src/pro/mexc.js +5 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/pro/whitebit.js +4 -6
- package/dist/cjs/src/pro/woo.js +1 -1
- package/dist/cjs/src/probit.js +1 -1
- package/dist/cjs/src/wavesexchange.js +1 -1
- package/dist/cjs/src/woo.js +22 -6
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/alpaca.js +90 -88
- package/js/src/base/Exchange.d.ts +6 -4
- package/js/src/base/Exchange.js +24 -1
- package/js/src/base/types.d.ts +9 -0
- package/js/src/binance.d.ts +3 -2
- package/js/src/binance.js +43 -30
- package/js/src/bingx.d.ts +3 -2
- package/js/src/bingx.js +15 -4
- package/js/src/bitget.d.ts +3 -2
- package/js/src/bitget.js +72 -57
- package/js/src/bitmex.d.ts +3 -3
- package/js/src/bitmex.js +13 -29
- package/js/src/bitrue.js +24 -15
- package/js/src/blofin.d.ts +3 -2
- package/js/src/blofin.js +25 -2
- package/js/src/bybit.d.ts +3 -6
- package/js/src/bybit.js +11 -3
- package/js/src/coinbase.js +24 -14
- package/js/src/currencycom.d.ts +3 -2
- package/js/src/currencycom.js +15 -5
- package/js/src/delta.d.ts +3 -2
- package/js/src/delta.js +14 -1
- package/js/src/gate.js +1 -1
- package/js/src/hitbtc.d.ts +3 -2
- package/js/src/hitbtc.js +12 -1
- package/js/src/krakenfutures.d.ts +3 -2
- package/js/src/krakenfutures.js +22 -7
- package/js/src/kuna.js +14 -11
- package/js/src/lbank.js +1 -1
- package/js/src/mexc.d.ts +3 -13
- package/js/src/mexc.js +20 -20
- package/js/src/okx.d.ts +3 -2
- package/js/src/okx.js +32 -2
- package/js/src/phemex.js +1 -1
- package/js/src/pro/alpaca.js +1 -1
- package/js/src/pro/binance.js +1 -1
- package/js/src/pro/bitfinex2.js +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bitmart.d.ts +2 -2
- package/js/src/pro/bitmart.js +51 -89
- package/js/src/pro/bitvavo.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinex.js +1 -1
- package/js/src/pro/cryptocom.js +1 -1
- package/js/src/pro/deribit.d.ts +5 -0
- package/js/src/pro/deribit.js +202 -85
- package/js/src/pro/gate.js +1 -1
- package/js/src/pro/independentreserve.js +1 -1
- package/js/src/pro/kraken.js +1 -1
- package/js/src/pro/kucoinfutures.js +1 -1
- package/js/src/pro/mexc.js +6 -4
- package/js/src/pro/okx.js +1 -1
- package/js/src/pro/whitebit.js +4 -6
- package/js/src/pro/woo.js +1 -1
- package/js/src/probit.js +1 -1
- package/js/src/wavesexchange.js +1 -1
- package/js/src/woo.d.ts +3 -5
- package/js/src/woo.js +22 -6
- package/package.json +1 -1
- package/skip-tests.json +8 -3
package/dist/ccxt.browser.js
CHANGED
|
@@ -2943,7 +2943,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
2943
2943
|
'loc': loc,
|
|
2944
2944
|
};
|
|
2945
2945
|
params = this.omit(params, ['loc', 'method']);
|
|
2946
|
-
let
|
|
2946
|
+
let symbolTrades = undefined;
|
|
2947
2947
|
if (method === 'marketPublicGetV1beta3CryptoLocTrades') {
|
|
2948
2948
|
if (since !== undefined) {
|
|
2949
2949
|
request['start'] = this.iso8601(since);
|
|
@@ -2951,47 +2951,48 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
2951
2951
|
if (limit !== undefined) {
|
|
2952
2952
|
request['limit'] = limit;
|
|
2953
2953
|
}
|
|
2954
|
-
response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
2954
|
+
const response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
|
|
2955
|
+
//
|
|
2956
|
+
// {
|
|
2957
|
+
// "next_page_token": null,
|
|
2958
|
+
// "trades": {
|
|
2959
|
+
// "BTC/USD": [
|
|
2960
|
+
// {
|
|
2961
|
+
// "i": 36440704,
|
|
2962
|
+
// "p": 22625,
|
|
2963
|
+
// "s": 0.0001,
|
|
2964
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
2965
|
+
// "tks": "B"
|
|
2966
|
+
// }
|
|
2967
|
+
// ]
|
|
2968
|
+
// }
|
|
2969
|
+
// }
|
|
2970
|
+
//
|
|
2971
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
2972
|
+
symbolTrades = this.safeList(trades, marketId, []);
|
|
2955
2973
|
}
|
|
2956
2974
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestTrades') {
|
|
2957
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
2975
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
|
|
2976
|
+
//
|
|
2977
|
+
// {
|
|
2978
|
+
// "trades": {
|
|
2979
|
+
// "BTC/USD": {
|
|
2980
|
+
// "i": 36440704,
|
|
2981
|
+
// "p": 22625,
|
|
2982
|
+
// "s": 0.0001,
|
|
2983
|
+
// "t": "2022-07-21T11:47:31.073391Z",
|
|
2984
|
+
// "tks": "B"
|
|
2985
|
+
// }
|
|
2986
|
+
// }
|
|
2987
|
+
// }
|
|
2988
|
+
//
|
|
2989
|
+
const trades = this.safeDict(response, 'trades', {});
|
|
2990
|
+
symbolTrades = this.safeDict(trades, marketId, {});
|
|
2991
|
+
symbolTrades = [symbolTrades];
|
|
2958
2992
|
}
|
|
2959
2993
|
else {
|
|
2960
2994
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTrades() does not support ' + method + ', marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported');
|
|
2961
2995
|
}
|
|
2962
|
-
//
|
|
2963
|
-
// {
|
|
2964
|
-
// "next_page_token":null,
|
|
2965
|
-
// "trades":{
|
|
2966
|
-
// "BTC/USD":[
|
|
2967
|
-
// {
|
|
2968
|
-
// "i":36440704,
|
|
2969
|
-
// "p":22625,
|
|
2970
|
-
// "s":0.0001,
|
|
2971
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
2972
|
-
// "tks":"B"
|
|
2973
|
-
// }
|
|
2974
|
-
// ]
|
|
2975
|
-
// }
|
|
2976
|
-
// }
|
|
2977
|
-
//
|
|
2978
|
-
// {
|
|
2979
|
-
// "trades":{
|
|
2980
|
-
// "BTC/USD":{
|
|
2981
|
-
// "i":36440704,
|
|
2982
|
-
// "p":22625,
|
|
2983
|
-
// "s":0.0001,
|
|
2984
|
-
// "t":"2022-07-21T11:47:31.073391Z",
|
|
2985
|
-
// "tks":"B"
|
|
2986
|
-
// }
|
|
2987
|
-
// }
|
|
2988
|
-
// }
|
|
2989
|
-
//
|
|
2990
|
-
const trades = this.safeValue(response, 'trades', {});
|
|
2991
|
-
let symbolTrades = this.safeValue(trades, marketId, {});
|
|
2992
|
-
if (!Array.isArray(symbolTrades)) {
|
|
2993
|
-
symbolTrades = [symbolTrades];
|
|
2994
|
-
}
|
|
2995
2996
|
return this.parseTrades(symbolTrades, market, since, limit);
|
|
2996
2997
|
}
|
|
2997
2998
|
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
@@ -3083,7 +3084,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
3083
3084
|
'loc': loc,
|
|
3084
3085
|
};
|
|
3085
3086
|
params = this.omit(params, ['loc', 'method']);
|
|
3086
|
-
let
|
|
3087
|
+
let ohlcvs = undefined;
|
|
3087
3088
|
if (method === 'marketPublicGetV1beta3CryptoLocBars') {
|
|
3088
3089
|
if (limit !== undefined) {
|
|
3089
3090
|
request['limit'] = limit;
|
|
@@ -3092,63 +3093,64 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
3092
3093
|
request['start'] = this.yyyymmdd(since);
|
|
3093
3094
|
}
|
|
3094
3095
|
request['timeframe'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
3095
|
-
response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
3096
|
+
const response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
|
|
3097
|
+
//
|
|
3098
|
+
// {
|
|
3099
|
+
// "bars": {
|
|
3100
|
+
// "BTC/USD": [
|
|
3101
|
+
// {
|
|
3102
|
+
// "c": 22887,
|
|
3103
|
+
// "h": 22888,
|
|
3104
|
+
// "l": 22873,
|
|
3105
|
+
// "n": 11,
|
|
3106
|
+
// "o": 22883,
|
|
3107
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
3108
|
+
// "v": 1.1138,
|
|
3109
|
+
// "vw": 22883.0155324116
|
|
3110
|
+
// },
|
|
3111
|
+
// {
|
|
3112
|
+
// "c": 22895,
|
|
3113
|
+
// "h": 22895,
|
|
3114
|
+
// "l": 22884,
|
|
3115
|
+
// "n": 6,
|
|
3116
|
+
// "o": 22884,
|
|
3117
|
+
// "t": "2022-07-21T05:01:00Z",
|
|
3118
|
+
// "v": 0.001,
|
|
3119
|
+
// "vw": 22889.5
|
|
3120
|
+
// }
|
|
3121
|
+
// ]
|
|
3122
|
+
// },
|
|
3123
|
+
// "next_page_token": "QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
3124
|
+
// }
|
|
3125
|
+
//
|
|
3126
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
3127
|
+
ohlcvs = this.safeList(bars, marketId, []);
|
|
3096
3128
|
}
|
|
3097
3129
|
else if (method === 'marketPublicGetV1beta3CryptoLocLatestBars') {
|
|
3098
|
-
response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
3130
|
+
const response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
|
|
3131
|
+
//
|
|
3132
|
+
// {
|
|
3133
|
+
// "bars": {
|
|
3134
|
+
// "BTC/USD": {
|
|
3135
|
+
// "c": 22887,
|
|
3136
|
+
// "h": 22888,
|
|
3137
|
+
// "l": 22873,
|
|
3138
|
+
// "n": 11,
|
|
3139
|
+
// "o": 22883,
|
|
3140
|
+
// "t": "2022-07-21T05:00:00Z",
|
|
3141
|
+
// "v": 1.1138,
|
|
3142
|
+
// "vw": 22883.0155324116
|
|
3143
|
+
// }
|
|
3144
|
+
// }
|
|
3145
|
+
// }
|
|
3146
|
+
//
|
|
3147
|
+
const bars = this.safeDict(response, 'bars', {});
|
|
3148
|
+
ohlcvs = this.safeDict(bars, marketId, {});
|
|
3149
|
+
ohlcvs = [ohlcvs];
|
|
3099
3150
|
}
|
|
3100
3151
|
else {
|
|
3101
3152
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOHLCV() does not support ' + method + ', marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported');
|
|
3102
3153
|
}
|
|
3103
|
-
//
|
|
3104
|
-
// {
|
|
3105
|
-
// "bars":{
|
|
3106
|
-
// "BTC/USD":[
|
|
3107
|
-
// {
|
|
3108
|
-
// "c":22887,
|
|
3109
|
-
// "h":22888,
|
|
3110
|
-
// "l":22873,
|
|
3111
|
-
// "n":11,
|
|
3112
|
-
// "o":22883,
|
|
3113
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
3114
|
-
// "v":1.1138,
|
|
3115
|
-
// "vw":22883.0155324116
|
|
3116
|
-
// },
|
|
3117
|
-
// {
|
|
3118
|
-
// "c":22895,
|
|
3119
|
-
// "h":22895,
|
|
3120
|
-
// "l":22884,
|
|
3121
|
-
// "n":6,
|
|
3122
|
-
// "o":22884,
|
|
3123
|
-
// "t":"2022-07-21T05:01:00Z",
|
|
3124
|
-
// "v":0.001,
|
|
3125
|
-
// "vw":22889.5
|
|
3126
|
-
// }
|
|
3127
|
-
// ]
|
|
3128
|
-
// },
|
|
3129
|
-
// "next_page_token":"QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
|
|
3130
|
-
// }
|
|
3131
|
-
//
|
|
3132
|
-
// {
|
|
3133
|
-
// "bars":{
|
|
3134
|
-
// "BTC/USD":{
|
|
3135
|
-
// "c":22887,
|
|
3136
|
-
// "h":22888,
|
|
3137
|
-
// "l":22873,
|
|
3138
|
-
// "n":11,
|
|
3139
|
-
// "o":22883,
|
|
3140
|
-
// "t":"2022-07-21T05:00:00Z",
|
|
3141
|
-
// "v":1.1138,
|
|
3142
|
-
// "vw":22883.0155324116
|
|
3143
|
-
// }
|
|
3144
|
-
// }
|
|
3145
|
-
// }
|
|
3146
|
-
//
|
|
3147
|
-
const bars = this.safeValue(response, 'bars', {});
|
|
3148
|
-
let ohlcvs = this.safeValue(bars, marketId, {});
|
|
3149
|
-
if (!Array.isArray(ohlcvs)) {
|
|
3150
|
-
ohlcvs = [ohlcvs];
|
|
3151
|
-
}
|
|
3152
3154
|
return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
|
|
3153
3155
|
}
|
|
3154
3156
|
parseOHLCV(ohlcv, market = undefined) {
|
|
@@ -9005,7 +9007,13 @@ class Exchange {
|
|
|
9005
9007
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setLeverage() is not supported yet');
|
|
9006
9008
|
}
|
|
9007
9009
|
async fetchLeverage(symbol, params = {}) {
|
|
9008
|
-
|
|
9010
|
+
if (this.has['fetchLeverages']) {
|
|
9011
|
+
const leverages = await this.fetchLeverages([symbol], params);
|
|
9012
|
+
return this.safeDict(leverages, symbol);
|
|
9013
|
+
}
|
|
9014
|
+
else {
|
|
9015
|
+
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverage() is not supported yet');
|
|
9016
|
+
}
|
|
9009
9017
|
}
|
|
9010
9018
|
async fetchLeverages(symbols = undefined, params = {}) {
|
|
9011
9019
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverages() is not supported yet');
|
|
@@ -10906,6 +10914,8 @@ class Exchange {
|
|
|
10906
10914
|
params = this.omit(params, [optionName, defaultOptionName]);
|
|
10907
10915
|
}
|
|
10908
10916
|
else {
|
|
10917
|
+
// handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
|
|
10918
|
+
[methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
|
|
10909
10919
|
// check if exchange has properties for this method
|
|
10910
10920
|
const exchangeWideMethodOptions = this.safeValue(this.options, methodName);
|
|
10911
10921
|
if (exchangeWideMethodOptions !== undefined) {
|
|
@@ -12604,6 +12614,21 @@ class Exchange {
|
|
|
12604
12614
|
parseMarginMode(marginMode, market = undefined) {
|
|
12605
12615
|
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginMode () is not supported yet');
|
|
12606
12616
|
}
|
|
12617
|
+
parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
|
|
12618
|
+
const leverageStructures = {};
|
|
12619
|
+
for (let i = 0; i < response.length; i++) {
|
|
12620
|
+
const info = response[i];
|
|
12621
|
+
const marketId = this.safeString(info, symbolKey);
|
|
12622
|
+
const market = this.safeMarket(marketId, undefined, undefined, marketType);
|
|
12623
|
+
if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
|
|
12624
|
+
leverageStructures[market['symbol']] = this.parseLeverage(info, market);
|
|
12625
|
+
}
|
|
12626
|
+
}
|
|
12627
|
+
return leverageStructures;
|
|
12628
|
+
}
|
|
12629
|
+
parseLeverage(leverage, market = undefined) {
|
|
12630
|
+
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseLeverage() is not supported yet');
|
|
12631
|
+
}
|
|
12607
12632
|
}
|
|
12608
12633
|
|
|
12609
12634
|
|
|
@@ -18209,7 +18234,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18209
18234
|
'fetchLastPrices': true,
|
|
18210
18235
|
'fetchLedger': true,
|
|
18211
18236
|
'fetchLedgerEntry': true,
|
|
18212
|
-
'fetchLeverage':
|
|
18237
|
+
'fetchLeverage': 'emulated',
|
|
18238
|
+
'fetchLeverages': true,
|
|
18213
18239
|
'fetchLeverageTiers': true,
|
|
18214
18240
|
'fetchLiquidations': false,
|
|
18215
18241
|
'fetchMarginMode': 'emulated',
|
|
@@ -22924,7 +22950,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
22924
22950
|
let stopPriceIsRequired = false;
|
|
22925
22951
|
let quantityIsRequired = false;
|
|
22926
22952
|
if (uppercaseType === 'MARKET') {
|
|
22927
|
-
const quoteOrderQty = this.
|
|
22953
|
+
const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
|
|
22928
22954
|
if (quoteOrderQty) {
|
|
22929
22955
|
const quoteOrderQtyNew = this.safeValue2(params, 'quoteOrderQty', 'cost');
|
|
22930
22956
|
const precision = market['precision']['price'];
|
|
@@ -28432,7 +28458,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28432
28458
|
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
|
|
28433
28459
|
// binanceusdm
|
|
28434
28460
|
if (e instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.MarginModeAlreadySet) {
|
|
28435
|
-
const throwMarginModeAlreadySet = this.
|
|
28461
|
+
const throwMarginModeAlreadySet = this.safeBool(this.options, 'throwMarginModeAlreadySet', false);
|
|
28436
28462
|
if (throwMarginModeAlreadySet) {
|
|
28437
28463
|
throw e;
|
|
28438
28464
|
}
|
|
@@ -28503,31 +28529,27 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28503
28529
|
//
|
|
28504
28530
|
return response;
|
|
28505
28531
|
}
|
|
28506
|
-
async
|
|
28532
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
28507
28533
|
/**
|
|
28508
28534
|
* @method
|
|
28509
|
-
* @name binance#
|
|
28510
|
-
* @description fetch the set leverage for
|
|
28535
|
+
* @name binance#fetchLeverages
|
|
28536
|
+
* @description fetch the set leverage for all markets
|
|
28511
28537
|
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
28512
28538
|
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
28513
28539
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
28514
28540
|
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
28515
|
-
* @param {string}
|
|
28541
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
28516
28542
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28517
|
-
* @returns {object} a [leverage
|
|
28543
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
28518
28544
|
*/
|
|
28519
28545
|
await this.loadMarkets();
|
|
28520
28546
|
await this.loadLeverageBrackets(false, params);
|
|
28521
|
-
const market = this.market(symbol);
|
|
28522
|
-
if (!market['contract']) {
|
|
28523
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
|
|
28524
|
-
}
|
|
28525
28547
|
let type = undefined;
|
|
28526
|
-
[type, params] = this.handleMarketTypeAndParams('
|
|
28548
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
|
|
28527
28549
|
let subType = undefined;
|
|
28528
|
-
[subType, params] = this.handleSubTypeAndParams('
|
|
28550
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
|
|
28529
28551
|
let isPortfolioMargin = undefined;
|
|
28530
|
-
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, '
|
|
28552
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
|
|
28531
28553
|
let response = undefined;
|
|
28532
28554
|
if (this.isLinear(type, subType)) {
|
|
28533
28555
|
if (isPortfolioMargin) {
|
|
@@ -28546,23 +28568,39 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28546
28568
|
}
|
|
28547
28569
|
}
|
|
28548
28570
|
else {
|
|
28549
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + '
|
|
28571
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
|
|
28550
28572
|
}
|
|
28551
|
-
const
|
|
28552
|
-
|
|
28553
|
-
|
|
28554
|
-
|
|
28555
|
-
|
|
28556
|
-
|
|
28557
|
-
|
|
28558
|
-
|
|
28559
|
-
|
|
28560
|
-
'marginMode': marginMode,
|
|
28561
|
-
'leverage': this.safeInteger(position, 'leverage'),
|
|
28562
|
-
};
|
|
28563
|
-
}
|
|
28573
|
+
const leverages = this.safeList(response, 'positions', []);
|
|
28574
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
28575
|
+
}
|
|
28576
|
+
parseLeverage(leverage, market = undefined) {
|
|
28577
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
28578
|
+
const marginModeRaw = this.safeBool(leverage, 'isolated');
|
|
28579
|
+
let marginMode = undefined;
|
|
28580
|
+
if (marginModeRaw !== undefined) {
|
|
28581
|
+
marginMode = marginModeRaw ? 'isolated' : 'cross';
|
|
28564
28582
|
}
|
|
28565
|
-
|
|
28583
|
+
const side = this.safeStringLower(leverage, 'positionSide');
|
|
28584
|
+
let longLeverage = undefined;
|
|
28585
|
+
let shortLeverage = undefined;
|
|
28586
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
28587
|
+
if (side === 'both') {
|
|
28588
|
+
longLeverage = leverageValue;
|
|
28589
|
+
shortLeverage = leverageValue;
|
|
28590
|
+
}
|
|
28591
|
+
else if (side === 'long') {
|
|
28592
|
+
longLeverage = leverageValue;
|
|
28593
|
+
}
|
|
28594
|
+
else if (side === 'short') {
|
|
28595
|
+
shortLeverage = leverageValue;
|
|
28596
|
+
}
|
|
28597
|
+
return {
|
|
28598
|
+
'info': leverage,
|
|
28599
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
28600
|
+
'marginMode': marginMode,
|
|
28601
|
+
'longLeverage': longLeverage,
|
|
28602
|
+
'shortLeverage': shortLeverage,
|
|
28603
|
+
};
|
|
28566
28604
|
}
|
|
28567
28605
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
28568
28606
|
/**
|
|
@@ -31225,7 +31263,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31225
31263
|
if (!this.checkRequiredCredentials(false)) {
|
|
31226
31264
|
return undefined;
|
|
31227
31265
|
}
|
|
31228
|
-
const isSandbox = this.
|
|
31266
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
31229
31267
|
if (isSandbox) {
|
|
31230
31268
|
return undefined;
|
|
31231
31269
|
}
|
|
@@ -31469,7 +31507,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
31469
31507
|
* @returns {object[]} an array of objects representing market data
|
|
31470
31508
|
*/
|
|
31471
31509
|
const requests = [this.fetchSwapMarkets(params)];
|
|
31472
|
-
const isSandbox = this.
|
|
31510
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
31473
31511
|
if (!isSandbox) {
|
|
31474
31512
|
requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
|
|
31475
31513
|
}
|
|
@@ -34272,7 +34310,18 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
34272
34310
|
// }
|
|
34273
34311
|
// }
|
|
34274
34312
|
//
|
|
34275
|
-
|
|
34313
|
+
const data = this.safeDict(response, 'data', {});
|
|
34314
|
+
return this.parseLeverage(data, market);
|
|
34315
|
+
}
|
|
34316
|
+
parseLeverage(leverage, market = undefined) {
|
|
34317
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
34318
|
+
return {
|
|
34319
|
+
'info': leverage,
|
|
34320
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
34321
|
+
'marginMode': undefined,
|
|
34322
|
+
'longLeverage': this.safeInteger(leverage, 'longLeverage'),
|
|
34323
|
+
'shortLeverage': this.safeInteger(leverage, 'shortLeverage'),
|
|
34324
|
+
};
|
|
34276
34325
|
}
|
|
34277
34326
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
34278
34327
|
/**
|
|
@@ -34935,7 +34984,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
34935
34984
|
const type = section[0];
|
|
34936
34985
|
const version = section[1];
|
|
34937
34986
|
const access = section[2];
|
|
34938
|
-
const isSandbox = this.
|
|
34987
|
+
const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
|
|
34939
34988
|
if (isSandbox && (type !== 'swap')) {
|
|
34940
34989
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
|
|
34941
34990
|
}
|
|
@@ -46132,7 +46181,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46132
46181
|
let defaultProductType = undefined;
|
|
46133
46182
|
if ((subType !== undefined) && (market === undefined)) {
|
|
46134
46183
|
// set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
|
|
46135
|
-
const sandboxMode = this.
|
|
46184
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
46136
46185
|
if (sandboxMode) {
|
|
46137
46186
|
defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
|
|
46138
46187
|
}
|
|
@@ -46201,7 +46250,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46201
46250
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
46202
46251
|
* @returns {object[]} an array of objects representing market data
|
|
46203
46252
|
*/
|
|
46204
|
-
const sandboxMode = this.
|
|
46253
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
46205
46254
|
let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
|
|
46206
46255
|
if (sandboxMode) {
|
|
46207
46256
|
types = ['swap'];
|
|
@@ -46656,7 +46705,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
46656
46705
|
* @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
|
|
46657
46706
|
*/
|
|
46658
46707
|
await this.loadMarkets();
|
|
46659
|
-
const sandboxMode = this.
|
|
46708
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
46660
46709
|
let market = undefined;
|
|
46661
46710
|
if (sandboxMode) {
|
|
46662
46711
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -47192,7 +47241,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47192
47241
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
47193
47242
|
*/
|
|
47194
47243
|
await this.loadMarkets();
|
|
47195
|
-
const sandboxMode = this.
|
|
47244
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
47196
47245
|
let market = undefined;
|
|
47197
47246
|
if (sandboxMode) {
|
|
47198
47247
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -47355,7 +47404,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47355
47404
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
47356
47405
|
*/
|
|
47357
47406
|
await this.loadMarkets();
|
|
47358
|
-
const sandboxMode = this.
|
|
47407
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
47359
47408
|
let market = undefined;
|
|
47360
47409
|
if (sandboxMode) {
|
|
47361
47410
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -47459,7 +47508,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47459
47508
|
let market = undefined;
|
|
47460
47509
|
if (symbols !== undefined) {
|
|
47461
47510
|
const symbol = this.safeValue(symbols, 0);
|
|
47462
|
-
const sandboxMode = this.
|
|
47511
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
47463
47512
|
if (sandboxMode) {
|
|
47464
47513
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
47465
47514
|
market = this.market(sandboxSymbol);
|
|
@@ -47677,7 +47726,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47677
47726
|
if (paginate) {
|
|
47678
47727
|
return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
|
|
47679
47728
|
}
|
|
47680
|
-
const sandboxMode = this.
|
|
47729
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
47681
47730
|
let market = undefined;
|
|
47682
47731
|
if (sandboxMode) {
|
|
47683
47732
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -47996,7 +48045,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
47996
48045
|
if (paginate) {
|
|
47997
48046
|
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
|
|
47998
48047
|
}
|
|
47999
|
-
const sandboxMode = this.
|
|
48048
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
48000
48049
|
let market = undefined;
|
|
48001
48050
|
if (sandboxMode) {
|
|
48002
48051
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -48816,7 +48865,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
48816
48865
|
return this.parseOrder(data, market);
|
|
48817
48866
|
}
|
|
48818
48867
|
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
48819
|
-
const sandboxMode = this.
|
|
48868
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
48820
48869
|
let market = undefined;
|
|
48821
48870
|
if (sandboxMode) {
|
|
48822
48871
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49087,7 +49136,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49087
49136
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
49088
49137
|
ordersRequests.push(orderRequest);
|
|
49089
49138
|
}
|
|
49090
|
-
const sandboxMode = this.
|
|
49139
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49091
49140
|
let market = undefined;
|
|
49092
49141
|
if (sandboxMode) {
|
|
49093
49142
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49184,7 +49233,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49184
49233
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
49185
49234
|
*/
|
|
49186
49235
|
await this.loadMarkets();
|
|
49187
|
-
const sandboxMode = this.
|
|
49236
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49188
49237
|
let market = undefined;
|
|
49189
49238
|
if (sandboxMode) {
|
|
49190
49239
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49220,7 +49269,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49220
49269
|
params = this.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent']);
|
|
49221
49270
|
let response = undefined;
|
|
49222
49271
|
if (market['spot']) {
|
|
49223
|
-
const editMarketBuyOrderRequiresPrice = this.
|
|
49272
|
+
const editMarketBuyOrderRequiresPrice = this.safeBool(this.options, 'editMarketBuyOrderRequiresPrice', true);
|
|
49224
49273
|
if (editMarketBuyOrderRequiresPrice && isMarketOrder && (side === 'buy')) {
|
|
49225
49274
|
if (price === undefined) {
|
|
49226
49275
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively set the editMarketBuyOrderRequiresPrice option to false and pass in the cost to spend into the amount parameter');
|
|
@@ -49350,7 +49399,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49350
49399
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
49351
49400
|
}
|
|
49352
49401
|
await this.loadMarkets();
|
|
49353
|
-
const sandboxMode = this.
|
|
49402
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49354
49403
|
let market = undefined;
|
|
49355
49404
|
if (sandboxMode) {
|
|
49356
49405
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49490,7 +49539,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49490
49539
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
|
|
49491
49540
|
}
|
|
49492
49541
|
await this.loadMarkets();
|
|
49493
|
-
const sandboxMode = this.
|
|
49542
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49494
49543
|
let market = undefined;
|
|
49495
49544
|
if (sandboxMode) {
|
|
49496
49545
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49584,7 +49633,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49584
49633
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
|
|
49585
49634
|
}
|
|
49586
49635
|
await this.loadMarkets();
|
|
49587
|
-
const sandboxMode = this.
|
|
49636
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49588
49637
|
let market = undefined;
|
|
49589
49638
|
if (sandboxMode) {
|
|
49590
49639
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49688,7 +49737,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49688
49737
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
49689
49738
|
}
|
|
49690
49739
|
await this.loadMarkets();
|
|
49691
|
-
const sandboxMode = this.
|
|
49740
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49692
49741
|
let market = undefined;
|
|
49693
49742
|
if (sandboxMode) {
|
|
49694
49743
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -49804,7 +49853,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49804
49853
|
* @param {int} [limit] the maximum number of open order structures to retrieve
|
|
49805
49854
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
49806
49855
|
* @param {int} [params.until] the latest time in ms to fetch orders for
|
|
49807
|
-
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'track_plan': trailing stop order, default is 'normal_plan'
|
|
49856
|
+
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
|
|
49808
49857
|
* @param {boolean} [params.stop] set to true for fetching trigger orders
|
|
49809
49858
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
49810
49859
|
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
|
@@ -49812,7 +49861,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49812
49861
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
49813
49862
|
*/
|
|
49814
49863
|
await this.loadMarkets();
|
|
49815
|
-
const sandboxMode = this.
|
|
49864
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
49816
49865
|
let market = undefined;
|
|
49817
49866
|
let type = undefined;
|
|
49818
49867
|
let request = {};
|
|
@@ -49850,8 +49899,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49850
49899
|
return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
|
|
49851
49900
|
}
|
|
49852
49901
|
let response = undefined;
|
|
49853
|
-
const trailing = this.
|
|
49854
|
-
const stop = this.
|
|
49902
|
+
const trailing = this.safeBool(params, 'trailing');
|
|
49903
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
49904
|
+
const planTypeDefined = this.safeString(params, 'planType') !== undefined;
|
|
49905
|
+
const isStop = (stop || planTypeDefined);
|
|
49855
49906
|
params = this.omit(params, ['stop', 'trigger', 'trailing']);
|
|
49856
49907
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
49857
49908
|
if (since !== undefined) {
|
|
@@ -49900,7 +49951,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
49900
49951
|
request['planType'] = planType;
|
|
49901
49952
|
response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
|
|
49902
49953
|
}
|
|
49903
|
-
else if (
|
|
49954
|
+
else if (isStop) {
|
|
49904
49955
|
const planType = this.safeString(query, 'planType', 'normal_plan');
|
|
49905
49956
|
request['planType'] = planType;
|
|
49906
49957
|
response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
|
|
@@ -50167,7 +50218,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50167
50218
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
50168
50219
|
*/
|
|
50169
50220
|
await this.loadMarkets();
|
|
50170
|
-
const sandboxMode = this.
|
|
50221
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
50171
50222
|
let market = undefined;
|
|
50172
50223
|
if (sandboxMode) {
|
|
50173
50224
|
if (symbol !== undefined) {
|
|
@@ -50200,7 +50251,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50200
50251
|
}
|
|
50201
50252
|
let response = undefined;
|
|
50202
50253
|
const trailing = this.safeValue(params, 'trailing');
|
|
50203
|
-
const stop = this.
|
|
50254
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
50204
50255
|
params = this.omit(params, ['stop', 'trigger', 'trailing']);
|
|
50205
50256
|
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
50206
50257
|
if (since !== undefined) {
|
|
@@ -50484,7 +50535,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50484
50535
|
params = this.omit(params, 'symbol');
|
|
50485
50536
|
let market = undefined;
|
|
50486
50537
|
if (symbol !== undefined) {
|
|
50487
|
-
const sandboxMode = this.
|
|
50538
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
50488
50539
|
if (sandboxMode) {
|
|
50489
50540
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
50490
50541
|
market = this.market(sandboxSymbol);
|
|
@@ -50704,7 +50755,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50704
50755
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
|
|
50705
50756
|
}
|
|
50706
50757
|
await this.loadMarkets();
|
|
50707
|
-
const sandboxMode = this.
|
|
50758
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
50708
50759
|
let market = undefined;
|
|
50709
50760
|
if (sandboxMode) {
|
|
50710
50761
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -50883,7 +50934,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50883
50934
|
* @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
50884
50935
|
*/
|
|
50885
50936
|
await this.loadMarkets();
|
|
50886
|
-
const sandboxMode = this.
|
|
50937
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
50887
50938
|
let market = undefined;
|
|
50888
50939
|
if (sandboxMode) {
|
|
50889
50940
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -50959,7 +51010,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
50959
51010
|
let market = undefined;
|
|
50960
51011
|
if (symbols !== undefined) {
|
|
50961
51012
|
const first = this.safeString(symbols, 0);
|
|
50962
|
-
const sandboxMode = this.
|
|
51013
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
50963
51014
|
if (sandboxMode) {
|
|
50964
51015
|
const sandboxSymbol = this.convertSymbolForSandbox(first);
|
|
50965
51016
|
market = this.market(sandboxSymbol);
|
|
@@ -51279,7 +51330,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51279
51330
|
if (paginate) {
|
|
51280
51331
|
return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
|
|
51281
51332
|
}
|
|
51282
|
-
const sandboxMode = this.
|
|
51333
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51283
51334
|
let market = undefined;
|
|
51284
51335
|
if (sandboxMode) {
|
|
51285
51336
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51343,7 +51394,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51343
51394
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
51344
51395
|
*/
|
|
51345
51396
|
await this.loadMarkets();
|
|
51346
|
-
const sandboxMode = this.
|
|
51397
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51347
51398
|
let market = undefined;
|
|
51348
51399
|
if (sandboxMode) {
|
|
51349
51400
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51430,7 +51481,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51430
51481
|
if (paginate) {
|
|
51431
51482
|
return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
|
|
51432
51483
|
}
|
|
51433
|
-
const sandboxMode = this.
|
|
51484
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51434
51485
|
let market = undefined;
|
|
51435
51486
|
if (sandboxMode) {
|
|
51436
51487
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51526,7 +51577,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51526
51577
|
async modifyMarginHelper(symbol, amount, type, params = {}) {
|
|
51527
51578
|
await this.loadMarkets();
|
|
51528
51579
|
const holdSide = this.safeString(params, 'holdSide');
|
|
51529
|
-
const sandboxMode = this.
|
|
51580
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51530
51581
|
let market = undefined;
|
|
51531
51582
|
if (sandboxMode) {
|
|
51532
51583
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51619,7 +51670,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51619
51670
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
51620
51671
|
*/
|
|
51621
51672
|
await this.loadMarkets();
|
|
51622
|
-
const sandboxMode = this.
|
|
51673
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51623
51674
|
let market = undefined;
|
|
51624
51675
|
if (sandboxMode) {
|
|
51625
51676
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51640,28 +51691,41 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51640
51691
|
// {
|
|
51641
51692
|
// "code": "00000",
|
|
51642
51693
|
// "msg": "success",
|
|
51643
|
-
// "requestTime":
|
|
51644
|
-
// "data":
|
|
51645
|
-
//
|
|
51646
|
-
//
|
|
51647
|
-
//
|
|
51648
|
-
//
|
|
51649
|
-
//
|
|
51650
|
-
//
|
|
51651
|
-
//
|
|
51652
|
-
//
|
|
51653
|
-
//
|
|
51654
|
-
//
|
|
51655
|
-
//
|
|
51656
|
-
//
|
|
51657
|
-
//
|
|
51658
|
-
//
|
|
51659
|
-
//
|
|
51660
|
-
//
|
|
51661
|
-
//
|
|
51694
|
+
// "requestTime": 1709366911964,
|
|
51695
|
+
// "data": {
|
|
51696
|
+
// "marginCoin": "USDT",
|
|
51697
|
+
// "locked": "0",
|
|
51698
|
+
// "available": "0",
|
|
51699
|
+
// "crossedMaxAvailable": "0",
|
|
51700
|
+
// "isolatedMaxAvailable": "0",
|
|
51701
|
+
// "maxTransferOut": "0",
|
|
51702
|
+
// "accountEquity": "0",
|
|
51703
|
+
// "usdtEquity": "0.000000009166",
|
|
51704
|
+
// "btcEquity": "0",
|
|
51705
|
+
// "crossedRiskRate": "0",
|
|
51706
|
+
// "crossedMarginLeverage": 20,
|
|
51707
|
+
// "isolatedLongLever": 20,
|
|
51708
|
+
// "isolatedShortLever": 20,
|
|
51709
|
+
// "marginMode": "crossed",
|
|
51710
|
+
// "posMode": "hedge_mode",
|
|
51711
|
+
// "unrealizedPL": "0",
|
|
51712
|
+
// "coupon": "0",
|
|
51713
|
+
// "crossedUnrealizedPL": "0",
|
|
51714
|
+
// "isolatedUnrealizedPL": ""
|
|
51715
|
+
// }
|
|
51662
51716
|
// }
|
|
51663
51717
|
//
|
|
51664
|
-
|
|
51718
|
+
const data = this.safeDict(response, 'data', {});
|
|
51719
|
+
return this.parseLeverage(data, market);
|
|
51720
|
+
}
|
|
51721
|
+
parseLeverage(leverage, market = undefined) {
|
|
51722
|
+
return {
|
|
51723
|
+
'info': leverage,
|
|
51724
|
+
'symbol': market['symbol'],
|
|
51725
|
+
'marginMode': 'isolated',
|
|
51726
|
+
'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
|
|
51727
|
+
'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
|
|
51728
|
+
};
|
|
51665
51729
|
}
|
|
51666
51730
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
51667
51731
|
/**
|
|
@@ -51679,7 +51743,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51679
51743
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
|
|
51680
51744
|
}
|
|
51681
51745
|
await this.loadMarkets();
|
|
51682
|
-
const sandboxMode = this.
|
|
51746
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51683
51747
|
let market = undefined;
|
|
51684
51748
|
if (sandboxMode) {
|
|
51685
51749
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51737,7 +51801,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51737
51801
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
|
|
51738
51802
|
}
|
|
51739
51803
|
await this.loadMarkets();
|
|
51740
|
-
const sandboxMode = this.
|
|
51804
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51741
51805
|
let market = undefined;
|
|
51742
51806
|
if (sandboxMode) {
|
|
51743
51807
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -51787,7 +51851,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51787
51851
|
const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
|
|
51788
51852
|
let market = undefined;
|
|
51789
51853
|
if (symbol !== undefined) {
|
|
51790
|
-
const sandboxMode = this.
|
|
51854
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51791
51855
|
if (sandboxMode) {
|
|
51792
51856
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
51793
51857
|
market = this.market(sandboxSymbol);
|
|
@@ -51826,7 +51890,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
51826
51890
|
* @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
|
|
51827
51891
|
*/
|
|
51828
51892
|
await this.loadMarkets();
|
|
51829
|
-
const sandboxMode = this.
|
|
51893
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
51830
51894
|
let market = undefined;
|
|
51831
51895
|
if (sandboxMode) {
|
|
51832
51896
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -52860,7 +52924,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
52860
52924
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
52861
52925
|
*/
|
|
52862
52926
|
await this.loadMarkets();
|
|
52863
|
-
const sandboxMode = this.
|
|
52927
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
52864
52928
|
let market = undefined;
|
|
52865
52929
|
if (sandboxMode) {
|
|
52866
52930
|
const sandboxSymbol = this.convertSymbolForSandbox(symbol);
|
|
@@ -58715,7 +58779,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
58715
58779
|
'fetchFundingRates': true,
|
|
58716
58780
|
'fetchIndexOHLCV': false,
|
|
58717
58781
|
'fetchLedger': true,
|
|
58718
|
-
'fetchLeverage':
|
|
58782
|
+
'fetchLeverage': 'emulated',
|
|
58719
58783
|
'fetchLeverages': true,
|
|
58720
58784
|
'fetchLeverageTiers': false,
|
|
58721
58785
|
'fetchLiquidations': true,
|
|
@@ -60163,7 +60227,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
60163
60227
|
request['endTime'] = this.iso8601(until);
|
|
60164
60228
|
}
|
|
60165
60229
|
const duration = this.parseTimeframe(timeframe) * 1000;
|
|
60166
|
-
const fetchOHLCVOpenTimestamp = this.
|
|
60230
|
+
const fetchOHLCVOpenTimestamp = this.safeBool(this.options, 'fetchOHLCVOpenTimestamp', true);
|
|
60167
60231
|
// if since is not set, they will return candles starting from 2017-01-01
|
|
60168
60232
|
if (since !== undefined) {
|
|
60169
60233
|
let timestamp = since;
|
|
@@ -60782,34 +60846,18 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
60782
60846
|
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
60783
60847
|
*/
|
|
60784
60848
|
await this.loadMarkets();
|
|
60785
|
-
const
|
|
60786
|
-
|
|
60787
|
-
for (let i = 0; i < positions.length; i++) {
|
|
60788
|
-
const entry = positions[i];
|
|
60789
|
-
const marketId = this.safeString(entry, 'symbol');
|
|
60790
|
-
const market = this.safeMarket(marketId, undefined, undefined, 'contract');
|
|
60791
|
-
result.push({
|
|
60792
|
-
'info': entry,
|
|
60793
|
-
'symbol': market['symbol'],
|
|
60794
|
-
'leverage': this.safeInteger(entry, 'leverage'),
|
|
60795
|
-
'marginMode': this.safeString(entry, 'marginMode'),
|
|
60796
|
-
});
|
|
60797
|
-
}
|
|
60798
|
-
return result;
|
|
60849
|
+
const leverages = await this.fetchPositions(symbols, params);
|
|
60850
|
+
return this.parseLeverages(leverages, symbols, 'symbol');
|
|
60799
60851
|
}
|
|
60800
|
-
|
|
60801
|
-
|
|
60802
|
-
|
|
60803
|
-
|
|
60804
|
-
|
|
60805
|
-
|
|
60806
|
-
|
|
60807
|
-
|
|
60808
|
-
|
|
60809
|
-
*/
|
|
60810
|
-
await this.loadMarkets();
|
|
60811
|
-
const leverage = await this.fetchLeverages([symbol], params);
|
|
60812
|
-
return leverage;
|
|
60852
|
+
parseLeverage(leverage, market = undefined) {
|
|
60853
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
60854
|
+
return {
|
|
60855
|
+
'info': leverage,
|
|
60856
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
60857
|
+
'marginMode': this.safeStringLower(leverage, 'marginMode'),
|
|
60858
|
+
'longLeverage': this.safeInteger(leverage, 'leverage'),
|
|
60859
|
+
'shortLeverage': this.safeInteger(leverage, 'leverage'),
|
|
60860
|
+
};
|
|
60813
60861
|
}
|
|
60814
60862
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
60815
60863
|
/**
|
|
@@ -65969,20 +66017,29 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
65969
66017
|
}
|
|
65970
66018
|
const response = await this.spotV1PrivateGetWithdrawHistory(this.extend(request, params));
|
|
65971
66019
|
//
|
|
65972
|
-
//
|
|
65973
|
-
//
|
|
65974
|
-
//
|
|
65975
|
-
//
|
|
65976
|
-
//
|
|
65977
|
-
//
|
|
65978
|
-
//
|
|
65979
|
-
//
|
|
65980
|
-
//
|
|
65981
|
-
//
|
|
65982
|
-
//
|
|
65983
|
-
//
|
|
66020
|
+
// {
|
|
66021
|
+
// "code": 200,
|
|
66022
|
+
// "msg": "succ",
|
|
66023
|
+
// "data": [
|
|
66024
|
+
// {
|
|
66025
|
+
// "id": 183745,
|
|
66026
|
+
// "symbol": "usdt_erc20",
|
|
66027
|
+
// "amount": "8.4000000000000000",
|
|
66028
|
+
// "fee": "1.6000000000000000",
|
|
66029
|
+
// "payAmount": "0.0000000000000000",
|
|
66030
|
+
// "createdAt": 1595336441000,
|
|
66031
|
+
// "updatedAt": 1595336576000,
|
|
66032
|
+
// "addressFrom": "",
|
|
66033
|
+
// "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83",
|
|
66034
|
+
// "txid": "",
|
|
66035
|
+
// "confirmations": 0,
|
|
66036
|
+
// "status": 6,
|
|
66037
|
+
// "tagType": null
|
|
66038
|
+
// }
|
|
66039
|
+
// ]
|
|
66040
|
+
// }
|
|
65984
66041
|
//
|
|
65985
|
-
const data = this.
|
|
66042
|
+
const data = this.safeList(response, 'data', []);
|
|
65986
66043
|
return this.parseTransactions(data, currency);
|
|
65987
66044
|
}
|
|
65988
66045
|
parseTransactionStatusByType(status, type = undefined) {
|
|
@@ -66325,7 +66382,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
66325
66382
|
// }]
|
|
66326
66383
|
// }
|
|
66327
66384
|
//
|
|
66328
|
-
const data = this.
|
|
66385
|
+
const data = this.safeList(response, 'data', []);
|
|
66329
66386
|
return this.parseTransfers(data, currency, since, limit);
|
|
66330
66387
|
}
|
|
66331
66388
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
|
@@ -77221,7 +77278,7 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
77221
77278
|
const symbol = market['symbol'];
|
|
77222
77279
|
const last = this.safeString(ticker, 'last');
|
|
77223
77280
|
const open = this.safeString(ticker, 'open24h');
|
|
77224
|
-
const spot = this.
|
|
77281
|
+
const spot = this.safeBool(market, 'spot', false);
|
|
77225
77282
|
const quoteVolume = spot ? this.safeString(ticker, 'volCurrency24h') : undefined;
|
|
77226
77283
|
const baseVolume = this.safeString(ticker, 'vol24h');
|
|
77227
77284
|
const high = this.safeString(ticker, 'high24h');
|
|
@@ -78640,7 +78697,30 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
78640
78697
|
'marginMode': marginMode,
|
|
78641
78698
|
};
|
|
78642
78699
|
const response = await this.privateGetAccountLeverageInfo(this.extend(request, params));
|
|
78643
|
-
|
|
78700
|
+
//
|
|
78701
|
+
// {
|
|
78702
|
+
// "code": "0",
|
|
78703
|
+
// "msg": "success",
|
|
78704
|
+
// "data": {
|
|
78705
|
+
// "leverage": "3",
|
|
78706
|
+
// "marginMode": "cross",
|
|
78707
|
+
// "instId": "BTC-USDT"
|
|
78708
|
+
// }
|
|
78709
|
+
// }
|
|
78710
|
+
//
|
|
78711
|
+
const data = this.safeDict(response, 'data', {});
|
|
78712
|
+
return this.parseLeverage(data, market);
|
|
78713
|
+
}
|
|
78714
|
+
parseLeverage(leverage, market = undefined) {
|
|
78715
|
+
const marketId = this.safeString(leverage, 'instId');
|
|
78716
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
78717
|
+
return {
|
|
78718
|
+
'info': leverage,
|
|
78719
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
78720
|
+
'marginMode': this.safeStringLower(leverage, 'marginMode'),
|
|
78721
|
+
'longLeverage': leverageValue,
|
|
78722
|
+
'shortLeverage': leverageValue,
|
|
78723
|
+
};
|
|
78644
78724
|
}
|
|
78645
78725
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
78646
78726
|
/**
|
|
@@ -88964,11 +89044,19 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
88964
89044
|
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
88965
89045
|
*/
|
|
88966
89046
|
await this.loadMarkets();
|
|
89047
|
+
const market = this.market(symbol);
|
|
88967
89048
|
const position = await this.fetchPosition(symbol, params);
|
|
89049
|
+
return this.parseLeverage(position, market);
|
|
89050
|
+
}
|
|
89051
|
+
parseLeverage(leverage, market = undefined) {
|
|
89052
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
89053
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
88968
89054
|
return {
|
|
88969
|
-
'info':
|
|
88970
|
-
'
|
|
88971
|
-
'marginMode': this.
|
|
89055
|
+
'info': leverage,
|
|
89056
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
89057
|
+
'marginMode': this.safeStringLower(leverage, 'marginMode'),
|
|
89058
|
+
'longLeverage': leverageValue,
|
|
89059
|
+
'shortLeverage': leverageValue,
|
|
88972
89060
|
};
|
|
88973
89061
|
}
|
|
88974
89062
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
@@ -95448,10 +95536,12 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
95448
95536
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
95449
95537
|
*/
|
|
95450
95538
|
await this.loadMarkets();
|
|
95539
|
+
const maxLimit = 300;
|
|
95540
|
+
limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
|
|
95451
95541
|
let paginate = false;
|
|
95452
95542
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate', false);
|
|
95453
95543
|
if (paginate) {
|
|
95454
|
-
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params,
|
|
95544
|
+
return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimit - 1);
|
|
95455
95545
|
}
|
|
95456
95546
|
const market = this.market(symbol);
|
|
95457
95547
|
const request = {
|
|
@@ -95461,20 +95551,20 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
95461
95551
|
const until = this.safeValueN(params, ['until', 'till', 'end']);
|
|
95462
95552
|
params = this.omit(params, ['until', 'till']);
|
|
95463
95553
|
const duration = this.parseTimeframe(timeframe);
|
|
95464
|
-
const
|
|
95554
|
+
const requestedDuration = limit * duration;
|
|
95465
95555
|
let sinceString = undefined;
|
|
95466
95556
|
if (since !== undefined) {
|
|
95467
95557
|
sinceString = this.numberToString(this.parseToInt(since / 1000));
|
|
95468
95558
|
}
|
|
95469
95559
|
else {
|
|
95470
95560
|
const now = this.seconds().toString();
|
|
95471
|
-
sinceString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringSub(now,
|
|
95561
|
+
sinceString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringSub(now, requestedDuration.toString());
|
|
95472
95562
|
}
|
|
95473
95563
|
request['start'] = sinceString;
|
|
95474
95564
|
let endString = this.numberToString(until);
|
|
95475
95565
|
if (until === undefined) {
|
|
95476
95566
|
// 300 candles max
|
|
95477
|
-
endString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(sinceString,
|
|
95567
|
+
endString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(sinceString, requestedDuration.toString());
|
|
95478
95568
|
}
|
|
95479
95569
|
request['end'] = endString;
|
|
95480
95570
|
const response = await this.v3PrivateGetBrokerageProductsProductIdCandles(this.extend(request, params));
|
|
@@ -95534,8 +95624,19 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
95534
95624
|
const request = {
|
|
95535
95625
|
'product_id': market['id'],
|
|
95536
95626
|
};
|
|
95627
|
+
if (since !== undefined) {
|
|
95628
|
+
request['start'] = this.numberToString(this.parseToInt(since / 1000));
|
|
95629
|
+
}
|
|
95537
95630
|
if (limit !== undefined) {
|
|
95538
|
-
request['limit'] = limit;
|
|
95631
|
+
request['limit'] = Math.min(limit, 1000);
|
|
95632
|
+
}
|
|
95633
|
+
let until = undefined;
|
|
95634
|
+
[until, params] = this.handleOptionAndParams(params, 'fetchTrades', 'until');
|
|
95635
|
+
if (until !== undefined) {
|
|
95636
|
+
request['end'] = this.numberToString(this.parseToInt(until / 1000));
|
|
95637
|
+
}
|
|
95638
|
+
else if (since !== undefined) {
|
|
95639
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchTrades() requires a `until` parameter when you use `since` argument');
|
|
95539
95640
|
}
|
|
95540
95641
|
const response = await this.v3PrivateGetBrokerageProductsProductIdTicker(this.extend(request, params));
|
|
95541
95642
|
//
|
|
@@ -95669,7 +95770,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
95669
95770
|
// }
|
|
95670
95771
|
// }
|
|
95671
95772
|
//
|
|
95672
|
-
const data = this.
|
|
95773
|
+
const data = this.safeDict(response, 'pricebook', {});
|
|
95673
95774
|
const time = this.safeString(data, 'time');
|
|
95674
95775
|
const timestamp = this.parse8601(time);
|
|
95675
95776
|
return this.parseOrderBook(data, symbol, timestamp, 'bids', 'asks', 'price', 'size');
|
|
@@ -96122,7 +96223,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
96122
96223
|
}
|
|
96123
96224
|
else {
|
|
96124
96225
|
this.checkRequiredCredentials();
|
|
96125
|
-
const
|
|
96226
|
+
const timestampString = this.seconds().toString();
|
|
96126
96227
|
let payload = '';
|
|
96127
96228
|
if (method !== 'GET') {
|
|
96128
96229
|
if (Object.keys(query).length) {
|
|
@@ -96130,17 +96231,14 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
96130
96231
|
payload = body;
|
|
96131
96232
|
}
|
|
96132
96233
|
}
|
|
96133
|
-
|
|
96134
|
-
|
|
96135
|
-
|
|
96136
|
-
}
|
|
96137
|
-
}
|
|
96138
|
-
const auth = nonce + method + savedPath + payload;
|
|
96234
|
+
// 'GET' doesn't need payload in the signature. inside url is enough
|
|
96235
|
+
// https://docs.cloud.coinbase.com/advanced-trade-api/docs/auth#example-request
|
|
96236
|
+
const auth = timestampString + method + savedPath + payload;
|
|
96139
96237
|
const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
|
|
96140
96238
|
headers = {
|
|
96141
96239
|
'CB-ACCESS-KEY': this.apiKey,
|
|
96142
96240
|
'CB-ACCESS-SIGN': signature,
|
|
96143
|
-
'CB-ACCESS-TIMESTAMP':
|
|
96241
|
+
'CB-ACCESS-TIMESTAMP': timestampString,
|
|
96144
96242
|
'Content-Type': 'application/json',
|
|
96145
96243
|
};
|
|
96146
96244
|
}
|
|
@@ -118369,12 +118467,22 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
|
|
|
118369
118467
|
};
|
|
118370
118468
|
const response = await this.privateGetV2LeverageSettings(this.extend(request, params));
|
|
118371
118469
|
//
|
|
118372
|
-
//
|
|
118373
|
-
//
|
|
118374
|
-
//
|
|
118375
|
-
//
|
|
118470
|
+
// {
|
|
118471
|
+
// "values": [ 1, 2, 5, 10, ],
|
|
118472
|
+
// "value": "10",
|
|
118473
|
+
// }
|
|
118376
118474
|
//
|
|
118377
|
-
return this.
|
|
118475
|
+
return this.parseLeverage(response, market);
|
|
118476
|
+
}
|
|
118477
|
+
parseLeverage(leverage, market = undefined) {
|
|
118478
|
+
const leverageValue = this.safeInteger(leverage, 'value');
|
|
118479
|
+
return {
|
|
118480
|
+
'info': leverage,
|
|
118481
|
+
'symbol': market['symbol'],
|
|
118482
|
+
'marginMode': undefined,
|
|
118483
|
+
'longLeverage': leverageValue,
|
|
118484
|
+
'shortLeverage': leverageValue,
|
|
118485
|
+
};
|
|
118378
118486
|
}
|
|
118379
118487
|
async fetchDepositAddress(code, params = {}) {
|
|
118380
118488
|
/**
|
|
@@ -121421,6 +121529,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
121421
121529
|
const request = {
|
|
121422
121530
|
'product_id': market['numericId'],
|
|
121423
121531
|
};
|
|
121532
|
+
const response = await this.privateGetProductsProductIdOrdersLeverage(this.extend(request, params));
|
|
121424
121533
|
//
|
|
121425
121534
|
// {
|
|
121426
121535
|
// "result": {
|
|
@@ -121434,7 +121543,19 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
121434
121543
|
// "success": true
|
|
121435
121544
|
// }
|
|
121436
121545
|
//
|
|
121437
|
-
|
|
121546
|
+
const result = this.safeDict(response, 'result', {});
|
|
121547
|
+
return this.parseLeverage(result, market);
|
|
121548
|
+
}
|
|
121549
|
+
parseLeverage(leverage, market = undefined) {
|
|
121550
|
+
const marketId = this.safeString(leverage, 'index_symbol');
|
|
121551
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
121552
|
+
return {
|
|
121553
|
+
'info': leverage,
|
|
121554
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
121555
|
+
'marginMode': this.safeStringLower(leverage, 'margin_mode'),
|
|
121556
|
+
'longLeverage': leverageValue,
|
|
121557
|
+
'shortLeverage': leverageValue,
|
|
121558
|
+
};
|
|
121438
121559
|
}
|
|
121439
121560
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
121440
121561
|
/**
|
|
@@ -133416,7 +133537,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
133416
133537
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
133417
133538
|
* @returns {object[]} an array of objects representing market data
|
|
133418
133539
|
*/
|
|
133419
|
-
const sandboxMode = this.
|
|
133540
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
133420
133541
|
let rawPromises = [
|
|
133421
133542
|
this.fetchContractMarkets(params),
|
|
133422
133543
|
this.fetchOptionMarkets(params),
|
|
@@ -144752,7 +144873,18 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
144752
144873
|
// ]
|
|
144753
144874
|
// }
|
|
144754
144875
|
//
|
|
144755
|
-
return this.
|
|
144876
|
+
return this.parseLeverage(response, market);
|
|
144877
|
+
}
|
|
144878
|
+
parseLeverage(leverage, market = undefined) {
|
|
144879
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
144880
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
144881
|
+
return {
|
|
144882
|
+
'info': leverage,
|
|
144883
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
144884
|
+
'marginMode': this.safeStringLower(leverage, 'type'),
|
|
144885
|
+
'longLeverage': leverageValue,
|
|
144886
|
+
'shortLeverage': leverageValue,
|
|
144887
|
+
};
|
|
144756
144888
|
}
|
|
144757
144889
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
144758
144890
|
/**
|
|
@@ -167498,7 +167630,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
167498
167630
|
//
|
|
167499
167631
|
return await this.privatePutLeveragepreferences(this.extend(request, params));
|
|
167500
167632
|
}
|
|
167501
|
-
async fetchLeverage(symbol
|
|
167633
|
+
async fetchLeverage(symbol, params = {}) {
|
|
167502
167634
|
/**
|
|
167503
167635
|
* @method
|
|
167504
167636
|
* @name krakenfutures#fetchLeverage
|
|
@@ -167512,17 +167644,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
|
|
|
167512
167644
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchLeverage() requires a symbol argument');
|
|
167513
167645
|
}
|
|
167514
167646
|
await this.loadMarkets();
|
|
167647
|
+
const market = this.market(symbol);
|
|
167515
167648
|
const request = {
|
|
167516
167649
|
'symbol': this.marketId(symbol).toUpperCase(),
|
|
167517
167650
|
};
|
|
167651
|
+
const response = await this.privateGetLeveragepreferences(this.extend(request, params));
|
|
167518
167652
|
//
|
|
167519
|
-
//
|
|
167520
|
-
//
|
|
167521
|
-
//
|
|
167522
|
-
//
|
|
167523
|
-
//
|
|
167653
|
+
// {
|
|
167654
|
+
// "result": "success",
|
|
167655
|
+
// "serverTime": "2023-08-01T09:54:08.900Z",
|
|
167656
|
+
// "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
|
|
167657
|
+
// }
|
|
167524
167658
|
//
|
|
167525
|
-
|
|
167659
|
+
const leveragePreferences = this.safeList(response, 'leveragePreferences', []);
|
|
167660
|
+
const data = this.safeDict(leveragePreferences, 0, {});
|
|
167661
|
+
return this.parseLeverage(data, market);
|
|
167662
|
+
}
|
|
167663
|
+
parseLeverage(leverage, market = undefined) {
|
|
167664
|
+
const marketId = this.safeString(leverage, 'symbol');
|
|
167665
|
+
const leverageValue = this.safeInteger(leverage, 'maxLeverage');
|
|
167666
|
+
return {
|
|
167667
|
+
'info': leverage,
|
|
167668
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
167669
|
+
'marginMode': undefined,
|
|
167670
|
+
'longLeverage': leverageValue,
|
|
167671
|
+
'shortLeverage': leverageValue,
|
|
167672
|
+
};
|
|
167526
167673
|
}
|
|
167527
167674
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
167528
167675
|
if (response === undefined) {
|
|
@@ -175459,7 +175606,7 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
175459
175606
|
await this.loadMarkets();
|
|
175460
175607
|
const market = this.market(symbol);
|
|
175461
175608
|
const request = {
|
|
175462
|
-
'
|
|
175609
|
+
'pairs': market['id'],
|
|
175463
175610
|
};
|
|
175464
175611
|
if (limit !== undefined) {
|
|
175465
175612
|
request['limit'] = limit;
|
|
@@ -175467,18 +175614,21 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
175467
175614
|
const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
|
|
175468
175615
|
//
|
|
175469
175616
|
// {
|
|
175470
|
-
//
|
|
175471
|
-
//
|
|
175472
|
-
//
|
|
175473
|
-
//
|
|
175474
|
-
//
|
|
175475
|
-
//
|
|
175476
|
-
//
|
|
175477
|
-
//
|
|
175478
|
-
//
|
|
175617
|
+
// 'data': [
|
|
175618
|
+
// {
|
|
175619
|
+
// 'createdAt': '2024-03-02T00:10:49.385Z',
|
|
175620
|
+
// 'id': '3b42878a-3688-4bc1-891e-5cc2fc902142',
|
|
175621
|
+
// 'matchPrice': '62181.31',
|
|
175622
|
+
// 'matchQuantity': '0.00568',
|
|
175623
|
+
// 'pair': 'BTC_USDT',
|
|
175624
|
+
// 'quoteQuantity': '353.1898408',
|
|
175625
|
+
// 'side': 'Bid'
|
|
175626
|
+
// },
|
|
175627
|
+
// ...
|
|
175628
|
+
// ]
|
|
175479
175629
|
// }
|
|
175480
175630
|
//
|
|
175481
|
-
const data = this.
|
|
175631
|
+
const data = this.safeList(response, 'data', []);
|
|
175482
175632
|
return this.parseTrades(data, market, since, limit);
|
|
175483
175633
|
}
|
|
175484
175634
|
parseTrade(trade, market = undefined) {
|
|
@@ -181062,7 +181212,7 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
181062
181212
|
const uppercaseHash = hash.toUpperCase();
|
|
181063
181213
|
let sign = undefined;
|
|
181064
181214
|
if (signatureMethod === 'RSA') {
|
|
181065
|
-
const cacheSecretAsPem = this.
|
|
181215
|
+
const cacheSecretAsPem = this.safeBool(this.options, 'cacheSecretAsPem', true);
|
|
181066
181216
|
let pem = undefined;
|
|
181067
181217
|
if (cacheSecretAsPem) {
|
|
181068
181218
|
pem = this.safeValue(this.options, 'pem');
|
|
@@ -190050,30 +190200,30 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
190050
190200
|
// }
|
|
190051
190201
|
//
|
|
190052
190202
|
const data = this.safeList(response, 'data', []);
|
|
190053
|
-
|
|
190054
|
-
return this.parseLeverage(longLeverage, market);
|
|
190203
|
+
return this.parseLeverage(data, market);
|
|
190055
190204
|
}
|
|
190056
190205
|
parseLeverage(leverage, market = undefined) {
|
|
190057
|
-
|
|
190058
|
-
|
|
190059
|
-
|
|
190060
|
-
|
|
190061
|
-
|
|
190062
|
-
|
|
190063
|
-
|
|
190064
|
-
|
|
190065
|
-
|
|
190066
|
-
|
|
190067
|
-
|
|
190068
|
-
|
|
190069
|
-
|
|
190070
|
-
|
|
190071
|
-
|
|
190206
|
+
let marginMode = undefined;
|
|
190207
|
+
let longLeverage = undefined;
|
|
190208
|
+
let shortLeverage = undefined;
|
|
190209
|
+
for (let i = 0; i < leverage.length; i++) {
|
|
190210
|
+
const entry = leverage[i];
|
|
190211
|
+
const openType = this.safeInteger(entry, 'openType');
|
|
190212
|
+
const positionType = this.safeInteger(entry, 'positionType');
|
|
190213
|
+
if (positionType === 1) {
|
|
190214
|
+
longLeverage = this.safeInteger(entry, 'leverage');
|
|
190215
|
+
}
|
|
190216
|
+
else if (positionType === 2) {
|
|
190217
|
+
shortLeverage = this.safeInteger(entry, 'leverage');
|
|
190218
|
+
}
|
|
190219
|
+
marginMode = (openType === 1) ? 'isolated' : 'cross';
|
|
190220
|
+
}
|
|
190072
190221
|
return {
|
|
190073
190222
|
'info': leverage,
|
|
190074
190223
|
'symbol': market['symbol'],
|
|
190075
|
-
'
|
|
190076
|
-
'
|
|
190224
|
+
'marginMode': marginMode,
|
|
190225
|
+
'longLeverage': longLeverage,
|
|
190226
|
+
'shortLeverage': shortLeverage,
|
|
190077
190227
|
};
|
|
190078
190228
|
}
|
|
190079
190229
|
handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
|
|
@@ -190124,7 +190274,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
190124
190274
|
'source': this.safeString(this.options, 'broker', 'CCXT'),
|
|
190125
190275
|
};
|
|
190126
190276
|
}
|
|
190127
|
-
if ((method === 'POST') || (method === 'PUT')) {
|
|
190277
|
+
if ((method === 'POST') || (method === 'PUT') || (method === 'DELETE')) {
|
|
190128
190278
|
headers['Content-Type'] = 'application/json';
|
|
190129
190279
|
}
|
|
190130
190280
|
}
|
|
@@ -199918,7 +200068,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
199918
200068
|
// while fetchCurrencies is a public API method by design
|
|
199919
200069
|
// therefore we check the keys here
|
|
199920
200070
|
// and fallback to generating the currencies from the markets
|
|
199921
|
-
const isSandboxMode = this.
|
|
200071
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
199922
200072
|
if (!this.checkRequiredCredentials(false) || isSandboxMode) {
|
|
199923
200073
|
return undefined;
|
|
199924
200074
|
}
|
|
@@ -203522,7 +203672,37 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
203522
203672
|
// "msg": ""
|
|
203523
203673
|
// }
|
|
203524
203674
|
//
|
|
203525
|
-
|
|
203675
|
+
const data = this.safeList(response, 'data', []);
|
|
203676
|
+
return this.parseLeverage(data, market);
|
|
203677
|
+
}
|
|
203678
|
+
parseLeverage(leverage, market = undefined) {
|
|
203679
|
+
let marketId = undefined;
|
|
203680
|
+
let marginMode = undefined;
|
|
203681
|
+
let longLeverage = undefined;
|
|
203682
|
+
let shortLeverage = undefined;
|
|
203683
|
+
for (let i = 0; i < leverage.length; i++) {
|
|
203684
|
+
const entry = leverage[i];
|
|
203685
|
+
marginMode = this.safeStringLower(entry, 'mgnMode');
|
|
203686
|
+
marketId = this.safeString(entry, 'instId');
|
|
203687
|
+
const positionSide = this.safeStringLower(entry, 'posSide');
|
|
203688
|
+
if (positionSide === 'long') {
|
|
203689
|
+
longLeverage = this.safeInteger(entry, 'lever');
|
|
203690
|
+
}
|
|
203691
|
+
else if (positionSide === 'short') {
|
|
203692
|
+
shortLeverage = this.safeInteger(entry, 'lever');
|
|
203693
|
+
}
|
|
203694
|
+
else {
|
|
203695
|
+
longLeverage = this.safeInteger(entry, 'lever');
|
|
203696
|
+
shortLeverage = this.safeInteger(entry, 'lever');
|
|
203697
|
+
}
|
|
203698
|
+
}
|
|
203699
|
+
return {
|
|
203700
|
+
'info': leverage,
|
|
203701
|
+
'symbol': this.safeSymbol(marketId, market),
|
|
203702
|
+
'marginMode': marginMode,
|
|
203703
|
+
'longLeverage': longLeverage,
|
|
203704
|
+
'shortLeverage': shortLeverage,
|
|
203705
|
+
};
|
|
203526
203706
|
}
|
|
203527
203707
|
async fetchPosition(symbol, params = {}) {
|
|
203528
203708
|
/**
|
|
@@ -212091,7 +212271,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
212091
212271
|
}
|
|
212092
212272
|
parseOrder(order, market = undefined) {
|
|
212093
212273
|
const isSwap = this.safeBool(market, 'swap', false);
|
|
212094
|
-
const hasPnl = ('closedPnl' in order);
|
|
212274
|
+
const hasPnl = ('closedPnl' in order) || ('closedPnlRv' in order) || ('totalPnlRv' in order);
|
|
212095
212275
|
if (isSwap || hasPnl) {
|
|
212096
212276
|
return this.parseSwapOrder(order, market);
|
|
212097
212277
|
}
|
|
@@ -219216,7 +219396,7 @@ class alpaca extends _alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
219216
219396
|
for (let i = 0; i < message.length; i++) {
|
|
219217
219397
|
const data = message[i];
|
|
219218
219398
|
const T = this.safeString(data, 'T');
|
|
219219
|
-
const msg = this.
|
|
219399
|
+
const msg = this.safeString(data, 'msg');
|
|
219220
219400
|
if (T === 'subscription') {
|
|
219221
219401
|
this.handleSubscription(client, data);
|
|
219222
219402
|
return;
|
|
@@ -222827,7 +223007,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222827
223007
|
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
222828
223008
|
this.setPositionsCache(client, type, symbols, isPortfolioMargin);
|
|
222829
223009
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
222830
|
-
const awaitPositionsSnapshot = this.
|
|
223010
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
222831
223011
|
const cache = this.safeValue(this.positions, type);
|
|
222832
223012
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
222833
223013
|
const snapshot = await client.future(type + ':fetchPositionsSnapshot');
|
|
@@ -225433,7 +225613,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
225433
225613
|
'symbol': marketId,
|
|
225434
225614
|
};
|
|
225435
225615
|
const result = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash, { 'checksum': false });
|
|
225436
|
-
const checksum = this.
|
|
225616
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
225437
225617
|
if (checksum && !client.subscriptions[messageHash]['checksum'] && (channel === 'book')) {
|
|
225438
225618
|
client.subscriptions[messageHash]['checksum'] = true;
|
|
225439
225619
|
await client.send({
|
|
@@ -227083,7 +227263,7 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
227083
227263
|
this.handleDeltas(storedOrderBook['bids'], bids);
|
|
227084
227264
|
storedOrderBook['timestamp'] = timestamp;
|
|
227085
227265
|
storedOrderBook['datetime'] = this.iso8601(timestamp);
|
|
227086
|
-
const checksum = this.
|
|
227266
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
227087
227267
|
const isSnapshot = this.safeString(message, 'action') === 'snapshot'; // snapshot does not have a checksum
|
|
227088
227268
|
if (!isSnapshot && checksum) {
|
|
227089
227269
|
const storedAsks = storedOrderBook['asks'];
|
|
@@ -228420,11 +228600,12 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
228420
228600
|
}
|
|
228421
228601
|
return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
228422
228602
|
}
|
|
228423
|
-
async subscribeMultiple(channel, type, symbols, params = {}) {
|
|
228603
|
+
async subscribeMultiple(channel, type, symbols = undefined, params = {}) {
|
|
228604
|
+
symbols = this.marketSymbols(symbols, type, false, true);
|
|
228424
228605
|
const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
|
|
228425
228606
|
const channelType = (type === 'spot') ? 'spot' : 'futures';
|
|
228426
228607
|
const actionType = (type === 'spot') ? 'op' : 'action';
|
|
228427
|
-
|
|
228608
|
+
let rawSubscriptions = [];
|
|
228428
228609
|
const messageHashes = [];
|
|
228429
228610
|
for (let i = 0; i < symbols.length; i++) {
|
|
228430
228611
|
const market = this.market(symbols[i]);
|
|
@@ -228432,6 +228613,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
228432
228613
|
rawSubscriptions.push(message);
|
|
228433
228614
|
messageHashes.push(channel + ':' + market['symbol']);
|
|
228434
228615
|
}
|
|
228616
|
+
// as an exclusion, futures "tickers" need one generic request for all symbols
|
|
228617
|
+
if ((type !== 'spot') && (channel === 'ticker')) {
|
|
228618
|
+
rawSubscriptions = [channelType + '/' + channel];
|
|
228619
|
+
}
|
|
228435
228620
|
const request = {
|
|
228436
228621
|
'args': rawSubscriptions,
|
|
228437
228622
|
};
|
|
@@ -228634,13 +228819,8 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
228634
228819
|
*/
|
|
228635
228820
|
await this.loadMarkets();
|
|
228636
228821
|
symbol = this.symbol(symbol);
|
|
228637
|
-
const
|
|
228638
|
-
|
|
228639
|
-
[type, params] = this.handleMarketTypeAndParams('watchTicker', market, params);
|
|
228640
|
-
if (type === 'swap') {
|
|
228641
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchTicker() does not support ' + type + ' markets. Use watchTickers() instead');
|
|
228642
|
-
}
|
|
228643
|
-
return await this.subscribe('ticker', symbol, type, params);
|
|
228822
|
+
const tickers = await this.watchTickers([symbol], params);
|
|
228823
|
+
return tickers[symbol];
|
|
228644
228824
|
}
|
|
228645
228825
|
async watchTickers(symbols = undefined, params = {}) {
|
|
228646
228826
|
/**
|
|
@@ -228654,40 +228834,12 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
228654
228834
|
*/
|
|
228655
228835
|
await this.loadMarkets();
|
|
228656
228836
|
const market = this.getMarketFromSymbols(symbols);
|
|
228657
|
-
let
|
|
228658
|
-
[
|
|
228659
|
-
const
|
|
228660
|
-
symbols = this.marketSymbols(symbols);
|
|
228661
|
-
let messageHash = 'tickers::' + type;
|
|
228662
|
-
if (symbols !== undefined) {
|
|
228663
|
-
messageHash += '::' + symbols.join(',');
|
|
228664
|
-
}
|
|
228665
|
-
let request = undefined;
|
|
228666
|
-
let tickers = undefined;
|
|
228667
|
-
const isSpot = (type === 'spot');
|
|
228668
|
-
if (isSpot) {
|
|
228669
|
-
if (symbols === undefined) {
|
|
228670
|
-
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchTickers() for ' + type + ' market type requires symbols argument to be provided');
|
|
228671
|
-
}
|
|
228672
|
-
const marketIds = this.marketIds(symbols);
|
|
228673
|
-
const finalArray = [];
|
|
228674
|
-
for (let i = 0; i < marketIds.length; i++) {
|
|
228675
|
-
finalArray.push('spot/ticker:' + marketIds[i]);
|
|
228676
|
-
}
|
|
228677
|
-
request = {
|
|
228678
|
-
'op': 'subscribe',
|
|
228679
|
-
'args': finalArray,
|
|
228680
|
-
};
|
|
228681
|
-
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
228682
|
-
}
|
|
228683
|
-
else {
|
|
228684
|
-
request = {
|
|
228685
|
-
'action': 'subscribe',
|
|
228686
|
-
'args': ['futures/ticker'],
|
|
228687
|
-
};
|
|
228688
|
-
tickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
|
|
228689
|
-
}
|
|
228837
|
+
let marketType = undefined;
|
|
228838
|
+
[marketType, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
|
|
228839
|
+
const ticker = await this.subscribeMultiple('ticker', marketType, symbols, params);
|
|
228690
228840
|
if (this.newUpdates) {
|
|
228841
|
+
const tickers = {};
|
|
228842
|
+
tickers[ticker['symbol']] = ticker;
|
|
228691
228843
|
return tickers;
|
|
228692
228844
|
}
|
|
228693
228845
|
return this.filterByArray(this.tickers, 'symbol', symbols);
|
|
@@ -229163,21 +229315,34 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
229163
229315
|
if (data === undefined) {
|
|
229164
229316
|
return;
|
|
229165
229317
|
}
|
|
229166
|
-
let stored = undefined;
|
|
229167
229318
|
let symbol = undefined;
|
|
229168
|
-
|
|
229169
|
-
|
|
229170
|
-
|
|
229171
|
-
|
|
229172
|
-
|
|
229173
|
-
|
|
229174
|
-
|
|
229175
|
-
this.trades[symbol] = stored;
|
|
229319
|
+
const length = data.length;
|
|
229320
|
+
const isSwap = ('group' in message);
|
|
229321
|
+
if (isSwap) {
|
|
229322
|
+
// in swap, chronologically decreasing: 1709536849322, 1709536848954,
|
|
229323
|
+
const maxLen = Math.max(length - 1, 0);
|
|
229324
|
+
for (let i = maxLen; i >= 0; i--) {
|
|
229325
|
+
symbol = this.handleTradeLoop(data[i]);
|
|
229176
229326
|
}
|
|
229177
|
-
stored.append(trade);
|
|
229178
229327
|
}
|
|
229179
|
-
|
|
229180
|
-
|
|
229328
|
+
else {
|
|
229329
|
+
// in spot, chronologically increasing: 1709536771200, 1709536771226,
|
|
229330
|
+
for (let i = 0; i < length; i++) {
|
|
229331
|
+
symbol = this.handleTradeLoop(data[i]);
|
|
229332
|
+
}
|
|
229333
|
+
}
|
|
229334
|
+
client.resolve(this.trades[symbol], 'trade:' + symbol);
|
|
229335
|
+
}
|
|
229336
|
+
handleTradeLoop(entry) {
|
|
229337
|
+
const trade = this.parseWsTrade(entry);
|
|
229338
|
+
const symbol = trade['symbol'];
|
|
229339
|
+
const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
229340
|
+
if (this.safeValue(this.trades, symbol) === undefined) {
|
|
229341
|
+
this.trades[symbol] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(tradesLimit);
|
|
229342
|
+
}
|
|
229343
|
+
const stored = this.trades[symbol];
|
|
229344
|
+
stored.append(trade);
|
|
229345
|
+
return symbol;
|
|
229181
229346
|
}
|
|
229182
229347
|
parseWsTrade(trade, market = undefined) {
|
|
229183
229348
|
// spot
|
|
@@ -229256,45 +229421,22 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
229256
229421
|
//
|
|
229257
229422
|
const table = this.safeString(message, 'table');
|
|
229258
229423
|
const isSpot = (table !== undefined);
|
|
229259
|
-
|
|
229260
|
-
if (data === undefined) {
|
|
229261
|
-
return;
|
|
229262
|
-
}
|
|
229424
|
+
let rawTickers = [];
|
|
229263
229425
|
if (isSpot) {
|
|
229264
|
-
|
|
229265
|
-
const ticker = this.parseTicker(data[i]);
|
|
229266
|
-
const symbol = ticker['symbol'];
|
|
229267
|
-
const marketId = this.safeString(ticker['info'], 'symbol');
|
|
229268
|
-
const messageHash = table + ':' + marketId;
|
|
229269
|
-
this.tickers[symbol] = ticker;
|
|
229270
|
-
client.resolve(ticker, messageHash);
|
|
229271
|
-
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
229272
|
-
}
|
|
229426
|
+
rawTickers = this.safeList(message, 'data', []);
|
|
229273
229427
|
}
|
|
229274
229428
|
else {
|
|
229275
|
-
|
|
229276
|
-
const ticker = this.parseWsSwapTicker(data);
|
|
229277
|
-
const symbol = this.safeString(ticker, 'symbol');
|
|
229278
|
-
this.tickers[symbol] = ticker;
|
|
229279
|
-
client.resolve(ticker, 'tickers::swap');
|
|
229280
|
-
this.resolveMessageHashesForSymbol(client, symbol, ticker, 'tickers::');
|
|
229429
|
+
rawTickers = [this.safeValue(message, 'data', {})];
|
|
229281
229430
|
}
|
|
229282
|
-
|
|
229283
|
-
|
|
229284
|
-
|
|
229285
|
-
|
|
229286
|
-
|
|
229287
|
-
|
|
229288
|
-
|
|
229289
|
-
const
|
|
229290
|
-
|
|
229291
|
-
const symbolsString = parts[length - 1];
|
|
229292
|
-
const symbols = symbolsString.split(symbolsSeparator);
|
|
229293
|
-
if (this.inArray(symbol, symbols)) {
|
|
229294
|
-
const response = {};
|
|
229295
|
-
response[symbol] = result;
|
|
229296
|
-
client.resolve(response, messageHash);
|
|
229297
|
-
}
|
|
229431
|
+
if (!rawTickers.length) {
|
|
229432
|
+
return;
|
|
229433
|
+
}
|
|
229434
|
+
for (let i = 0; i < rawTickers.length; i++) {
|
|
229435
|
+
const ticker = isSpot ? this.parseTicker(rawTickers[i]) : this.parseWsSwapTicker(rawTickers[i]);
|
|
229436
|
+
const symbol = ticker['symbol'];
|
|
229437
|
+
this.tickers[symbol] = ticker;
|
|
229438
|
+
const messageHash = 'ticker:' + symbol;
|
|
229439
|
+
client.resolve(ticker, messageHash);
|
|
229298
229440
|
}
|
|
229299
229441
|
}
|
|
229300
229442
|
parseWsSwapTicker(ticker, market = undefined) {
|
|
@@ -234130,7 +234272,7 @@ class bitvavo extends _bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
234130
234272
|
return messageHash;
|
|
234131
234273
|
}
|
|
234132
234274
|
checkMessageHashDoesNotExist(messageHash) {
|
|
234133
|
-
const supressMultipleWsRequestsError = this.
|
|
234275
|
+
const supressMultipleWsRequestsError = this.safeBool(this.options, 'supressMultipleWsRequestsError', false);
|
|
234134
234276
|
if (!supressMultipleWsRequestsError) {
|
|
234135
234277
|
const client = this.safeValue(this.clients, this.urls['api']['ws']);
|
|
234136
234278
|
if (client !== undefined) {
|
|
@@ -236134,7 +236276,7 @@ class bybit extends _bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
236134
236276
|
this.setPositionsCache(client, symbols);
|
|
236135
236277
|
const cache = this.positions;
|
|
236136
236278
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
236137
|
-
const awaitPositionsSnapshot = this.
|
|
236279
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
236138
236280
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
236139
236281
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
236140
236282
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
|
@@ -240897,7 +241039,7 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
240897
241039
|
}
|
|
240898
241040
|
const url = this.urls['api']['ws'][type];
|
|
240899
241041
|
const messageHash = 'ohlcv';
|
|
240900
|
-
const watchOHLCVWarning = this.
|
|
241042
|
+
const watchOHLCVWarning = this.safeBool(this.options, 'watchOHLCVWarning', true);
|
|
240901
241043
|
const client = this.safeValue(this.clients, url, {});
|
|
240902
241044
|
const clientSub = this.safeValue(client, 'subscriptions', {});
|
|
240903
241045
|
const existingSubscription = this.safeValue(clientSub, messageHash);
|
|
@@ -242432,7 +242574,7 @@ class cryptocom extends _cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
|
|
|
242432
242574
|
const client = this.client(url);
|
|
242433
242575
|
this.setPositionsCache(client, symbols);
|
|
242434
242576
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
242435
|
-
const awaitPositionsSnapshot = this.
|
|
242577
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
242436
242578
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
242437
242579
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
242438
242580
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
|
@@ -243495,10 +243637,13 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243495
243637
|
'watchTicker': true,
|
|
243496
243638
|
'watchTickers': false,
|
|
243497
243639
|
'watchTrades': true,
|
|
243640
|
+
'watchTradesForSymbols': true,
|
|
243498
243641
|
'watchMyTrades': true,
|
|
243499
243642
|
'watchOrders': true,
|
|
243500
243643
|
'watchOrderBook': true,
|
|
243644
|
+
'watchOrderBookForSymbols': true,
|
|
243501
243645
|
'watchOHLCV': true,
|
|
243646
|
+
'watchOHLCVForSymbols': true,
|
|
243502
243647
|
},
|
|
243503
243648
|
'urls': {
|
|
243504
243649
|
'test': {
|
|
@@ -243509,18 +243654,31 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243509
243654
|
},
|
|
243510
243655
|
},
|
|
243511
243656
|
'options': {
|
|
243512
|
-
'
|
|
243513
|
-
'
|
|
243514
|
-
|
|
243515
|
-
|
|
243516
|
-
|
|
243517
|
-
|
|
243518
|
-
|
|
243519
|
-
|
|
243520
|
-
|
|
243521
|
-
|
|
243522
|
-
|
|
243523
|
-
|
|
243657
|
+
'ws': {
|
|
243658
|
+
'timeframes': {
|
|
243659
|
+
'1m': '1',
|
|
243660
|
+
'3m': '3',
|
|
243661
|
+
'5m': '5',
|
|
243662
|
+
'15m': '15',
|
|
243663
|
+
'30m': '30',
|
|
243664
|
+
'1h': '60',
|
|
243665
|
+
'2h': '120',
|
|
243666
|
+
'4h': '180',
|
|
243667
|
+
'6h': '360',
|
|
243668
|
+
'12h': '720',
|
|
243669
|
+
'1d': '1D',
|
|
243670
|
+
},
|
|
243671
|
+
// watchTrades replacement
|
|
243672
|
+
'watchTradesForSymbols': {
|
|
243673
|
+
'interval': '100ms', // 100ms, agg2, raw
|
|
243674
|
+
},
|
|
243675
|
+
// watchOrderBook replacement
|
|
243676
|
+
'watchOrderBookForSymbols': {
|
|
243677
|
+
'interval': '100ms',
|
|
243678
|
+
'useDepthEndpoint': false,
|
|
243679
|
+
'depth': '20',
|
|
243680
|
+
'group': 'none', // none, 1, 2, 5, 10, 25, 100, 250
|
|
243681
|
+
},
|
|
243524
243682
|
},
|
|
243525
243683
|
'currencies': ['BTC', 'ETH', 'SOL', 'USDC'],
|
|
243526
243684
|
},
|
|
@@ -243700,27 +243858,31 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243700
243858
|
* @param {str} [params.interval] specify aggregation and frequency of notifications. Possible values: 100ms, raw
|
|
243701
243859
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
243702
243860
|
*/
|
|
243703
|
-
|
|
243704
|
-
|
|
243705
|
-
|
|
243706
|
-
|
|
243707
|
-
|
|
243708
|
-
|
|
243861
|
+
params['callerMethodName'] = 'watchTrades';
|
|
243862
|
+
return await this.watchTradesForSymbols([symbol], since, limit, params);
|
|
243863
|
+
}
|
|
243864
|
+
async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
|
|
243865
|
+
/**
|
|
243866
|
+
* @method
|
|
243867
|
+
* @name deribit#watchTradesForSymbols
|
|
243868
|
+
* @description get the list of most recent trades for a list of symbols
|
|
243869
|
+
* @see https://docs.deribit.com/#trades-instrument_name-interval
|
|
243870
|
+
* @param {string[]} symbols unified symbol of the market to fetch trades for
|
|
243871
|
+
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
243872
|
+
* @param {int} [limit] the maximum amount of trades to fetch
|
|
243873
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
243874
|
+
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
243875
|
+
*/
|
|
243876
|
+
let interval = undefined;
|
|
243877
|
+
[interval, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'interval', '100ms');
|
|
243709
243878
|
if (interval === 'raw') {
|
|
243710
243879
|
await this.authenticate();
|
|
243711
243880
|
}
|
|
243712
|
-
const
|
|
243713
|
-
'jsonrpc': '2.0',
|
|
243714
|
-
'method': 'public/subscribe',
|
|
243715
|
-
'params': {
|
|
243716
|
-
'channels': [channel],
|
|
243717
|
-
},
|
|
243718
|
-
'id': this.requestId(),
|
|
243719
|
-
};
|
|
243720
|
-
const request = this.deepExtend(message, params);
|
|
243721
|
-
const trades = await this.watch(url, channel, request, channel, request);
|
|
243881
|
+
const trades = await this.watchMultipleWrapper('trades', interval, symbols, params);
|
|
243722
243882
|
if (this.newUpdates) {
|
|
243723
|
-
|
|
243883
|
+
const first = this.safeDict(trades, 0);
|
|
243884
|
+
const tradeSymbol = this.safeString(first, 'symbol');
|
|
243885
|
+
limit = trades.getLimit(tradeSymbol, limit);
|
|
243724
243886
|
}
|
|
243725
243887
|
return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
|
|
243726
243888
|
}
|
|
@@ -243746,26 +243908,27 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243746
243908
|
// }
|
|
243747
243909
|
// }
|
|
243748
243910
|
//
|
|
243749
|
-
const params = this.
|
|
243911
|
+
const params = this.safeDict(message, 'params', {});
|
|
243750
243912
|
const channel = this.safeString(params, 'channel', '');
|
|
243751
243913
|
const parts = channel.split('.');
|
|
243752
243914
|
const marketId = this.safeString(parts, 1);
|
|
243915
|
+
const interval = this.safeString(parts, 2);
|
|
243753
243916
|
const symbol = this.safeSymbol(marketId);
|
|
243754
243917
|
const market = this.safeMarket(marketId);
|
|
243755
|
-
const trades = this.
|
|
243756
|
-
|
|
243757
|
-
if (stored === undefined) {
|
|
243918
|
+
const trades = this.safeList(params, 'data', []);
|
|
243919
|
+
if (this.safeValue(this.trades, symbol) === undefined) {
|
|
243758
243920
|
const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
|
|
243759
|
-
|
|
243760
|
-
this.trades[symbol] = stored;
|
|
243921
|
+
this.trades[symbol] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCache */ .ZL(limit);
|
|
243761
243922
|
}
|
|
243923
|
+
const stored = this.trades[symbol];
|
|
243762
243924
|
for (let i = 0; i < trades.length; i++) {
|
|
243763
243925
|
const trade = trades[i];
|
|
243764
243926
|
const parsed = this.parseTrade(trade, market);
|
|
243765
243927
|
stored.append(parsed);
|
|
243766
243928
|
}
|
|
243767
243929
|
this.trades[symbol] = stored;
|
|
243768
|
-
|
|
243930
|
+
const messageHash = 'trades|' + symbol + '|' + interval;
|
|
243931
|
+
client.resolve(this.trades[symbol], messageHash);
|
|
243769
243932
|
}
|
|
243770
243933
|
async watchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
243771
243934
|
/**
|
|
@@ -243856,7 +244019,7 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243856
244019
|
/**
|
|
243857
244020
|
* @method
|
|
243858
244021
|
* @name deribit#watchOrderBook
|
|
243859
|
-
* @see https://docs.deribit.com/#
|
|
244022
|
+
* @see https://docs.deribit.com/#book-instrument_name-group-depth-interval
|
|
243860
244023
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
243861
244024
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
243862
244025
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
@@ -243864,25 +244027,39 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243864
244027
|
* @param {string} [params.interval] Frequency of notifications. Events will be aggregated over this interval. Possible values: 100ms, raw
|
|
243865
244028
|
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
243866
244029
|
*/
|
|
243867
|
-
|
|
243868
|
-
|
|
243869
|
-
|
|
243870
|
-
|
|
243871
|
-
|
|
244030
|
+
params['callerMethodName'] = 'watchOrderBook';
|
|
244031
|
+
return await this.watchOrderBookForSymbols([symbol], limit, params);
|
|
244032
|
+
}
|
|
244033
|
+
async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
|
|
244034
|
+
/**
|
|
244035
|
+
* @method
|
|
244036
|
+
* @name deribit#watchOrderBookForSymbols
|
|
244037
|
+
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
244038
|
+
* @see https://docs.deribit.com/#book-instrument_name-group-depth-interval
|
|
244039
|
+
* @param {string[]} symbols unified array of symbols
|
|
244040
|
+
* @param {int} [limit] the maximum amount of order book entries to return
|
|
244041
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
244042
|
+
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
244043
|
+
*/
|
|
244044
|
+
let interval = undefined;
|
|
244045
|
+
[interval, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'interval', '100ms');
|
|
243872
244046
|
if (interval === 'raw') {
|
|
243873
244047
|
await this.authenticate();
|
|
243874
244048
|
}
|
|
243875
|
-
|
|
243876
|
-
|
|
243877
|
-
|
|
243878
|
-
|
|
243879
|
-
|
|
243880
|
-
|
|
243881
|
-
|
|
243882
|
-
|
|
243883
|
-
|
|
243884
|
-
|
|
243885
|
-
|
|
244049
|
+
let descriptor = '';
|
|
244050
|
+
let useDepthEndpoint = undefined; // for more info, see comment in .options
|
|
244051
|
+
[useDepthEndpoint, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'useDepthEndpoint', false);
|
|
244052
|
+
if (useDepthEndpoint) {
|
|
244053
|
+
let depth = undefined;
|
|
244054
|
+
[depth, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'depth', '20');
|
|
244055
|
+
let group = undefined;
|
|
244056
|
+
[group, params] = this.handleOptionAndParams(params, 'watchOrderBookForSymbols', 'group', 'none');
|
|
244057
|
+
descriptor = group + '.' + depth + '.' + interval;
|
|
244058
|
+
}
|
|
244059
|
+
else {
|
|
244060
|
+
descriptor = interval;
|
|
244061
|
+
}
|
|
244062
|
+
const orderbook = await this.watchMultipleWrapper('book', descriptor, symbols, params);
|
|
243886
244063
|
return orderbook.limit();
|
|
243887
244064
|
}
|
|
243888
244065
|
handleOrderBook(client, message) {
|
|
@@ -243934,6 +244111,20 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243934
244111
|
const params = this.safeValue(message, 'params', {});
|
|
243935
244112
|
const data = this.safeValue(params, 'data', {});
|
|
243936
244113
|
const channel = this.safeString(params, 'channel');
|
|
244114
|
+
const parts = channel.split('.');
|
|
244115
|
+
let descriptor = '';
|
|
244116
|
+
const partsLength = parts.length;
|
|
244117
|
+
const isDetailed = partsLength === 5;
|
|
244118
|
+
if (isDetailed) {
|
|
244119
|
+
const group = this.safeString(parts, 2);
|
|
244120
|
+
const depth = this.safeString(parts, 3);
|
|
244121
|
+
const interval = this.safeString(parts, 4);
|
|
244122
|
+
descriptor = group + '.' + depth + '.' + interval;
|
|
244123
|
+
}
|
|
244124
|
+
else {
|
|
244125
|
+
const interval = this.safeString(parts, 2);
|
|
244126
|
+
descriptor = interval;
|
|
244127
|
+
}
|
|
243937
244128
|
const marketId = this.safeString(data, 'instrument_name');
|
|
243938
244129
|
const symbol = this.safeSymbol(marketId);
|
|
243939
244130
|
const timestamp = this.safeInteger(data, 'timestamp');
|
|
@@ -243950,7 +244141,8 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
243950
244141
|
storedOrderBook['datetime'] = this.iso8601(timestamp);
|
|
243951
244142
|
storedOrderBook['symbol'] = symbol;
|
|
243952
244143
|
this.orderbooks[symbol] = storedOrderBook;
|
|
243953
|
-
|
|
244144
|
+
const messageHash = 'book|' + symbol + '|' + descriptor;
|
|
244145
|
+
client.resolve(storedOrderBook, messageHash);
|
|
243954
244146
|
}
|
|
243955
244147
|
cleanOrderBook(data) {
|
|
243956
244148
|
const bids = this.safeValue(data, 'bids', []);
|
|
@@ -244090,28 +244282,32 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
244090
244282
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
244091
244283
|
*/
|
|
244092
244284
|
await this.loadMarkets();
|
|
244093
|
-
|
|
244094
|
-
const
|
|
244095
|
-
|
|
244096
|
-
|
|
244097
|
-
|
|
244098
|
-
|
|
244285
|
+
symbol = this.symbol(symbol);
|
|
244286
|
+
const ohlcvs = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
|
|
244287
|
+
return ohlcvs[symbol][timeframe];
|
|
244288
|
+
}
|
|
244289
|
+
async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
|
|
244290
|
+
/**
|
|
244291
|
+
* @method
|
|
244292
|
+
* @name deribit#watchOHLCVForSymbols
|
|
244293
|
+
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
244294
|
+
* @see https://docs.deribit.com/#chart-trades-instrument_name-resolution
|
|
244295
|
+
* @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
|
|
244296
|
+
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
244297
|
+
* @param {int} [limit] the maximum amount of candles to fetch
|
|
244298
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
244299
|
+
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
244300
|
+
*/
|
|
244301
|
+
const symbolsLength = symbolsAndTimeframes.length;
|
|
244302
|
+
if (symbolsLength === 0 || !Array.isArray(symbolsAndTimeframes[0])) {
|
|
244303
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + " watchOHLCVForSymbols() requires a an array of symbols and timeframes, like [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]");
|
|
244099
244304
|
}
|
|
244100
|
-
const
|
|
244101
|
-
const message = {
|
|
244102
|
-
'jsonrpc': '2.0',
|
|
244103
|
-
'method': 'public/subscribe',
|
|
244104
|
-
'params': {
|
|
244105
|
-
'channels': [channel],
|
|
244106
|
-
},
|
|
244107
|
-
'id': this.requestId(),
|
|
244108
|
-
};
|
|
244109
|
-
const request = this.deepExtend(message, params);
|
|
244110
|
-
const ohlcv = await this.watch(url, channel, request, channel, request);
|
|
244305
|
+
const [symbol, timeframe, candles] = await this.watchMultipleWrapper('chart.trades', undefined, symbolsAndTimeframes, params);
|
|
244111
244306
|
if (this.newUpdates) {
|
|
244112
|
-
limit =
|
|
244307
|
+
limit = candles.getLimit(symbol, limit);
|
|
244113
244308
|
}
|
|
244114
|
-
|
|
244309
|
+
const filtered = this.filterBySinceLimit(candles, since, limit, 0, true);
|
|
244310
|
+
return this.createOHLCVObject(symbol, timeframe, filtered);
|
|
244115
244311
|
}
|
|
244116
244312
|
handleOHLCV(client, message) {
|
|
244117
244313
|
//
|
|
@@ -244132,13 +244328,44 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
244132
244328
|
// }
|
|
244133
244329
|
// }
|
|
244134
244330
|
//
|
|
244135
|
-
const params = this.
|
|
244331
|
+
const params = this.safeDict(message, 'params', {});
|
|
244136
244332
|
const channel = this.safeString(params, 'channel', '');
|
|
244137
244333
|
const parts = channel.split('.');
|
|
244138
244334
|
const marketId = this.safeString(parts, 2);
|
|
244139
|
-
const
|
|
244140
|
-
const
|
|
244141
|
-
const
|
|
244335
|
+
const rawTimeframe = this.safeString(parts, 3);
|
|
244336
|
+
const market = this.safeMarket(marketId);
|
|
244337
|
+
const symbol = market['symbol'];
|
|
244338
|
+
const wsOptions = this.safeDict(this.options, 'ws', {});
|
|
244339
|
+
const timeframes = this.safeDict(wsOptions, 'timeframes', {});
|
|
244340
|
+
const unifiedTimeframe = this.findTimeframe(rawTimeframe, timeframes);
|
|
244341
|
+
this.ohlcvs[symbol] = this.safeDict(this.ohlcvs, symbol, {});
|
|
244342
|
+
if (this.safeValue(this.ohlcvs[symbol], unifiedTimeframe) === undefined) {
|
|
244343
|
+
const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
|
|
244344
|
+
this.ohlcvs[symbol][unifiedTimeframe] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheByTimestamp */ .Py(limit);
|
|
244345
|
+
}
|
|
244346
|
+
const stored = this.ohlcvs[symbol][unifiedTimeframe];
|
|
244347
|
+
const ohlcv = this.safeDict(params, 'data', {});
|
|
244348
|
+
// data contains a single OHLCV candle
|
|
244349
|
+
const parsed = this.parseWsOHLCV(ohlcv, market);
|
|
244350
|
+
stored.append(parsed);
|
|
244351
|
+
this.ohlcvs[symbol][unifiedTimeframe] = stored;
|
|
244352
|
+
const resolveData = [symbol, unifiedTimeframe, stored];
|
|
244353
|
+
const messageHash = 'chart.trades|' + symbol + '|' + rawTimeframe;
|
|
244354
|
+
client.resolve(resolveData, messageHash);
|
|
244355
|
+
}
|
|
244356
|
+
parseWsOHLCV(ohlcv, market = undefined) {
|
|
244357
|
+
//
|
|
244358
|
+
// {
|
|
244359
|
+
// "c": "28909.0",
|
|
244360
|
+
// "o": "28915.4",
|
|
244361
|
+
// "h": "28915.4",
|
|
244362
|
+
// "l": "28896.1",
|
|
244363
|
+
// "v": "27.6919",
|
|
244364
|
+
// "T": 1696687499999,
|
|
244365
|
+
// "t": 1696687440000
|
|
244366
|
+
// }
|
|
244367
|
+
//
|
|
244368
|
+
return [
|
|
244142
244369
|
this.safeInteger(ohlcv, 'tick'),
|
|
244143
244370
|
this.safeNumber(ohlcv, 'open'),
|
|
244144
244371
|
this.safeNumber(ohlcv, 'high'),
|
|
@@ -244146,14 +244373,46 @@ class deribit extends _deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
244146
244373
|
this.safeNumber(ohlcv, 'close'),
|
|
244147
244374
|
this.safeNumber(ohlcv, 'volume'),
|
|
244148
244375
|
];
|
|
244149
|
-
|
|
244150
|
-
|
|
244151
|
-
|
|
244152
|
-
|
|
244376
|
+
}
|
|
244377
|
+
async watchMultipleWrapper(channelName, channelDescriptor, symbolsArray = undefined, params = {}) {
|
|
244378
|
+
await this.loadMarkets();
|
|
244379
|
+
const url = this.urls['api']['ws'];
|
|
244380
|
+
const rawSubscriptions = [];
|
|
244381
|
+
const messageHashes = [];
|
|
244382
|
+
const isOHLCV = (channelName === 'chart.trades');
|
|
244383
|
+
const symbols = isOHLCV ? this.getListFromObjectValues(symbolsArray, 0) : symbolsArray;
|
|
244384
|
+
this.marketSymbols(symbols, undefined, false);
|
|
244385
|
+
for (let i = 0; i < symbolsArray.length; i++) {
|
|
244386
|
+
const current = symbolsArray[i];
|
|
244387
|
+
let market = undefined;
|
|
244388
|
+
if (isOHLCV) {
|
|
244389
|
+
market = this.market(current[0]);
|
|
244390
|
+
const unifiedTf = current[1];
|
|
244391
|
+
const rawTf = this.safeString(this.timeframes, unifiedTf, unifiedTf);
|
|
244392
|
+
channelDescriptor = rawTf;
|
|
244393
|
+
}
|
|
244394
|
+
else {
|
|
244395
|
+
market = this.market(current);
|
|
244396
|
+
}
|
|
244397
|
+
const message = channelName + '.' + market['id'] + '.' + channelDescriptor;
|
|
244398
|
+
rawSubscriptions.push(message);
|
|
244399
|
+
messageHashes.push(channelName + '|' + market['symbol'] + '|' + channelDescriptor);
|
|
244153
244400
|
}
|
|
244154
|
-
|
|
244155
|
-
|
|
244156
|
-
|
|
244401
|
+
const request = {
|
|
244402
|
+
'jsonrpc': '2.0',
|
|
244403
|
+
'method': 'public/subscribe',
|
|
244404
|
+
'params': {
|
|
244405
|
+
'channels': rawSubscriptions,
|
|
244406
|
+
},
|
|
244407
|
+
'id': this.requestId(),
|
|
244408
|
+
};
|
|
244409
|
+
const extendedRequest = this.deepExtend(request, params);
|
|
244410
|
+
const maxMessageByteLimit = 32768 - 1; // 'Message Too Big: limit 32768B'
|
|
244411
|
+
const jsonedText = this.json(extendedRequest);
|
|
244412
|
+
if (jsonedText.length >= maxMessageByteLimit) {
|
|
244413
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' requested subscription length over limit, try to reduce symbols amount');
|
|
244414
|
+
}
|
|
244415
|
+
return await this.watchMultiple(url, messageHashes, extendedRequest, rawSubscriptions);
|
|
244157
244416
|
}
|
|
244158
244417
|
handleMessage(client, message) {
|
|
244159
244418
|
//
|
|
@@ -245806,7 +246065,7 @@ class gate extends _gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
245806
246065
|
const client = this.client(url);
|
|
245807
246066
|
this.setPositionsCache(client, type, symbols);
|
|
245808
246067
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
245809
|
-
const awaitPositionsSnapshot = this.
|
|
246068
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
245810
246069
|
const cache = this.safeValue(this.positions, type);
|
|
245811
246070
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
|
|
245812
246071
|
return await client.future(type + ':fetchPositionsSnapshot');
|
|
@@ -253162,7 +253421,7 @@ class independentreserve extends _independentreserve_js__WEBPACK_IMPORTED_MODULE
|
|
|
253162
253421
|
orderbook['timestamp'] = timestamp;
|
|
253163
253422
|
orderbook['datetime'] = this.iso8601(timestamp);
|
|
253164
253423
|
}
|
|
253165
|
-
const checksum = this.
|
|
253424
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
253166
253425
|
if (checksum && receivedSnapshot) {
|
|
253167
253426
|
const storedAsks = orderbook['asks'];
|
|
253168
253427
|
const storedBids = orderbook['bids'];
|
|
@@ -253953,7 +254212,7 @@ class kraken extends _kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
|
|
|
253953
254212
|
}
|
|
253954
254213
|
// don't remove this line or I will poop on your face
|
|
253955
254214
|
orderbook.limit();
|
|
253956
|
-
const checksum = this.
|
|
254215
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
253957
254216
|
if (checksum) {
|
|
253958
254217
|
const priceString = this.safeString(example, 0);
|
|
253959
254218
|
const amountString = this.safeString(example, 1);
|
|
@@ -257503,7 +257762,7 @@ class kucoinfutures extends _kucoinfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
|
|
|
257503
257762
|
const client = this.client(url);
|
|
257504
257763
|
this.setPositionCache(client, symbol);
|
|
257505
257764
|
const fetchPositionSnapshot = this.handleOption('watchPosition', 'fetchPositionSnapshot', true);
|
|
257506
|
-
const awaitPositionSnapshot = this.
|
|
257765
|
+
const awaitPositionSnapshot = this.safeBool('watchPosition', 'awaitPositionSnapshot', true);
|
|
257507
257766
|
const currentPosition = this.getCurrentPosition(symbol);
|
|
257508
257767
|
if (fetchPositionSnapshot && awaitPositionSnapshot && currentPosition === undefined) {
|
|
257509
257768
|
const snapshot = await client.future('fetchPositionSnapshot:' + symbol);
|
|
@@ -259980,10 +260239,12 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
259980
260239
|
}
|
|
259981
260240
|
}
|
|
259982
260241
|
handleDelta(orderbook, delta) {
|
|
259983
|
-
const
|
|
260242
|
+
const existingNonce = this.safeInteger(orderbook, 'nonce');
|
|
259984
260243
|
const deltaNonce = this.safeInteger2(delta, 'r', 'version');
|
|
259985
|
-
if (deltaNonce
|
|
259986
|
-
|
|
260244
|
+
if (deltaNonce < existingNonce) {
|
|
260245
|
+
// even when doing < comparison, this happens: https://app.travis-ci.com/github/ccxt/ccxt/builds/269234741#L1809
|
|
260246
|
+
// so, we just skip old updates
|
|
260247
|
+
return;
|
|
259987
260248
|
}
|
|
259988
260249
|
orderbook['nonce'] = deltaNonce;
|
|
259989
260250
|
const asks = this.safeValue(delta, 'asks', []);
|
|
@@ -262530,7 +262791,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
262530
262791
|
const storedBids = orderbook['bids'];
|
|
262531
262792
|
this.handleDeltas(storedAsks, asks);
|
|
262532
262793
|
this.handleDeltas(storedBids, bids);
|
|
262533
|
-
const checksum = this.
|
|
262794
|
+
const checksum = this.safeBool(this.options, 'checksum', true);
|
|
262534
262795
|
if (checksum) {
|
|
262535
262796
|
const asksLength = storedAsks.length;
|
|
262536
262797
|
const bidsLength = storedBids.length;
|
|
@@ -271724,12 +271985,10 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
|
|
|
271724
271985
|
if (!this.handleErrorMessage(client, message)) {
|
|
271725
271986
|
return;
|
|
271726
271987
|
}
|
|
271727
|
-
const result = this.
|
|
271728
|
-
if (result
|
|
271729
|
-
|
|
271730
|
-
|
|
271731
|
-
return;
|
|
271732
|
-
}
|
|
271988
|
+
const result = this.safeString(message, 'result');
|
|
271989
|
+
if (result === 'pong') {
|
|
271990
|
+
this.handlePong(client, message);
|
|
271991
|
+
return;
|
|
271733
271992
|
}
|
|
271734
271993
|
const id = this.safeInteger(message, 'id');
|
|
271735
271994
|
if (id !== undefined) {
|
|
@@ -272427,7 +272686,7 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
|
|
|
272427
272686
|
const client = this.client(url);
|
|
272428
272687
|
this.setPositionsCache(client, symbols);
|
|
272429
272688
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
272430
|
-
const awaitPositionsSnapshot = this.
|
|
272689
|
+
const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
|
|
272431
272690
|
if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
|
|
272432
272691
|
const snapshot = await client.future('fetchPositionsSnapshot');
|
|
272433
272692
|
return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
|
|
@@ -274257,7 +274516,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
274257
274516
|
// ]
|
|
274258
274517
|
// }
|
|
274259
274518
|
//
|
|
274260
|
-
const data = this.
|
|
274519
|
+
const data = this.safeList(response, 'data', []);
|
|
274261
274520
|
return this.parseTransactions(data, currency, since, limit);
|
|
274262
274521
|
}
|
|
274263
274522
|
parseTransaction(transaction, currency = undefined) {
|
|
@@ -291061,7 +291320,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
|
|
|
291061
291320
|
'amountAsset': amountAsset,
|
|
291062
291321
|
'priceAsset': priceAsset,
|
|
291063
291322
|
};
|
|
291064
|
-
const sandboxMode = this.
|
|
291323
|
+
const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
291065
291324
|
const chainId = (sandboxMode) ? 84 : 87;
|
|
291066
291325
|
const body = {
|
|
291067
291326
|
'senderPublicKey': this.apiKey,
|
|
@@ -296075,7 +296334,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
296075
296334
|
// ]
|
|
296076
296335
|
// }
|
|
296077
296336
|
//
|
|
296078
|
-
const resultResponse = this.
|
|
296337
|
+
const resultResponse = this.safeList(response, 'rows', []);
|
|
296079
296338
|
return this.parseTrades(resultResponse, market, since, limit);
|
|
296080
296339
|
}
|
|
296081
296340
|
parseTrade(trade, market = undefined) {
|
|
@@ -297919,7 +298178,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
297919
298178
|
else {
|
|
297920
298179
|
this.checkRequiredCredentials();
|
|
297921
298180
|
if (method === 'POST' && (path === 'algo/order' || path === 'order')) {
|
|
297922
|
-
const isSandboxMode = this.
|
|
298181
|
+
const isSandboxMode = this.safeBool(this.options, 'sandboxMode', false);
|
|
297923
298182
|
if (!isSandboxMode) {
|
|
297924
298183
|
const applicationId = 'bc830de7-50f3-460b-9ee0-f430f83f9dad';
|
|
297925
298184
|
const brokerId = this.safeString(this.options, 'brokerId', applicationId);
|
|
@@ -298238,7 +298497,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
298238
298497
|
return response;
|
|
298239
298498
|
}
|
|
298240
298499
|
async fetchLeverage(symbol, params = {}) {
|
|
298500
|
+
/**
|
|
298501
|
+
* @method
|
|
298502
|
+
* @name woo#fetchLeverage
|
|
298503
|
+
* @description fetch the set leverage for a market
|
|
298504
|
+
* @see https://docs.woo.org/#get-account-information-new
|
|
298505
|
+
* @param {string} symbol unified market symbol
|
|
298506
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
298507
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
298508
|
+
*/
|
|
298241
298509
|
await this.loadMarkets();
|
|
298510
|
+
const market = this.market(symbol);
|
|
298242
298511
|
const response = await this.v3PrivateGetAccountinfo(params);
|
|
298243
298512
|
//
|
|
298244
298513
|
// {
|
|
@@ -298268,11 +298537,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
298268
298537
|
// "timestamp": 1673323685109
|
|
298269
298538
|
// }
|
|
298270
298539
|
//
|
|
298271
|
-
const
|
|
298272
|
-
|
|
298540
|
+
const data = this.safeDict(response, 'data', {});
|
|
298541
|
+
return this.parseLeverage(data, market);
|
|
298542
|
+
}
|
|
298543
|
+
parseLeverage(leverage, market = undefined) {
|
|
298544
|
+
const leverageValue = this.safeInteger(leverage, 'leverage');
|
|
298273
298545
|
return {
|
|
298274
|
-
'info':
|
|
298275
|
-
'
|
|
298546
|
+
'info': leverage,
|
|
298547
|
+
'symbol': market['symbol'],
|
|
298548
|
+
'marginMode': undefined,
|
|
298549
|
+
'longLeverage': leverageValue,
|
|
298550
|
+
'shortLeverage': leverageValue,
|
|
298276
298551
|
};
|
|
298277
298552
|
}
|
|
298278
298553
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
@@ -307990,7 +308265,7 @@ SOFTWARE.
|
|
|
307990
308265
|
|
|
307991
308266
|
//-----------------------------------------------------------------------------
|
|
307992
308267
|
// this is updated by vss.js when building
|
|
307993
|
-
const version = '4.2.
|
|
308268
|
+
const version = '4.2.59';
|
|
307994
308269
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
307995
308270
|
//-----------------------------------------------------------------------------
|
|
307996
308271
|
|