ccxt 4.2.53 → 4.2.54
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 +202 -47
- 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/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/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/pro/binance.d.ts +4 -4
- package/js/src/pro/binance.js +92 -38
- package/js/src/whitebit.js +4 -3
- package/jsdoc2md.js +3 -2
- package/package.json +1 -1
- package/skip-tests.json +1 -1
package/README.md
CHANGED
|
@@ -209,13 +209,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
209
209
|
|
|
210
210
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
211
211
|
|
|
212
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
213
|
-
* unpkg: https://unpkg.com/ccxt@4.2.
|
|
212
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.2.54/dist/ccxt.browser.js
|
|
213
|
+
* unpkg: https://unpkg.com/ccxt@4.2.54/dist/ccxt.browser.js
|
|
214
214
|
|
|
215
215
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
216
216
|
|
|
217
217
|
```HTML
|
|
218
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.
|
|
218
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.2.54/dist/ccxt.browser.js"></script>
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -18179,7 +18179,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18179
18179
|
'fetchL3OrderBook': false,
|
|
18180
18180
|
'fetchLastPrices': true,
|
|
18181
18181
|
'fetchLedger': true,
|
|
18182
|
-
'
|
|
18182
|
+
'fetchLedgerEntry': true,
|
|
18183
|
+
'fetchLeverage': true,
|
|
18183
18184
|
'fetchLeverageTiers': true,
|
|
18184
18185
|
'fetchLiquidations': false,
|
|
18185
18186
|
'fetchMarketLeverageTiers': 'emulated',
|
|
@@ -18379,8 +18380,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18379
18380
|
'loan/flexible/borrow/history': 40,
|
|
18380
18381
|
'loan/flexible/repay/history': 40,
|
|
18381
18382
|
'loan/flexible/ltv/adjustment/history': 40,
|
|
18382
|
-
'loan/flexible/loanable/data': 40,
|
|
18383
|
-
'loan/flexible/collateral/data': 40,
|
|
18384
18383
|
'loan/vip/ongoing/orders': 40,
|
|
18385
18384
|
'loan/vip/repay/history': 40,
|
|
18386
18385
|
'loan/vip/collateral/account': 600,
|
|
@@ -18672,7 +18671,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18672
18671
|
'loan/repay': 40.002,
|
|
18673
18672
|
'loan/adjust/ltv': 40.002,
|
|
18674
18673
|
'loan/customize/margin_call': 40.002,
|
|
18675
|
-
'loan/flexible/borrow': 40.002,
|
|
18676
18674
|
'loan/flexible/repay': 40.002,
|
|
18677
18675
|
'loan/flexible/adjust/ltv': 40.002,
|
|
18678
18676
|
'loan/vip/repay': 40.002,
|
|
@@ -18727,10 +18725,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
18727
18725
|
'sub-account/futures/account': 0.1,
|
|
18728
18726
|
'sub-account/futures/accountSummary': 1,
|
|
18729
18727
|
'sub-account/futures/positionRisk': 0.1,
|
|
18728
|
+
'loan/flexible/ongoing/orders': 30,
|
|
18729
|
+
'loan/flexible/borrow/history': 40,
|
|
18730
|
+
'loan/flexible/repay/history': 40,
|
|
18731
|
+
'loan/flexible/ltv/adjustment/history': 40,
|
|
18732
|
+
'loan/flexible/loanable/data': 40,
|
|
18733
|
+
'loan/flexible/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
|
|
18730
18734
|
},
|
|
18731
18735
|
'post': {
|
|
18732
18736
|
'eth-staking/eth/stake': 15,
|
|
18733
|
-
'sub-account/subAccountApi/ipRestriction': 20.001,
|
|
18737
|
+
'sub-account/subAccountApi/ipRestriction': 20.001,
|
|
18738
|
+
'loan/flexible/borrow': 40.002,
|
|
18739
|
+
'loan/flexible/repay': 40.002,
|
|
18740
|
+
'loan/flexible/adjust/ltv': 40.002, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40.002
|
|
18734
18741
|
},
|
|
18735
18742
|
},
|
|
18736
18743
|
'sapiV3': {
|
|
@@ -28465,6 +28472,67 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28465
28472
|
//
|
|
28466
28473
|
return response;
|
|
28467
28474
|
}
|
|
28475
|
+
async fetchLeverage(symbol, params = {}) {
|
|
28476
|
+
/**
|
|
28477
|
+
* @method
|
|
28478
|
+
* @name binance#fetchLeverage
|
|
28479
|
+
* @description fetch the set leverage for a market
|
|
28480
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
|
|
28481
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
|
|
28482
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
|
|
28483
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
|
|
28484
|
+
* @param {string} symbol unified market symbol
|
|
28485
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
28486
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
28487
|
+
*/
|
|
28488
|
+
await this.loadMarkets();
|
|
28489
|
+
await this.loadLeverageBrackets(false, params);
|
|
28490
|
+
const market = this.market(symbol);
|
|
28491
|
+
if (!market['contract']) {
|
|
28492
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
|
|
28493
|
+
}
|
|
28494
|
+
let type = undefined;
|
|
28495
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
|
|
28496
|
+
let subType = undefined;
|
|
28497
|
+
[subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
|
|
28498
|
+
let isPortfolioMargin = undefined;
|
|
28499
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
|
|
28500
|
+
let response = undefined;
|
|
28501
|
+
if (this.isLinear(type, subType)) {
|
|
28502
|
+
if (isPortfolioMargin) {
|
|
28503
|
+
response = await this.papiGetUmAccount(params);
|
|
28504
|
+
}
|
|
28505
|
+
else {
|
|
28506
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
28507
|
+
}
|
|
28508
|
+
}
|
|
28509
|
+
else if (this.isInverse(type, subType)) {
|
|
28510
|
+
if (isPortfolioMargin) {
|
|
28511
|
+
response = await this.papiGetCmAccount(params);
|
|
28512
|
+
}
|
|
28513
|
+
else {
|
|
28514
|
+
response = await this.dapiPrivateGetAccount(params);
|
|
28515
|
+
}
|
|
28516
|
+
}
|
|
28517
|
+
else {
|
|
28518
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
|
|
28519
|
+
}
|
|
28520
|
+
const positions = this.safeList(response, 'positions', []);
|
|
28521
|
+
for (let i = 0; i < positions.length; i++) {
|
|
28522
|
+
const position = positions[i];
|
|
28523
|
+
const innerSymbol = this.safeString(position, 'symbol');
|
|
28524
|
+
if (innerSymbol === market['id']) {
|
|
28525
|
+
const isolated = this.safeBool(position, 'isolated');
|
|
28526
|
+
const marginMode = isolated ? 'isolated' : 'cross';
|
|
28527
|
+
return {
|
|
28528
|
+
'info': position,
|
|
28529
|
+
'marginMode': marginMode,
|
|
28530
|
+
'leverage': this.safeInteger(position, 'leverage'),
|
|
28531
|
+
};
|
|
28532
|
+
}
|
|
28533
|
+
}
|
|
28534
|
+
return response;
|
|
28535
|
+
}
|
|
28468
28536
|
async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
28469
28537
|
/**
|
|
28470
28538
|
* @method
|
|
@@ -28647,6 +28715,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
|
|
|
28647
28715
|
}
|
|
28648
28716
|
return result;
|
|
28649
28717
|
}
|
|
28718
|
+
async fetchLedgerEntry(id, code = undefined, params = {}) {
|
|
28719
|
+
await this.loadMarkets();
|
|
28720
|
+
let type = undefined;
|
|
28721
|
+
[type, params] = this.handleMarketTypeAndParams('fetchLedgerEntry', undefined, params);
|
|
28722
|
+
const query = {
|
|
28723
|
+
'recordId': id,
|
|
28724
|
+
'type': type,
|
|
28725
|
+
};
|
|
28726
|
+
if (type !== 'option') {
|
|
28727
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchLedgerEntry () can only be used for type option');
|
|
28728
|
+
}
|
|
28729
|
+
return await this.fetchLedger(code, undefined, undefined, this.extend(query, params));
|
|
28730
|
+
}
|
|
28650
28731
|
async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
28651
28732
|
/**
|
|
28652
28733
|
* @method
|
|
@@ -82408,6 +82489,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
82408
82489
|
'fetchUnderlyingAssets': false,
|
|
82409
82490
|
'fetchVolatilityHistory': true,
|
|
82410
82491
|
'fetchWithdrawals': true,
|
|
82492
|
+
'fetchLeverage': true,
|
|
82411
82493
|
'repayCrossMargin': true,
|
|
82412
82494
|
'setLeverage': true,
|
|
82413
82495
|
'setMarginMode': true,
|
|
@@ -88644,6 +88726,24 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
|
|
|
88644
88726
|
'takeProfitPrice': this.safeNumber2(position, 'take_profit', 'takeProfit'),
|
|
88645
88727
|
});
|
|
88646
88728
|
}
|
|
88729
|
+
async fetchLeverage(symbol, params = {}) {
|
|
88730
|
+
/**
|
|
88731
|
+
* @method
|
|
88732
|
+
* @name bybit#fetchLeverage
|
|
88733
|
+
* @description fetch the set leverage for a market
|
|
88734
|
+
* @see https://bybit-exchange.github.io/docs/v5/position
|
|
88735
|
+
* @param {string} symbol unified market symbol
|
|
88736
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
88737
|
+
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
88738
|
+
*/
|
|
88739
|
+
await this.loadMarkets();
|
|
88740
|
+
const position = await this.fetchPosition(symbol, params);
|
|
88741
|
+
return {
|
|
88742
|
+
'info': position,
|
|
88743
|
+
'leverage': this.safeInteger(position, 'leverage'),
|
|
88744
|
+
'marginMode': this.safeNumber(position, 'marginMode'),
|
|
88745
|
+
};
|
|
88746
|
+
}
|
|
88647
88747
|
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
88648
88748
|
/**
|
|
88649
88749
|
* @method
|
|
@@ -220006,6 +220106,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
220006
220106
|
'future': 'wss://fstream.binance.com/ws',
|
|
220007
220107
|
'delivery': 'wss://dstream.binance.com/ws',
|
|
220008
220108
|
'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
|
|
220109
|
+
'papi': 'wss://fstream.binance.com/pm/ws',
|
|
220009
220110
|
},
|
|
220010
220111
|
},
|
|
220011
220112
|
},
|
|
@@ -221181,11 +221282,12 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221181
221282
|
}
|
|
221182
221283
|
async authenticate(params = {}) {
|
|
221183
221284
|
const time = this.milliseconds();
|
|
221184
|
-
let query = undefined;
|
|
221185
221285
|
let type = undefined;
|
|
221186
|
-
[type,
|
|
221286
|
+
[type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
|
|
221187
221287
|
let subType = undefined;
|
|
221188
|
-
[subType,
|
|
221288
|
+
[subType, params] = this.handleSubTypeAndParams('authenticate', undefined, params);
|
|
221289
|
+
let isPortfolioMargin = undefined;
|
|
221290
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'authenticate', 'papi', 'portfolioMargin', false);
|
|
221189
221291
|
if (this.isLinear(type, subType)) {
|
|
221190
221292
|
type = 'future';
|
|
221191
221293
|
}
|
|
@@ -221193,36 +221295,39 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221193
221295
|
type = 'delivery';
|
|
221194
221296
|
}
|
|
221195
221297
|
let marginMode = undefined;
|
|
221196
|
-
[marginMode,
|
|
221298
|
+
[marginMode, params] = this.handleMarginModeAndParams('authenticate', params);
|
|
221197
221299
|
const isIsolatedMargin = (marginMode === 'isolated');
|
|
221198
221300
|
const isCrossMargin = (marginMode === 'cross') || (marginMode === undefined);
|
|
221199
|
-
const symbol = this.safeString(
|
|
221200
|
-
|
|
221301
|
+
const symbol = this.safeString(params, 'symbol');
|
|
221302
|
+
params = this.omit(params, 'symbol');
|
|
221201
221303
|
const options = this.safeValue(this.options, type, {});
|
|
221202
221304
|
const lastAuthenticatedTime = this.safeInteger(options, 'lastAuthenticatedTime', 0);
|
|
221203
221305
|
const listenKeyRefreshRate = this.safeInteger(this.options, 'listenKeyRefreshRate', 1200000);
|
|
221204
221306
|
const delay = this.sum(listenKeyRefreshRate, 10000);
|
|
221205
221307
|
if (time - lastAuthenticatedTime > delay) {
|
|
221206
221308
|
let response = undefined;
|
|
221207
|
-
if (
|
|
221208
|
-
response = await this.
|
|
221309
|
+
if (isPortfolioMargin) {
|
|
221310
|
+
response = await this.papiPostListenKey(params);
|
|
221311
|
+
}
|
|
221312
|
+
else if (type === 'future') {
|
|
221313
|
+
response = await this.fapiPrivatePostListenKey(params);
|
|
221209
221314
|
}
|
|
221210
221315
|
else if (type === 'delivery') {
|
|
221211
|
-
response = await this.dapiPrivatePostListenKey(
|
|
221316
|
+
response = await this.dapiPrivatePostListenKey(params);
|
|
221212
221317
|
}
|
|
221213
221318
|
else if (type === 'margin' && isCrossMargin) {
|
|
221214
|
-
response = await this.sapiPostUserDataStream(
|
|
221319
|
+
response = await this.sapiPostUserDataStream(params);
|
|
221215
221320
|
}
|
|
221216
221321
|
else if (isIsolatedMargin) {
|
|
221217
221322
|
if (symbol === undefined) {
|
|
221218
221323
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' authenticate() requires a symbol argument for isolated margin mode');
|
|
221219
221324
|
}
|
|
221220
221325
|
const marketId = this.marketId(symbol);
|
|
221221
|
-
|
|
221222
|
-
response = await this.sapiPostUserDataStreamIsolated(
|
|
221326
|
+
params = this.extend(params, { 'symbol': marketId });
|
|
221327
|
+
response = await this.sapiPostUserDataStreamIsolated(params);
|
|
221223
221328
|
}
|
|
221224
221329
|
else {
|
|
221225
|
-
response = await this.publicPostUserDataStream(
|
|
221330
|
+
response = await this.publicPostUserDataStream(params);
|
|
221226
221331
|
}
|
|
221227
221332
|
this.options[type] = this.extend(options, {
|
|
221228
221333
|
'listenKey': this.safeString(response, 'listenKey'),
|
|
@@ -221235,6 +221340,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221235
221340
|
// https://binance-docs.github.io/apidocs/spot/en/#listen-key-spot
|
|
221236
221341
|
let type = this.safeString2(this.options, 'defaultType', 'authenticate', 'spot');
|
|
221237
221342
|
type = this.safeString(params, 'type', type);
|
|
221343
|
+
let isPortfolioMargin = undefined;
|
|
221344
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'keepAliveListenKey', 'papi', 'portfolioMargin', false);
|
|
221238
221345
|
const subTypeInfo = this.handleSubTypeAndParams('keepAliveListenKey', undefined, params);
|
|
221239
221346
|
const subType = subTypeInfo[0];
|
|
221240
221347
|
if (this.isLinear(type, subType)) {
|
|
@@ -221251,28 +221358,35 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221251
221358
|
}
|
|
221252
221359
|
const request = {};
|
|
221253
221360
|
const symbol = this.safeString(params, 'symbol');
|
|
221254
|
-
|
|
221361
|
+
params = this.omit(params, ['type', 'symbol']);
|
|
221255
221362
|
const time = this.milliseconds();
|
|
221256
221363
|
try {
|
|
221257
|
-
if (
|
|
221258
|
-
await this.
|
|
221364
|
+
if (isPortfolioMargin) {
|
|
221365
|
+
await this.papiPutListenKey(this.extend(request, params));
|
|
221366
|
+
}
|
|
221367
|
+
else if (type === 'future') {
|
|
221368
|
+
await this.fapiPrivatePutListenKey(this.extend(request, params));
|
|
221259
221369
|
}
|
|
221260
221370
|
else if (type === 'delivery') {
|
|
221261
|
-
await this.dapiPrivatePutListenKey(this.extend(request,
|
|
221371
|
+
await this.dapiPrivatePutListenKey(this.extend(request, params));
|
|
221262
221372
|
}
|
|
221263
221373
|
else {
|
|
221264
221374
|
request['listenKey'] = listenKey;
|
|
221265
221375
|
if (type === 'margin') {
|
|
221266
221376
|
request['symbol'] = symbol;
|
|
221267
|
-
await this.sapiPutUserDataStream(this.extend(request,
|
|
221377
|
+
await this.sapiPutUserDataStream(this.extend(request, params));
|
|
221268
221378
|
}
|
|
221269
221379
|
else {
|
|
221270
|
-
await this.publicPutUserDataStream(this.extend(request,
|
|
221380
|
+
await this.publicPutUserDataStream(this.extend(request, params));
|
|
221271
221381
|
}
|
|
221272
221382
|
}
|
|
221273
221383
|
}
|
|
221274
221384
|
catch (error) {
|
|
221275
|
-
|
|
221385
|
+
let urlType = type;
|
|
221386
|
+
if (isPortfolioMargin) {
|
|
221387
|
+
urlType = 'papi';
|
|
221388
|
+
}
|
|
221389
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
221276
221390
|
const client = this.client(url);
|
|
221277
221391
|
const messageHashes = Object.keys(client.futures);
|
|
221278
221392
|
for (let i = 0; i < messageHashes.length; i++) {
|
|
@@ -221304,7 +221418,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221304
221418
|
}
|
|
221305
221419
|
}
|
|
221306
221420
|
}
|
|
221307
|
-
setBalanceCache(client, type) {
|
|
221421
|
+
setBalanceCache(client, type, isPortfolioMargin = false) {
|
|
221308
221422
|
if (type in client.subscriptions) {
|
|
221309
221423
|
return;
|
|
221310
221424
|
}
|
|
@@ -221314,15 +221428,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221314
221428
|
const messageHash = type + ':fetchBalanceSnapshot';
|
|
221315
221429
|
if (!(messageHash in client.futures)) {
|
|
221316
221430
|
client.future(messageHash);
|
|
221317
|
-
this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
|
|
221431
|
+
this.spawn(this.loadBalanceSnapshot, client, messageHash, type, isPortfolioMargin);
|
|
221318
221432
|
}
|
|
221319
221433
|
}
|
|
221320
221434
|
else {
|
|
221321
221435
|
this.balance[type] = {};
|
|
221322
221436
|
}
|
|
221323
221437
|
}
|
|
221324
|
-
async loadBalanceSnapshot(client, messageHash, type) {
|
|
221325
|
-
const
|
|
221438
|
+
async loadBalanceSnapshot(client, messageHash, type, isPortfolioMargin) {
|
|
221439
|
+
const params = {
|
|
221440
|
+
'type': type,
|
|
221441
|
+
};
|
|
221442
|
+
if (isPortfolioMargin) {
|
|
221443
|
+
params['portfolioMargin'] = true;
|
|
221444
|
+
}
|
|
221445
|
+
const response = await this.fetchBalance(params);
|
|
221326
221446
|
this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
|
|
221327
221447
|
// don't remove the future from the .futures cache
|
|
221328
221448
|
const future = client.futures[messageHash];
|
|
@@ -221416,6 +221536,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221416
221536
|
* @name binance#watchBalance
|
|
221417
221537
|
* @description watch balance and get the amount of funds available for trading or funds locked in orders
|
|
221418
221538
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
221539
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch the balance of a portfolio margin account
|
|
221419
221540
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
221420
221541
|
*/
|
|
221421
221542
|
await this.loadMarkets();
|
|
@@ -221424,16 +221545,22 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
221424
221545
|
let type = this.safeString(params, 'type', defaultType);
|
|
221425
221546
|
let subType = undefined;
|
|
221426
221547
|
[subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params);
|
|
221548
|
+
let isPortfolioMargin = undefined;
|
|
221549
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchBalance', 'papi', 'portfolioMargin', false);
|
|
221550
|
+
let urlType = type;
|
|
221551
|
+
if (isPortfolioMargin) {
|
|
221552
|
+
urlType = 'papi';
|
|
221553
|
+
}
|
|
221427
221554
|
if (this.isLinear(type, subType)) {
|
|
221428
221555
|
type = 'future';
|
|
221429
221556
|
}
|
|
221430
221557
|
else if (this.isInverse(type, subType)) {
|
|
221431
221558
|
type = 'delivery';
|
|
221432
221559
|
}
|
|
221433
|
-
const url = this.urls['api']['ws'][
|
|
221560
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
221434
221561
|
const client = this.client(url);
|
|
221435
|
-
this.setBalanceCache(client, type);
|
|
221436
|
-
this.setPositionsCache(client, type);
|
|
221562
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
221563
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
221437
221564
|
const options = this.safeValue(this.options, 'watchBalance');
|
|
221438
221565
|
const fetchBalanceSnapshot = this.safeBool(options, 'fetchBalanceSnapshot', false);
|
|
221439
221566
|
const awaitBalanceSnapshot = this.safeBool(options, 'awaitBalanceSnapshot', true);
|
|
@@ -222040,11 +222167,14 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222040
222167
|
* @name binance#watchOrders
|
|
222041
222168
|
* @description watches information on multiple orders made by the user
|
|
222042
222169
|
* @see https://binance-docs.github.io/apidocs/spot/en/#payload-order-update
|
|
222170
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#event-futures-order-update
|
|
222171
|
+
* @see https://binance-docs.github.io/apidocs/pm/en/#event-margin-order-update
|
|
222043
222172
|
* @param {string} symbol unified market symbol of the market the orders were made in
|
|
222044
222173
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
222045
222174
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
222046
222175
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
222047
222176
|
* @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for spot margin
|
|
222177
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch portfolio margin account orders
|
|
222048
222178
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
222049
222179
|
*/
|
|
222050
222180
|
await this.loadMarkets();
|
|
@@ -222073,10 +222203,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222073
222203
|
if ((type === 'margin') || ((type === 'spot') && (marginMode !== undefined))) {
|
|
222074
222204
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
222075
222205
|
}
|
|
222206
|
+
let isPortfolioMargin = undefined;
|
|
222207
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchOrders', 'papi', 'portfolioMargin', false);
|
|
222208
|
+
if (isPortfolioMargin) {
|
|
222209
|
+
urlType = 'papi';
|
|
222210
|
+
}
|
|
222076
222211
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
222077
222212
|
const client = this.client(url);
|
|
222078
|
-
this.setBalanceCache(client, type);
|
|
222079
|
-
this.setPositionsCache(client, type);
|
|
222213
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
222214
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
222080
222215
|
const message = undefined;
|
|
222081
222216
|
const orders = await this.watch(url, messageHash, message, type);
|
|
222082
222217
|
if (this.newUpdates) {
|
|
@@ -222331,6 +222466,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222331
222466
|
* @description watch all open positions
|
|
222332
222467
|
* @param {string[]|undefined} symbols list of unified market symbols
|
|
222333
222468
|
* @param {object} params extra parameters specific to the exchange API endpoint
|
|
222469
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch positions in a portfolio margin account
|
|
222334
222470
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
|
|
222335
222471
|
*/
|
|
222336
222472
|
await this.loadMarkets();
|
|
@@ -222361,10 +222497,16 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222361
222497
|
type = 'delivery';
|
|
222362
222498
|
}
|
|
222363
222499
|
messageHash = type + ':positions' + messageHash;
|
|
222364
|
-
|
|
222500
|
+
let isPortfolioMargin = undefined;
|
|
222501
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchPositions', 'papi', 'portfolioMargin', false);
|
|
222502
|
+
let urlType = type;
|
|
222503
|
+
if (isPortfolioMargin) {
|
|
222504
|
+
urlType = 'papi';
|
|
222505
|
+
}
|
|
222506
|
+
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
222365
222507
|
const client = this.client(url);
|
|
222366
|
-
this.setBalanceCache(client, type);
|
|
222367
|
-
this.setPositionsCache(client, type, symbols);
|
|
222508
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
222509
|
+
this.setPositionsCache(client, type, symbols, isPortfolioMargin);
|
|
222368
222510
|
const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
|
|
222369
222511
|
const awaitPositionsSnapshot = this.safeValue('watchPositions', 'awaitPositionsSnapshot', true);
|
|
222370
222512
|
const cache = this.safeValue(this.positions, type);
|
|
@@ -222378,7 +222520,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222378
222520
|
}
|
|
222379
222521
|
return this.filterBySymbolsSinceLimit(cache, symbols, since, limit, true);
|
|
222380
222522
|
}
|
|
222381
|
-
setPositionsCache(client, type, symbols = undefined) {
|
|
222523
|
+
setPositionsCache(client, type, symbols = undefined, isPortfolioMargin = false) {
|
|
222382
222524
|
if (type === 'spot') {
|
|
222383
222525
|
return;
|
|
222384
222526
|
}
|
|
@@ -222393,15 +222535,21 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222393
222535
|
const messageHash = type + ':fetchPositionsSnapshot';
|
|
222394
222536
|
if (!(messageHash in client.futures)) {
|
|
222395
222537
|
client.future(messageHash);
|
|
222396
|
-
this.spawn(this.loadPositionsSnapshot, client, messageHash, type);
|
|
222538
|
+
this.spawn(this.loadPositionsSnapshot, client, messageHash, type, isPortfolioMargin);
|
|
222397
222539
|
}
|
|
222398
222540
|
}
|
|
222399
222541
|
else {
|
|
222400
222542
|
this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
|
|
222401
222543
|
}
|
|
222402
222544
|
}
|
|
222403
|
-
async loadPositionsSnapshot(client, messageHash, type) {
|
|
222404
|
-
const
|
|
222545
|
+
async loadPositionsSnapshot(client, messageHash, type, isPortfolioMargin) {
|
|
222546
|
+
const params = {
|
|
222547
|
+
'type': type,
|
|
222548
|
+
};
|
|
222549
|
+
if (isPortfolioMargin) {
|
|
222550
|
+
params['portfolioMargin'] = true;
|
|
222551
|
+
}
|
|
222552
|
+
const positions = await this.fetchPositions(undefined, params);
|
|
222405
222553
|
this.positions[type] = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolBySide */ .tU();
|
|
222406
222554
|
const cache = this.positions[type];
|
|
222407
222555
|
for (let i = 0; i < positions.length; i++) {
|
|
@@ -222674,6 +222822,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222674
222822
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
222675
222823
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
222676
222824
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
222825
|
+
* @param {boolean} [params.portfolioMargin] set to true if you would like to watch trades in a portfolio margin account
|
|
222677
222826
|
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure
|
|
222678
222827
|
*/
|
|
222679
222828
|
await this.loadMarkets();
|
|
@@ -222703,10 +222852,15 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
222703
222852
|
if (type === 'margin') {
|
|
222704
222853
|
urlType = 'spot'; // spot-margin shares the same stream as regular spot
|
|
222705
222854
|
}
|
|
222855
|
+
let isPortfolioMargin = undefined;
|
|
222856
|
+
[isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'watchMyTrades', 'papi', 'portfolioMargin', false);
|
|
222857
|
+
if (isPortfolioMargin) {
|
|
222858
|
+
urlType = 'papi';
|
|
222859
|
+
}
|
|
222706
222860
|
const url = this.urls['api']['ws'][urlType] + '/' + this.options[type]['listenKey'];
|
|
222707
222861
|
const client = this.client(url);
|
|
222708
|
-
this.setBalanceCache(client, type);
|
|
222709
|
-
this.setPositionsCache(client, type);
|
|
222862
|
+
this.setBalanceCache(client, type, isPortfolioMargin);
|
|
222863
|
+
this.setPositionsCache(client, type, undefined, isPortfolioMargin);
|
|
222710
222864
|
const message = undefined;
|
|
222711
222865
|
const trades = await this.watch(url, messageHash, message, type);
|
|
222712
222866
|
if (this.newUpdates) {
|
|
@@ -293003,6 +293157,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
293003
293157
|
'account': 'spot',
|
|
293004
293158
|
},
|
|
293005
293159
|
'accountsByType': {
|
|
293160
|
+
'funding': 'main',
|
|
293006
293161
|
'main': 'main',
|
|
293007
293162
|
'spot': 'spot',
|
|
293008
293163
|
'margin': 'collateral',
|
|
@@ -294096,9 +294251,9 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
|
|
|
294096
294251
|
else {
|
|
294097
294252
|
const options = this.safeValue(this.options, 'fetchBalance', {});
|
|
294098
294253
|
const defaultAccount = this.safeString(options, 'account');
|
|
294099
|
-
const account = this.
|
|
294100
|
-
params = this.omit(params, 'account');
|
|
294101
|
-
if (account === 'main') {
|
|
294254
|
+
const account = this.safeString2(params, 'account', 'type', defaultAccount);
|
|
294255
|
+
params = this.omit(params, ['account', 'type']);
|
|
294256
|
+
if (account === 'main' || account === 'funding') {
|
|
294102
294257
|
response = await this.v4PrivatePostMainAccountBalance(params);
|
|
294103
294258
|
}
|
|
294104
294259
|
else {
|
|
@@ -307460,7 +307615,7 @@ SOFTWARE.
|
|
|
307460
307615
|
|
|
307461
307616
|
//-----------------------------------------------------------------------------
|
|
307462
307617
|
// this is updated by vss.js when building
|
|
307463
|
-
const version = '4.2.
|
|
307618
|
+
const version = '4.2.54';
|
|
307464
307619
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
307465
307620
|
//-----------------------------------------------------------------------------
|
|
307466
307621
|
|