ccxt 4.2.53 → 4.2.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ccxt.browser.js +225 -50
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +86 -5
- package/dist/cjs/src/bybit.js +19 -0
- package/dist/cjs/src/gate.js +6 -2
- package/dist/cjs/src/okx.js +17 -1
- package/dist/cjs/src/pro/binance.js +92 -38
- package/dist/cjs/src/whitebit.js +4 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +9 -3
- package/js/src/abstract/binancecoinm.d.ts +9 -3
- package/js/src/abstract/binanceus.d.ts +9 -3
- package/js/src/abstract/binanceusdm.d.ts +9 -3
- package/js/src/abstract/gate.d.ts +13 -9
- package/js/src/abstract/gateio.d.ts +13 -9
- package/js/src/binance.d.ts +2 -0
- package/js/src/binance.js +86 -5
- package/js/src/bybit.d.ts +5 -0
- package/js/src/bybit.js +19 -0
- package/js/src/gate.js +6 -2
- package/js/src/okx.js +17 -1
- package/js/src/pro/binance.d.ts +4 -4
- package/js/src/pro/binance.js +92 -38
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/whitebit.js +4 -3
- package/jsdoc2md.js +3 -2
- package/package.json +1 -1
- package/skip-tests.json +28 -8
package/dist/cjs/ccxt.js
CHANGED
|
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
176
176
|
|
|
177
177
|
//-----------------------------------------------------------------------------
|
|
178
178
|
// this is updated by vss.js when building
|
|
179
|
-
const version = '4.2.
|
|
179
|
+
const version = '4.2.55';
|
|
180
180
|
Exchange["default"].ccxtVersion = version;
|
|
181
181
|
const exchanges = {
|
|
182
182
|
'ace': ace,
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -93,7 +93,8 @@ class binance extends binance$1 {
|
|
|
93
93
|
'fetchL3OrderBook': false,
|
|
94
94
|
'fetchLastPrices': true,
|
|
95
95
|
'fetchLedger': true,
|
|
96
|
-
'
|
|
96
|
+
'fetchLedgerEntry': true,
|
|
97
|
+
'fetchLeverage': true,
|
|
97
98
|
'fetchLeverageTiers': true,
|
|
98
99
|
'fetchLiquidations': false,
|
|
99
100
|
'fetchMarketLeverageTiers': 'emulated',
|
|
@@ -293,8 +294,6 @@ class binance extends binance$1 {
|
|
|
293
294
|
'loan/flexible/borrow/history': 40,
|
|
294
295
|
'loan/flexible/repay/history': 40,
|
|
295
296
|
'loan/flexible/ltv/adjustment/history': 40,
|
|
296
|
-
'loan/flexible/loanable/data': 40,
|
|
297
|
-
'loan/flexible/collateral/data': 40,
|
|
298
297
|
'loan/vip/ongoing/orders': 40,
|
|
299
298
|
'loan/vip/repay/history': 40,
|
|
300
299
|
'loan/vip/collateral/account': 600,
|
|
@@ -586,7 +585,6 @@ class binance extends binance$1 {
|
|
|
586
585
|
'loan/repay': 40.002,
|
|
587
586
|
'loan/adjust/ltv': 40.002,
|
|
588
587
|
'loan/customize/margin_call': 40.002,
|
|
589
|
-
'loan/flexible/borrow': 40.002,
|
|
590
588
|
'loan/flexible/repay': 40.002,
|
|
591
589
|
'loan/flexible/adjust/ltv': 40.002,
|
|
592
590
|
'loan/vip/repay': 40.002,
|
|
@@ -641,10 +639,19 @@ class binance extends binance$1 {
|
|
|
641
639
|
'sub-account/futures/account': 0.1,
|
|
642
640
|
'sub-account/futures/accountSummary': 1,
|
|
643
641
|
'sub-account/futures/positionRisk': 0.1,
|
|
642
|
+
'loan/flexible/ongoing/orders': 30,
|
|
643
|
+
'loan/flexible/borrow/history': 40,
|
|
644
|
+
'loan/flexible/repay/history': 40,
|
|
645
|
+
'loan/flexible/ltv/adjustment/history': 40,
|
|
646
|
+
'loan/flexible/loanable/data': 40,
|
|
647
|
+
'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
|
|
644
648
|
},
|
|
645
649
|
'post': {
|
|
646
650
|
'eth-staking/eth/stake': 15,
|
|
647
|
-
'sub-account/subAccountApi/ipRestriction': 20.001,
|
|
651
|
+
'sub-account/subAccountApi/ipRestriction': 20.001,
|
|
652
|
+
'loan/flexible/borrow': 40.002,
|
|
653
|
+
'loan/flexible/repay': 40.002,
|
|
654
|
+
'loan/flexible/adjust/ltv': 40.002, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40.002
|
|
648
655
|
},
|
|
649
656
|
},
|
|
650
657
|
'sapiV3': {
|
|
@@ -10379,6 +10386,67 @@ class binance extends binance$1 {
|
|
|
10379
10386
|
//
|
|
10380
10387
|
return response;
|
|
10381
10388
|
}
|
|
10389
|
+
async fetchLeverage(symbol, params = {}) {
|
|
10390
|
+
/**
|
|
10391
|
+
* @method
|
|
10392
|
+
* @name binance#fetchLeverage
|
|
10393
|
+
* @description fetch the set leverage for a market
|
|
10394
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
10395
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
10396
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
10397
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
10398
|
+
* @param {string} symbol unified market symbol
|
|
10399
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
10400
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
10401
|
+
*/
|
|
10402
|
+
await this.loadMarkets();
|
|
10403
|
+
await this.loadLeverageBrackets(false, params);
|
|
10404
|
+
const market = this.market(symbol);
|
|
10405
|
+
if (!market['contract']) {
|
|
10406
|
+
throw new errors.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
|
|
10407
|
+
}
|
|
10408
|
+
let type = undefined;
|
|
10409
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
|
|
10410
|
+
let subType = undefined;
|
|
10411
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
|
|
10412
|
+
let isPortfolioMargin = undefined;
|
|
10413
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
|
|
10414
|
+
let response = undefined;
|
|
10415
|
+
if (this.isLinear(type, subType)) {
|
|
10416
|
+
if (isPortfolioMargin) {
|
|
10417
|
+
response = await this.papiGetUmAccount(params);
|
|
10418
|
+
}
|
|
10419
|
+
else {
|
|
10420
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
10421
|
+
}
|
|
10422
|
+
}
|
|
10423
|
+
else if (this.isInverse(type, subType)) {
|
|
10424
|
+
if (isPortfolioMargin) {
|
|
10425
|
+
response = await this.papiGetCmAccount(params);
|
|
10426
|
+
}
|
|
10427
|
+
else {
|
|
10428
|
+
response = await this.dapiPrivateGetAccount(params);
|
|
10429
|
+
}
|
|
10430
|
+
}
|
|
10431
|
+
else {
|
|
10432
|
+
throw new errors.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
|
|
10433
|
+
}
|
|
10434
|
+
const positions = this.safeList(response, 'positions', []);
|
|
10435
|
+
for (let i = 0; i < positions.length; i++) {
|
|
10436
|
+
const position = positions[i];
|
|
10437
|
+
const innerSymbol = this.safeString(position, 'symbol');
|
|
10438
|
+
if (innerSymbol === market['id']) {
|
|
10439
|
+
const isolated = this.safeBool(position, 'isolated');
|
|
10440
|
+
const marginMode = isolated ? 'isolated' : 'cross';
|
|
10441
|
+
return {
|
|
10442
|
+
'info': position,
|
|
10443
|
+
'marginMode': marginMode,
|
|
10444
|
+
'leverage': this.safeInteger(position, 'leverage'),
|
|
10445
|
+
};
|
|
10446
|
+
}
|
|
10447
|
+
}
|
|
10448
|
+
return response;
|
|
10449
|
+
}
|
|
10382
10450
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
10383
10451
|
/**
|
|
10384
10452
|
* @method
|
|
@@ -10561,6 +10629,19 @@ class binance extends binance$1 {
|
|
|
10561
10629
|
}
|
|
10562
10630
|
return result;
|
|
10563
10631
|
}
|
|
10632
|
+
async fetchLedgerEntry(id, code = undefined, params = {}) {
|
|
10633
|
+
await this.loadMarkets();
|
|
10634
|
+
let type = undefined;
|
|
10635
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
|
|
10636
|
+
const query = {
|
|
10637
|
+
'recordId': id,
|
|
10638
|
+
'type': type,
|
|
10639
|
+
};
|
|
10640
|
+
if (type !== 'option') {
|
|
10641
|
+
throw new errors.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
|
|
10642
|
+
}
|
|
10643
|
+
return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
|
|
10644
|
+
}
|
|
10564
10645
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
10565
10646
|
/**
|
|
10566
10647
|
* @method
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -78,6 +78,7 @@ class bybit extends bybit$1 {
|
|
|
78
78
|
'fetchIsolatedBorrowRate': false,
|
|
79
79
|
'fetchIsolatedBorrowRates': false,
|
|
80
80
|
'fetchLedger': true,
|
|
81
|
+
'fetchLeverage': true,
|
|
81
82
|
'fetchMarketLeverageTiers': true,
|
|
82
83
|
'fetchMarkets': true,
|
|
83
84
|
'fetchMarkOHLCV': true,
|
|
@@ -6344,6 +6345,24 @@ class bybit extends bybit$1 {
|
|
|
6344
6345
|
'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
|
|
6345
6346
|
});
|
|
6346
6347
|
}
|
|
6348
|
+
async fetchLeverage(symbol, params = {}) {
|
|
6349
|
+
/**
|
|
6350
|
+
* @method
|
|
6351
|
+
* @name bybit#fetchLeverage
|
|
6352
|
+
* @description fetch the set leverage for a market
|
|
6353
|
+
* @see https://bybit-exchange.github.io/docs/v5/position
|
|
6354
|
+
* @param {string} symbol unified market symbol
|
|
6355
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6356
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
6357
|
+
*/
|
|
6358
|
+
await this.loadMarkets();
|
|
6359
|
+
const position = await this.fetchPosition(symbol, params);
|
|
6360
|
+
return {
|
|
6361
|
+
'info': position,
|
|
6362
|
+
'leverage': this.safeInteger(position, 'leverage'),
|
|
6363
|
+
'marginMode': this.safeNumber(position, 'marginMode'),
|
|
6364
|
+
};
|
|
6365
|
+
}
|
|
6347
6366
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
6348
6367
|
/**
|
|
6349
6368
|
* @method
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -45,7 +45,7 @@ class gate extends gate$1 {
|
|
|
45
45
|
'spot': 'https://api.gateio.ws/api/v4',
|
|
46
46
|
'options': 'https://api.gateio.ws/api/v4',
|
|
47
47
|
'subAccounts': 'https://api.gateio.ws/api/v4',
|
|
48
|
-
'
|
|
48
|
+
'unified': 'https://api.gateio.ws/api/v4',
|
|
49
49
|
'rebate': 'https://api.gateio.ws/api/v4',
|
|
50
50
|
'earn': 'https://api.gateio.ws/api/v4',
|
|
51
51
|
'account': 'https://api.gateio.ws/api/v4',
|
|
@@ -268,11 +268,14 @@ class gate extends gate$1 {
|
|
|
268
268
|
'saved_address': 1,
|
|
269
269
|
'fee': 1,
|
|
270
270
|
'total_balance': 2.5,
|
|
271
|
+
'small_balance': 1,
|
|
272
|
+
'small_balance_history': 1,
|
|
271
273
|
},
|
|
272
274
|
'post': {
|
|
273
275
|
'transfers': 2.5,
|
|
274
276
|
'sub_account_transfers': 2.5,
|
|
275
277
|
'sub_account_to_sub_account': 2.5,
|
|
278
|
+
'small_balance': 1,
|
|
276
279
|
},
|
|
277
280
|
},
|
|
278
281
|
'subAccounts': {
|
|
@@ -295,7 +298,7 @@ class gate extends gate$1 {
|
|
|
295
298
|
'sub_accounts/{user_id}/keys/{key}': 2.5,
|
|
296
299
|
},
|
|
297
300
|
},
|
|
298
|
-
'
|
|
301
|
+
'unified': {
|
|
299
302
|
'get': {
|
|
300
303
|
'accounts': 20 / 15,
|
|
301
304
|
'account_mode': 20 / 15,
|
|
@@ -304,6 +307,7 @@ class gate extends gate$1 {
|
|
|
304
307
|
'loans': 20 / 15,
|
|
305
308
|
'loan_records': 20 / 15,
|
|
306
309
|
'interest_records': 20 / 15,
|
|
310
|
+
'estimate_rate': 20 / 15,
|
|
307
311
|
},
|
|
308
312
|
'post': {
|
|
309
313
|
'account_mode': 20 / 15,
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -573,6 +573,7 @@ class okx extends okx$1 {
|
|
|
573
573
|
'50027': errors.PermissionDenied,
|
|
574
574
|
'50028': errors.ExchangeError,
|
|
575
575
|
'50044': errors.BadRequest,
|
|
576
|
+
'50062': errors.ExchangeError,
|
|
576
577
|
// API Class
|
|
577
578
|
'50100': errors.ExchangeError,
|
|
578
579
|
'50101': errors.AuthenticationError,
|
|
@@ -627,6 +628,15 @@ class okx extends okx$1 {
|
|
|
627
628
|
'51072': errors.InvalidOrder,
|
|
628
629
|
'51073': errors.InvalidOrder,
|
|
629
630
|
'51074': errors.InvalidOrder,
|
|
631
|
+
'51090': errors.InvalidOrder,
|
|
632
|
+
'51091': errors.InvalidOrder,
|
|
633
|
+
'51092': errors.InvalidOrder,
|
|
634
|
+
'51093': errors.InvalidOrder,
|
|
635
|
+
'51094': errors.InvalidOrder,
|
|
636
|
+
'51095': errors.InvalidOrder,
|
|
637
|
+
'51096': errors.InvalidOrder,
|
|
638
|
+
'51098': errors.InvalidOrder,
|
|
639
|
+
'51099': errors.InvalidOrder,
|
|
630
640
|
'51100': errors.InvalidOrder,
|
|
631
641
|
'51101': errors.InvalidOrder,
|
|
632
642
|
'51102': errors.InvalidOrder,
|
|
@@ -2754,7 +2764,7 @@ class okx extends okx$1 {
|
|
|
2754
2764
|
}
|
|
2755
2765
|
request['tpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
2756
2766
|
const takeProfitLimitPrice = this.safeValueN(takeProfit, ['price', 'takeProfitPrice', 'tpOrdPx']);
|
|
2757
|
-
const takeProfitOrderType = this.
|
|
2767
|
+
const takeProfitOrderType = this.safeString2(takeProfit, 'type', 'tpOrdKind');
|
|
2758
2768
|
if (takeProfitOrderType !== undefined) {
|
|
2759
2769
|
const takeProfitLimitOrderType = (takeProfitOrderType === 'limit');
|
|
2760
2770
|
const takeProfitMarketOrderType = (takeProfitOrderType === 'market');
|
|
@@ -2766,6 +2776,7 @@ class okx extends okx$1 {
|
|
|
2766
2776
|
throw new errors.InvalidOrder(this.id + ' createOrder() requires a limit price in params["takeProfit"]["price"] or params["takeProfit"]["tpOrdPx"] for a take profit limit order');
|
|
2767
2777
|
}
|
|
2768
2778
|
else {
|
|
2779
|
+
request['tpOrdKind'] = takeProfitOrderType;
|
|
2769
2780
|
request['tpOrdPx'] = this.priceToPrecision(symbol, takeProfitLimitPrice);
|
|
2770
2781
|
}
|
|
2771
2782
|
}
|
|
@@ -2774,6 +2785,7 @@ class okx extends okx$1 {
|
|
|
2774
2785
|
}
|
|
2775
2786
|
}
|
|
2776
2787
|
else if (takeProfitLimitPrice !== undefined) {
|
|
2788
|
+
request['tpOrdKind'] = 'limit';
|
|
2777
2789
|
request['tpOrdPx'] = this.priceToPrecision(symbol, takeProfitLimitPrice); // limit tp order
|
|
2778
2790
|
}
|
|
2779
2791
|
else {
|
|
@@ -2798,6 +2810,7 @@ class okx extends okx$1 {
|
|
|
2798
2810
|
const twoWayCondition = ((takeProfitPrice !== undefined) && (stopLossPrice !== undefined));
|
|
2799
2811
|
// if TP and SL are sent together
|
|
2800
2812
|
// as ordType 'conditional' only stop-loss order will be applied
|
|
2813
|
+
// tpOrdKind is 'condition' which is the default
|
|
2801
2814
|
if (twoWayCondition) {
|
|
2802
2815
|
request['ordType'] = 'oco';
|
|
2803
2816
|
}
|
|
@@ -2851,6 +2864,7 @@ class okx extends okx$1 {
|
|
|
2851
2864
|
* @param {string} [params.stopLoss.type] 'market' or 'limit' used to specify the stop loss price type
|
|
2852
2865
|
* @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
|
|
2853
2866
|
* @param {string} [params.trailingPercent] the percent to trail away from the current market price
|
|
2867
|
+
* @param {string} [params.tpOrdKind] 'condition' or 'limit', the default is 'condition'
|
|
2854
2868
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2855
2869
|
*/
|
|
2856
2870
|
await this.loadMarkets();
|
|
@@ -3016,6 +3030,7 @@ class okx extends okx$1 {
|
|
|
3016
3030
|
takeProfitTriggerPrice = this.safeValue(takeProfit, 'triggerPrice');
|
|
3017
3031
|
takeProfitPrice = this.safeValue(takeProfit, 'price');
|
|
3018
3032
|
const takeProfitType = this.safeString(takeProfit, 'type');
|
|
3033
|
+
request['newTpOrdKind'] = (takeProfitType === 'limit') ? takeProfitType : 'condition';
|
|
3019
3034
|
request['newTpTriggerPx'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
|
|
3020
3035
|
request['newTpOrdPx'] = (takeProfitType === 'market') ? '-1' : this.priceToPrecision(symbol, takeProfitPrice);
|
|
3021
3036
|
request['newTpTriggerPxType'] = takeProfitTriggerPriceType;
|
|
@@ -3061,6 +3076,7 @@ class okx extends okx$1 {
|
|
|
3061
3076
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
3062
3077
|
* @param {float} [params.takeProfit.price] used for take profit limit orders, not used for take profit market price orders
|
|
3063
3078
|
* @param {string} [params.takeProfit.type] 'market' or 'limit' used to specify the take profit price type
|
|
3079
|
+
* @param {string} [params.newTpOrdKind] 'condition' or 'limit', the default is 'condition'
|
|
3064
3080
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3065
3081
|
*/
|
|
3066
3082
|
await this.loadMarkets();
|
|
@@ -63,6 +63,7 @@ class binance extends binance$1 {
|
|
|
63
63
|
'future': 'wss://fstream.binance.com/ws',
|
|
64
64
|
'delivery': 'wss://dstream.binance.com/ws',
|
|
65
65
|
'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
|
|
66
|
+
'papi': 'wss://fstream.binance.com/pm/ws',
|
|
66
67
|
},
|
|
67
68
|
},
|
|
68
69
|
},
|
|
@@ -1238,11 +1239,12 @@ class binance extends binance$1 {
|
|
|
1238
1239
|
}
|
|
1239
1240
|
async authenticate(params = {}) {
|
|
1240
1241
|
const time = this.milliseconds();
|
|
1241
|
-
let query = undefined;
|
|
1242
1242
|
let type = undefined;
|
|
1243
|
-
[type,
|
|
1243
|
+
[type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
|
|
1244
1244
|
let subType = undefined;
|
|
1245
|
-
[subType,
|
|
1245
|
+
[subType, params] = this.handleSubTypeAndParams('authenticate', undefined, params);
|
|
1246
|
+
let isPortfolioMargin = undefined;
|
|
1247
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'authenticate', 'papi', 'portfolioMargin', false);
|
|
1246
1248
|
if (this.isLinear(type, subType)) {
|
|
1247
1249
|
type = 'future';
|
|
1248
1250
|
}
|
|
@@ -1250,36 +1252,39 @@ class binance extends binance$1 {
|
|
|
1250
1252
|
type = 'delivery';
|
|
1251
1253
|
}
|
|
1252
1254
|
let marginMode = undefined;
|
|
1253
|
-
[marginMode,
|
|
1255
|
+
[marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
|
|
1254
1256
|
const isIsolatedMargin = (marginMode === 'isolated');
|
|
1255
1257
|
const isCrossMargin = (marginMode === 'cross') || (marginMode === undefined);
|
|
1256
|
-
const symbol = this.safeString(
|
|
1257
|
-
|
|
1258
|
+
const symbol = this.safeString(params, 'symbol');
|
|
1259
|
+
params = this.omit(params, 'symbol');
|
|
1258
1260
|
const options = this.safeValue(this.options, type, {});
|
|
1259
1261
|
const lastAuthenticatedTime = this.safeInteger(options, 'lastAuthenticatedTime', 0);
|
|
1260
1262
|
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
|
|
1261
1263
|
const delay = this.sum(listenKeyRefreshRate, 10000);
|
|
1262
1264
|
if (time - lastAuthenticatedTime > delay) {
|
|
1263
1265
|
let response = undefined;
|
|
1264
|
-
if (
|
|
1265
|
-
response = await this.
|
|
1266
|
+
if (isPortfolioMargin) {
|
|
1267
|
+
response = await this.papiPostListenKey(params);
|
|
1268
|
+
}
|
|
1269
|
+
else if (type === 'future') {
|
|
1270
|
+
response = await this.fapiPrivatePostListenKey(params);
|
|
1266
1271
|
}
|
|
1267
1272
|
else if (type === 'delivery') {
|
|
1268
|
-
response = await this.dapiPrivatePostListenKey(
|
|
1273
|
+
response = await this.dapiPrivatePostListenKey(params);
|
|
1269
1274
|
}
|
|
1270
1275
|
else if (type === 'margin' && isCrossMargin) {
|
|
1271
|
-
response = await this.sapiPostUserDataStream(
|
|
1276
|
+
response = await this.sapiPostUserDataStream(params);
|
|
1272
1277
|
}
|
|
1273
1278
|
else if (isIsolatedMargin) {
|
|
1274
1279
|
if (symbol === undefined) {
|
|
1275
1280
|
throw new errors.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
|
|
1276
1281
|
}
|
|
1277
1282
|
const marketId = this.marketId(symbol);
|
|
1278
|
-
|
|
1279
|
-
response = await this.sapiPostUserDataStreamIsolated(
|
|
1283
|
+
params = this.extend(params, { 'symbol': marketId });
|
|
1284
|
+
response = await this.sapiPostUserDataStreamIsolated(params);
|
|
1280
1285
|
}
|
|
1281
1286
|
else {
|
|
1282
|
-
response = await this.publicPostUserDataStream(
|
|
1287
|
+
response = await this.publicPostUserDataStream(params);
|
|
1283
1288
|
}
|
|
1284
1289
|
this.options[type] = this.extend(options, {
|
|
1285
1290
|
'listenKey': this.safeString(response, 'listenKey'),
|
|
@@ -1292,6 +1297,8 @@ class binance extends binance$1 {
|
|
|
1292
1297
|
// https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot
|
|
1293
1298
|
let type = this.safeString2(this.options, 'defaultType', 'authenticate', 'spot');
|
|
1294
1299
|
type = this.safeString(params, 'type', type);
|
|
1300
|
+
let isPortfolioMargin = undefined;
|
|
1301
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'keepAliveListenKey', 'papi', 'portfolioMargin', false);
|
|
1295
1302
|
const subTypeInfo = this.handleSubTypeAndParams('keepAliveListenKey', undefined, params);
|
|
1296
1303
|
const subType = subTypeInfo[0];
|
|
1297
1304
|
if (this.isLinear(type, subType)) {
|
|
@@ -1308,28 +1315,35 @@ class binance extends binance$1 {
|
|
|
1308
1315
|
}
|
|
1309
1316
|
const request = {};
|
|
1310
1317
|
const symbol = this.safeString(params, 'symbol');
|
|
1311
|
-
|
|
1318
|
+
params = this.omit(params, ['type', 'symbol']);
|
|
1312
1319
|
const time = this.milliseconds();
|
|
1313
1320
|
try {
|
|
1314
|
-
if (
|
|
1315
|
-
await this.
|
|
1321
|
+
if (isPortfolioMargin) {
|
|
1322
|
+
await this.papiPutListenKey(this.extend(request, params));
|
|
1323
|
+
}
|
|
1324
|
+
else if (type === 'future') {
|
|
1325
|
+
await this.fapiPrivatePutListenKey(this.extend(request, params));
|
|
1316
1326
|
}
|
|
1317
1327
|
else if (type === 'delivery') {
|
|
1318
|
-
await this.dapiPrivatePutListenKey(this.extend(request,
|
|
1328
|
+
await this.dapiPrivatePutListenKey(this.extend(request, params));
|
|
1319
1329
|
}
|
|
1320
1330
|
else {
|
|
1321
1331
|
request['listenKey'] = listenKey;
|
|
1322
1332
|
if (type === 'margin') {
|
|
1323
1333
|
request['symbol'] = symbol;
|
|
1324
|
-
await this.sapiPutUserDataStream(this.extend(request,
|
|
1334
|
+
await this.sapiPutUserDataStream(this.extend(request, params));
|
|
1325
1335
|
}
|
|
1326
1336
|
else {
|
|
1327
|
-
await this.publicPutUserDataStream(this.extend(request,
|
|
1337
|
+
await this.publicPutUserDataStream(this.extend(request, params));
|
|
1328
1338
|
}
|
|
1329
1339
|
}
|
|
1330
1340
|
}
|
|
1331
1341
|
catch (error) {
|
|
1332
|
-
|
|
1342
|
+
let urlType = type;
|
|
1343
|
+
if (isPortfolioMargin) {
|
|
1344
|
+
urlType = 'papi';
|
|
1345
|
+
}
|
|
1346
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
1333
1347
|
const client = this.client(url);
|
|
1334
1348
|
const messageHashes = Object.keys(client.futures);
|
|
1335
1349
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
@@ -1361,7 +1375,7 @@ class binance extends binance$1 {
|
|
|
1361
1375
|
}
|
|
1362
1376
|
}
|
|
1363
1377
|
}
|
|
1364
|
-
setBalanceCache(client, type) {
|
|
1378
|
+
setBalanceCache(client, type, isPortfolioMargin = false) {
|
|
1365
1379
|
if (type in client.subscriptions) {
|
|
1366
1380
|
return;
|
|
1367
1381
|
}
|
|
@@ -1371,15 +1385,21 @@ class binance extends binance$1 {
|
|
|
1371
1385
|
const messageHash = type + ':fetchBalanceSnapshot';
|
|
1372
1386
|
if (!(messageHash in client.futures)) {
|
|
1373
1387
|
client.future(messageHash);
|
|
1374
|
-
this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
|
|
1388
|
+
this.spawn(this.loadBalanceSnapshot, client, messageHash, type, isPortfolioMargin);
|
|
1375
1389
|
}
|
|
1376
1390
|
}
|
|
1377
1391
|
else {
|
|
1378
1392
|
this.balance[type] = {};
|
|
1379
1393
|
}
|
|
1380
1394
|
}
|
|
1381
|
-
async loadBalanceSnapshot(client, messageHash, type) {
|
|
1382
|
-
const
|
|
1395
|
+
async loadBalanceSnapshot(client, messageHash, type, isPortfolioMargin) {
|
|
1396
|
+
const params = {
|
|
1397
|
+
'type': type,
|
|
1398
|
+
};
|
|
1399
|
+
if (isPortfolioMargin) {
|
|
1400
|
+
params['portfolioMargin'] = true;
|
|
1401
|
+
}
|
|
1402
|
+
const response = await this.fetchBalance(params);
|
|
1383
1403
|
this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
|
|
1384
1404
|
// don't remove the future from the .futures cache
|
|
1385
1405
|
const future = client.futures[messageHash];
|
|
@@ -1473,6 +1493,7 @@ class binance extends binance$1 {
|
|
|
1473
1493
|
* @name binance#watchBalance
|
|
1474
1494
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
1475
1495
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1496
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch the balance of a portfolio margin account
|
|
1476
1497
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
1477
1498
|
*/
|
|
1478
1499
|
await this.loadMarkets();
|
|
@@ -1481,16 +1502,22 @@ class binance extends binance$1 {
|
|
|
1481
1502
|
let type = this.safeString(params, 'type', defaultType);
|
|
1482
1503
|
let subType = undefined;
|
|
1483
1504
|
[subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
|
|
1505
|
+
let isPortfolioMargin = undefined;
|
|
1506
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
|
|
1507
|
+
let urlType = type;
|
|
1508
|
+
if (isPortfolioMargin) {
|
|
1509
|
+
urlType = 'papi';
|
|
1510
|
+
}
|
|
1484
1511
|
if (this.isLinear(type, subType)) {
|
|
1485
1512
|
type = 'future';
|
|
1486
1513
|
}
|
|
1487
1514
|
else if (this.isInverse(type, subType)) {
|
|
1488
1515
|
type = 'delivery';
|
|
1489
1516
|
}
|
|
1490
|
-
const url = this.urls['api']['ws'][
|
|
1517
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
1491
1518
|
const client = this.client(url);
|
|
1492
|
-
this.setBalanceCache(client, type);
|
|
1493
|
-
this.setPositionsCache(client, type);
|
|
1519
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
1520
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
1494
1521
|
const options = this.safeValue(this.options, 'watchBalance');
|
|
1495
1522
|
const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
|
|
1496
1523
|
const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
|
|
@@ -2097,11 +2124,14 @@ class binance extends binance$1 {
|
|
|
2097
2124
|
* @name binance#watchOrders
|
|
2098
2125
|
* @description watches information on multiple orders made by the user
|
|
2099
2126
|
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
2127
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#event-futures-order-update
|
|
2128
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#event-margin-order-update
|
|
2100
2129
|
* @param {string} symbol unified market symbol of the market the orders were made in
|
|
2101
2130
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
2102
2131
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
2103
2132
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2104
2133
|
* @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
|
|
2134
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch portfolio margin account orders
|
|
2105
2135
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2106
2136
|
*/
|
|
2107
2137
|
await this.loadMarkets();
|
|
@@ -2130,10 +2160,15 @@ class binance extends binance$1 {
|
|
|
2130
2160
|
if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
|
|
2131
2161
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
2132
2162
|
}
|
|
2163
|
+
let isPortfolioMargin = undefined;
|
|
2164
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchOrders', 'papi', 'portfolioMargin', false);
|
|
2165
|
+
if (isPortfolioMargin) {
|
|
2166
|
+
urlType = 'papi';
|
|
2167
|
+
}
|
|
2133
2168
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
2134
2169
|
const client = this.client(url);
|
|
2135
|
-
this.setBalanceCache(client, type);
|
|
2136
|
-
this.setPositionsCache(client, type);
|
|
2170
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
2171
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
2137
2172
|
const message = undefined;
|
|
2138
2173
|
const orders = await this.watch(url, messageHash, message, type);
|
|
2139
2174
|
if (this.newUpdates) {
|
|
@@ -2388,6 +2423,7 @@ class binance extends binance$1 {
|
|
|
2388
2423
|
* @description watch all open positions
|
|
2389
2424
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
2390
2425
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
2426
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
|
|
2391
2427
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
2392
2428
|
*/
|
|
2393
2429
|
await this.loadMarkets();
|
|
@@ -2418,10 +2454,16 @@ class binance extends binance$1 {
|
|
|
2418
2454
|
type = 'delivery';
|
|
2419
2455
|
}
|
|
2420
2456
|
messageHash = type + ':positions' + messageHash;
|
|
2421
|
-
|
|
2457
|
+
let isPortfolioMargin = undefined;
|
|
2458
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchPositions', 'papi', 'portfolioMargin', false);
|
|
2459
|
+
let urlType = type;
|
|
2460
|
+
if (isPortfolioMargin) {
|
|
2461
|
+
urlType = 'papi';
|
|
2462
|
+
}
|
|
2463
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
2422
2464
|
const client = this.client(url);
|
|
2423
|
-
this.setBalanceCache(client, type);
|
|
2424
|
-
this.setPositionsCache(client, type, symbols);
|
|
2465
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
2466
|
+
this.setPositionsCache(client, type, symbols, isPortfolioMargin);
|
|
2425
2467
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
2426
2468
|
const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
|
|
2427
2469
|
const cache = this.safeValue(this.positions, type);
|
|
@@ -2435,7 +2477,7 @@ class binance extends binance$1 {
|
|
|
2435
2477
|
}
|
|
2436
2478
|
return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
|
|
2437
2479
|
}
|
|
2438
|
-
setPositionsCache(client, type, symbols = undefined) {
|
|
2480
|
+
setPositionsCache(client, type, symbols = undefined, isPortfolioMargin = false) {
|
|
2439
2481
|
if (type === 'spot') {
|
|
2440
2482
|
return;
|
|
2441
2483
|
}
|
|
@@ -2450,15 +2492,21 @@ class binance extends binance$1 {
|
|
|
2450
2492
|
const messageHash = type + ':fetchPositionsSnapshot';
|
|
2451
2493
|
if (!(messageHash in client.futures)) {
|
|
2452
2494
|
client.future(messageHash);
|
|
2453
|
-
this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
|
|
2495
|
+
this.spawn(this.loadPositionsSnapshot, client, messageHash, type, isPortfolioMargin);
|
|
2454
2496
|
}
|
|
2455
2497
|
}
|
|
2456
2498
|
else {
|
|
2457
2499
|
this.positions[type] = new Cache.ArrayCacheBySymbolBySide();
|
|
2458
2500
|
}
|
|
2459
2501
|
}
|
|
2460
|
-
async loadPositionsSnapshot(client, messageHash, type) {
|
|
2461
|
-
const
|
|
2502
|
+
async loadPositionsSnapshot(client, messageHash, type, isPortfolioMargin) {
|
|
2503
|
+
const params = {
|
|
2504
|
+
'type': type,
|
|
2505
|
+
};
|
|
2506
|
+
if (isPortfolioMargin) {
|
|
2507
|
+
params['portfolioMargin'] = true;
|
|
2508
|
+
}
|
|
2509
|
+
const positions = await this.fetchPositions(undefined, params);
|
|
2462
2510
|
this.positions[type] = new Cache.ArrayCacheBySymbolBySide();
|
|
2463
2511
|
const cache = this.positions[type];
|
|
2464
2512
|
for (let i = 0; i < positions.length; i++) {
|
|
@@ -2731,6 +2779,7 @@ class binance extends binance$1 {
|
|
|
2731
2779
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
2732
2780
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
2733
2781
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2782
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
|
|
2734
2783
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
2735
2784
|
*/
|
|
2736
2785
|
await this.loadMarkets();
|
|
@@ -2760,10 +2809,15 @@ class binance extends binance$1 {
|
|
|
2760
2809
|
if (type === 'margin') {
|
|
2761
2810
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
2762
2811
|
}
|
|
2812
|
+
let isPortfolioMargin = undefined;
|
|
2813
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchMyTrades', 'papi', 'portfolioMargin', false);
|
|
2814
|
+
if (isPortfolioMargin) {
|
|
2815
|
+
urlType = 'papi';
|
|
2816
|
+
}
|
|
2763
2817
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
2764
2818
|
const client = this.client(url);
|
|
2765
|
-
this.setBalanceCache(client, type);
|
|
2766
|
-
this.setPositionsCache(client, type);
|
|
2819
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
2820
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
2767
2821
|
const message = undefined;
|
|
2768
2822
|
const trades = await this.watch(url, messageHash, message, type);
|
|
2769
2823
|
if (this.newUpdates) {
|
package/dist/cjs/src/whitebit.js
CHANGED
|
@@ -227,6 +227,7 @@ class whitebit extends whitebit$1 {
|
|
|
227
227
|
'account': 'spot',
|
|
228
228
|
},
|
|
229
229
|
'accountsByType': {
|
|
230
|
+
'funding': 'main',
|
|
230
231
|
'main': 'main',
|
|
231
232
|
'spot': 'spot',
|
|
232
233
|
'margin': 'collateral',
|
|
@@ -1320,9 +1321,9 @@ class whitebit extends whitebit$1 {
|
|
|
1320
1321
|
else {
|
|
1321
1322
|
const options = this.safeValue(this.options, 'fetchBalance', {});
|
|
1322
1323
|
const defaultAccount = this.safeString(options, 'account');
|
|
1323
|
-
const account = this.
|
|
1324
|
-
params = this.omit(params, 'account');
|
|
1325
|
-
if (account === 'main') {
|
|
1324
|
+
const account = this.safeString2(params, 'account', 'type', defaultAccount);
|
|
1325
|
+
params = this.omit(params, ['account', 'type']);
|
|
1326
|
+
if (account === 'main' || account === 'funding') {
|
|
1326
1327
|
response = await this.v4PrivatePostMainAccountBalance(params);
|
|
1327
1328
|
}
|
|
1328
1329
|
else {
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.54";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|