ccxt 4.3.73 → 4.3.75
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 +5 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +1 -1
- package/dist/cjs/src/binance.js +236 -87
- package/dist/cjs/src/bybit.js +42 -7
- package/dist/cjs/src/mexc.js +1 -1
- package/dist/cjs/src/pro/alpaca.js +5 -0
- package/dist/cjs/src/pro/binance.js +15 -2
- package/dist/cjs/src/pro/bitfinex.js +5 -0
- package/dist/cjs/src/whitebit.js +17 -2
- package/dist/cjs/src/woo.js +1 -1
- package/dist/cjs/src/yobit.js +55 -29
- package/examples/js/cli.js +13 -10
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +5 -0
- package/js/src/abstract/binancecoinm.d.ts +5 -0
- package/js/src/abstract/binanceus.d.ts +5 -0
- package/js/src/abstract/binanceusdm.d.ts +5 -0
- package/js/src/abstract/bybit.d.ts +1 -0
- package/js/src/ace.js +1 -1
- package/js/src/binance.js +236 -87
- package/js/src/bybit.js +42 -7
- package/js/src/mexc.js +1 -1
- package/js/src/pro/alpaca.js +5 -0
- package/js/src/pro/binance.js +15 -2
- package/js/src/pro/bitfinex.js +5 -0
- package/js/src/whitebit.js +17 -2
- package/js/src/woo.js +1 -1
- package/js/src/yobit.d.ts +1 -0
- package/js/src/yobit.js +55 -29
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
194
194
|
|
|
195
195
|
//-----------------------------------------------------------------------------
|
|
196
196
|
// this is updated by vss.js when building
|
|
197
|
-
const version = '4.3.
|
|
197
|
+
const version = '4.3.75';
|
|
198
198
|
Exchange["default"].ccxtVersion = version;
|
|
199
199
|
const exchanges = {
|
|
200
200
|
'ace': ace,
|
package/dist/cjs/src/ace.js
CHANGED
|
@@ -352,7 +352,7 @@ class ace extends ace$1 {
|
|
|
352
352
|
for (let i = 0; i < pairs.length; i++) {
|
|
353
353
|
const marketId = pairs[i];
|
|
354
354
|
const market = this.safeMarket(marketId);
|
|
355
|
-
const rawTicker = this.safeDict(response, marketId);
|
|
355
|
+
const rawTicker = this.safeDict(response, marketId, {});
|
|
356
356
|
const ticker = this.parseTicker(rawTicker, market);
|
|
357
357
|
tickers.push(ticker);
|
|
358
358
|
}
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -189,8 +189,10 @@ class binance extends binance$1 {
|
|
|
189
189
|
'dapiPrivateV2': 'https://testnet.binancefuture.com/dapi/v2',
|
|
190
190
|
'fapiPublic': 'https://testnet.binancefuture.com/fapi/v1',
|
|
191
191
|
'fapiPublicV2': 'https://testnet.binancefuture.com/fapi/v2',
|
|
192
|
+
'fapiPublicV3': 'https://testnet.binancefuture.com/fapi/v3',
|
|
192
193
|
'fapiPrivate': 'https://testnet.binancefuture.com/fapi/v1',
|
|
193
194
|
'fapiPrivateV2': 'https://testnet.binancefuture.com/fapi/v2',
|
|
195
|
+
'fapiPrivateV3': 'https://testnet.binancefuture.com/fapi/v3',
|
|
194
196
|
'public': 'https://testnet.binance.vision/api/v3',
|
|
195
197
|
'private': 'https://testnet.binance.vision/api/v3',
|
|
196
198
|
'v1': 'https://testnet.binance.vision/api/v1',
|
|
@@ -208,9 +210,11 @@ class binance extends binance$1 {
|
|
|
208
210
|
'dapiData': 'https://dapi.binance.com/futures/data',
|
|
209
211
|
'fapiPublic': 'https://fapi.binance.com/fapi/v1',
|
|
210
212
|
'fapiPublicV2': 'https://fapi.binance.com/fapi/v2',
|
|
213
|
+
'fapiPublicV3': 'https://fapi.binance.com/fapi/v3',
|
|
211
214
|
'fapiPrivate': 'https://fapi.binance.com/fapi/v1',
|
|
212
|
-
'fapiData': 'https://fapi.binance.com/futures/data',
|
|
213
215
|
'fapiPrivateV2': 'https://fapi.binance.com/fapi/v2',
|
|
216
|
+
'fapiPrivateV3': 'https://fapi.binance.com/fapi/v3',
|
|
217
|
+
'fapiData': 'https://fapi.binance.com/futures/data',
|
|
214
218
|
'public': 'https://api.binance.com/api/v3',
|
|
215
219
|
'private': 'https://api.binance.com/api/v3',
|
|
216
220
|
'v1': 'https://api.binance.com/api/v1',
|
|
@@ -846,6 +850,8 @@ class binance extends binance$1 {
|
|
|
846
850
|
'trade/asyn': 1000,
|
|
847
851
|
'trade/asyn/id': 10,
|
|
848
852
|
'feeBurn': 1,
|
|
853
|
+
'symbolConfig': 5,
|
|
854
|
+
'accountConfig': 5,
|
|
849
855
|
},
|
|
850
856
|
'post': {
|
|
851
857
|
'batchOrders': 5,
|
|
@@ -886,6 +892,16 @@ class binance extends binance$1 {
|
|
|
886
892
|
'positionRisk': 1,
|
|
887
893
|
},
|
|
888
894
|
},
|
|
895
|
+
'fapiPublicV3': {
|
|
896
|
+
'get': {},
|
|
897
|
+
},
|
|
898
|
+
'fapiPrivateV3': {
|
|
899
|
+
'get': {
|
|
900
|
+
'account': 1,
|
|
901
|
+
'balance': 1,
|
|
902
|
+
'positionRisk': 1,
|
|
903
|
+
},
|
|
904
|
+
},
|
|
889
905
|
'eapiPublic': {
|
|
890
906
|
'get': {
|
|
891
907
|
'ping': 1,
|
|
@@ -3417,7 +3433,7 @@ class binance extends binance$1 {
|
|
|
3417
3433
|
}
|
|
3418
3434
|
else if (this.isLinear(type, subType)) {
|
|
3419
3435
|
type = 'linear';
|
|
3420
|
-
response = await this.
|
|
3436
|
+
response = await this.fapiPrivateV3GetAccount(this.extend(request, query));
|
|
3421
3437
|
}
|
|
3422
3438
|
else if (this.isInverse(type, subType)) {
|
|
3423
3439
|
type = 'inverse';
|
|
@@ -9426,24 +9442,29 @@ class binance extends binance$1 {
|
|
|
9426
9442
|
//
|
|
9427
9443
|
// usdm
|
|
9428
9444
|
//
|
|
9445
|
+
// v3 (similar for cross & isolated)
|
|
9446
|
+
//
|
|
9429
9447
|
// {
|
|
9430
|
-
//
|
|
9431
|
-
//
|
|
9432
|
-
//
|
|
9433
|
-
//
|
|
9434
|
-
//
|
|
9435
|
-
//
|
|
9436
|
-
//
|
|
9437
|
-
//
|
|
9438
|
-
//
|
|
9439
|
-
//
|
|
9440
|
-
//
|
|
9441
|
-
//
|
|
9442
|
-
//
|
|
9443
|
-
//
|
|
9444
|
-
//
|
|
9445
|
-
//
|
|
9446
|
-
//
|
|
9448
|
+
// "symbol": "WLDUSDT",
|
|
9449
|
+
// "positionSide": "BOTH",
|
|
9450
|
+
// "positionAmt": "-849",
|
|
9451
|
+
// "unrealizedProfit": "11.17920750",
|
|
9452
|
+
// "notional": "-1992.46079250",
|
|
9453
|
+
// "isolatedMargin": "0",
|
|
9454
|
+
// "isolatedWallet": "0",
|
|
9455
|
+
// "initialMargin": "99.62303962",
|
|
9456
|
+
// "maintMargin": "11.95476475",
|
|
9457
|
+
// "updateTime": "1721995760449"
|
|
9458
|
+
// "leverage": "50", // in v2
|
|
9459
|
+
// "entryPrice": "2.34", // in v2
|
|
9460
|
+
// "positionInitialMargin": "118.82116614", // in v2
|
|
9461
|
+
// "openOrderInitialMargin": "0", // in v2
|
|
9462
|
+
// "isolated": false, // in v2
|
|
9463
|
+
// "breakEvenPrice": "2.3395788", // in v2
|
|
9464
|
+
// "maxNotional": "25000", // in v2
|
|
9465
|
+
// "bidNotional": "0", // in v2
|
|
9466
|
+
// "askNotional": "0" // in v2
|
|
9467
|
+
// }
|
|
9447
9468
|
//
|
|
9448
9469
|
// coinm
|
|
9449
9470
|
//
|
|
@@ -9509,13 +9530,16 @@ class binance extends binance$1 {
|
|
|
9509
9530
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
9510
9531
|
const symbol = this.safeString(market, 'symbol');
|
|
9511
9532
|
const leverageString = this.safeString(position, 'leverage');
|
|
9512
|
-
const leverage = parseInt(leverageString);
|
|
9533
|
+
const leverage = (leverageString !== undefined) ? parseInt(leverageString) : undefined;
|
|
9513
9534
|
const initialMarginString = this.safeString(position, 'initialMargin');
|
|
9514
9535
|
const initialMargin = this.parseNumber(initialMarginString);
|
|
9515
|
-
let initialMarginPercentageString =
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9536
|
+
let initialMarginPercentageString = undefined;
|
|
9537
|
+
if (leverageString !== undefined) {
|
|
9538
|
+
initialMarginPercentageString = Precise["default"].stringDiv('1', leverageString, 8);
|
|
9539
|
+
const rational = this.isRoundNumber(1000 % leverage);
|
|
9540
|
+
if (!rational) {
|
|
9541
|
+
initialMarginPercentageString = Precise["default"].stringDiv(Precise["default"].stringAdd(initialMarginPercentageString, '1e-8'), '1', 8);
|
|
9542
|
+
}
|
|
9519
9543
|
}
|
|
9520
9544
|
// as oppose to notionalValue
|
|
9521
9545
|
const usdm = ('notional' in position);
|
|
@@ -9552,7 +9576,11 @@ class binance extends binance$1 {
|
|
|
9552
9576
|
if (timestamp === 0) {
|
|
9553
9577
|
timestamp = undefined;
|
|
9554
9578
|
}
|
|
9555
|
-
|
|
9579
|
+
let isolated = this.safeBool(position, 'isolated');
|
|
9580
|
+
if (isolated === undefined) {
|
|
9581
|
+
const isolatedMarginRaw = this.safeString(position, 'isolatedMargin');
|
|
9582
|
+
isolated = !Precise["default"].stringEq(isolatedMarginRaw, '0');
|
|
9583
|
+
}
|
|
9556
9584
|
let marginMode = undefined;
|
|
9557
9585
|
let collateralString = undefined;
|
|
9558
9586
|
let walletBalance = undefined;
|
|
@@ -9668,23 +9696,34 @@ class binance extends binance$1 {
|
|
|
9668
9696
|
//
|
|
9669
9697
|
// usdm
|
|
9670
9698
|
//
|
|
9671
|
-
//
|
|
9672
|
-
//
|
|
9673
|
-
//
|
|
9674
|
-
//
|
|
9675
|
-
//
|
|
9676
|
-
//
|
|
9677
|
-
//
|
|
9678
|
-
//
|
|
9679
|
-
//
|
|
9680
|
-
//
|
|
9681
|
-
//
|
|
9682
|
-
//
|
|
9683
|
-
//
|
|
9684
|
-
//
|
|
9685
|
-
//
|
|
9686
|
-
//
|
|
9687
|
-
//
|
|
9699
|
+
// {
|
|
9700
|
+
// symbol: "WLDUSDT",
|
|
9701
|
+
// positionSide: "BOTH",
|
|
9702
|
+
// positionAmt: "5",
|
|
9703
|
+
// entryPrice: "2.3483",
|
|
9704
|
+
// breakEvenPrice: "2.349356735",
|
|
9705
|
+
// markPrice: "2.39560000",
|
|
9706
|
+
// unRealizedProfit: "0.23650000",
|
|
9707
|
+
// liquidationPrice: "0",
|
|
9708
|
+
// isolatedMargin: "0",
|
|
9709
|
+
// notional: "11.97800000",
|
|
9710
|
+
// isolatedWallet: "0",
|
|
9711
|
+
// updateTime: "1722062678998",
|
|
9712
|
+
// initialMargin: "2.39560000", // not in v2
|
|
9713
|
+
// maintMargin: "0.07186800", // not in v2
|
|
9714
|
+
// positionInitialMargin: "2.39560000", // not in v2
|
|
9715
|
+
// openOrderInitialMargin: "0", // not in v2
|
|
9716
|
+
// adl: "2", // not in v2
|
|
9717
|
+
// bidNotional: "0", // not in v2
|
|
9718
|
+
// askNotional: "0", // not in v2
|
|
9719
|
+
// marginAsset: "USDT", // not in v2
|
|
9720
|
+
// // the below fields are only in v2
|
|
9721
|
+
// leverage: "5",
|
|
9722
|
+
// maxNotionalValue: "6000000",
|
|
9723
|
+
// marginType: "cross",
|
|
9724
|
+
// isAutoAddMargin: "false",
|
|
9725
|
+
// isolated: false,
|
|
9726
|
+
// adlQuantile: "2",
|
|
9688
9727
|
//
|
|
9689
9728
|
// coinm
|
|
9690
9729
|
//
|
|
@@ -9742,6 +9781,7 @@ class binance extends binance$1 {
|
|
|
9742
9781
|
const marketId = this.safeString(position, 'symbol');
|
|
9743
9782
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
9744
9783
|
const symbol = this.safeString(market, 'symbol');
|
|
9784
|
+
const isolatedMarginString = this.safeString(position, 'isolatedMargin');
|
|
9745
9785
|
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
|
|
9746
9786
|
const leverageBracket = this.safeList(leverageBrackets, symbol, []);
|
|
9747
9787
|
const notionalString = this.safeString2(position, 'notional', 'notionalValue');
|
|
@@ -9759,12 +9799,13 @@ class binance extends binance$1 {
|
|
|
9759
9799
|
const contracts = this.parseNumber(contractsAbs);
|
|
9760
9800
|
const unrealizedPnlString = this.safeString(position, 'unRealizedProfit');
|
|
9761
9801
|
const unrealizedPnl = this.parseNumber(unrealizedPnlString);
|
|
9762
|
-
const leverageString = this.safeString(position, 'leverage');
|
|
9763
|
-
const leverage = parseInt(leverageString);
|
|
9764
9802
|
const liquidationPriceString = this.omitZero(this.safeString(position, 'liquidationPrice'));
|
|
9765
9803
|
const liquidationPrice = this.parseNumber(liquidationPriceString);
|
|
9766
9804
|
let collateralString = undefined;
|
|
9767
|
-
|
|
9805
|
+
let marginMode = this.safeString(position, 'marginType');
|
|
9806
|
+
if (marginMode === undefined && isolatedMarginString !== undefined) {
|
|
9807
|
+
marginMode = Precise["default"].stringEq(isolatedMarginString, '0') ? 'cross' : 'isolated';
|
|
9808
|
+
}
|
|
9768
9809
|
let side = undefined;
|
|
9769
9810
|
if (Precise["default"].stringGt(notionalString, '0')) {
|
|
9770
9811
|
side = 'long';
|
|
@@ -9834,15 +9875,30 @@ class binance extends binance$1 {
|
|
|
9834
9875
|
timestamp = undefined;
|
|
9835
9876
|
}
|
|
9836
9877
|
const maintenanceMarginPercentage = this.parseNumber(maintenanceMarginPercentageString);
|
|
9837
|
-
|
|
9878
|
+
let maintenanceMarginString = Precise["default"].stringMul(maintenanceMarginPercentageString, notionalStringAbs);
|
|
9879
|
+
if (maintenanceMarginString === undefined) {
|
|
9880
|
+
// for a while, this new value was a backup to the existing calculations, but in future we might prioritize this
|
|
9881
|
+
maintenanceMarginString = this.safeString(position, 'maintMargin');
|
|
9882
|
+
}
|
|
9838
9883
|
const maintenanceMargin = this.parseNumber(maintenanceMarginString);
|
|
9839
|
-
let
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9884
|
+
let initialMarginString = undefined;
|
|
9885
|
+
let initialMarginPercentageString = undefined;
|
|
9886
|
+
const leverageString = this.safeString(position, 'leverage');
|
|
9887
|
+
if (leverageString !== undefined) {
|
|
9888
|
+
const leverage = parseInt(leverageString);
|
|
9889
|
+
const rational = this.isRoundNumber(1000 % leverage);
|
|
9890
|
+
initialMarginPercentageString = Precise["default"].stringDiv('1', leverageString, 8);
|
|
9891
|
+
if (!rational) {
|
|
9892
|
+
initialMarginPercentageString = Precise["default"].stringAdd(initialMarginPercentageString, '1e-8');
|
|
9893
|
+
}
|
|
9894
|
+
const unrounded = Precise["default"].stringMul(notionalStringAbs, initialMarginPercentageString);
|
|
9895
|
+
initialMarginString = Precise["default"].stringDiv(unrounded, '1', 8);
|
|
9896
|
+
}
|
|
9897
|
+
else {
|
|
9898
|
+
initialMarginString = this.safeString(position, 'initialMargin');
|
|
9899
|
+
const unrounded = Precise["default"].stringMul(initialMarginString, '1');
|
|
9900
|
+
initialMarginPercentageString = Precise["default"].stringDiv(unrounded, notionalStringAbs, 8);
|
|
9843
9901
|
}
|
|
9844
|
-
const initialMarginString = Precise["default"].stringDiv(Precise["default"].stringMul(notionalStringAbs, initialMarginPercentageString), '1', 8);
|
|
9845
|
-
const initialMargin = this.parseNumber(initialMarginString);
|
|
9846
9902
|
let marginRatio = undefined;
|
|
9847
9903
|
let percentage = undefined;
|
|
9848
9904
|
if (!Precise["default"].stringEquals(collateralString, '0')) {
|
|
@@ -9865,7 +9921,7 @@ class binance extends binance$1 {
|
|
|
9865
9921
|
'markPrice': markPrice,
|
|
9866
9922
|
'entryPrice': entryPrice,
|
|
9867
9923
|
'timestamp': timestamp,
|
|
9868
|
-
'initialMargin':
|
|
9924
|
+
'initialMargin': this.parseNumber(initialMarginString),
|
|
9869
9925
|
'initialMarginPercentage': this.parseNumber(initialMarginPercentageString),
|
|
9870
9926
|
'maintenanceMargin': maintenanceMargin,
|
|
9871
9927
|
'maintenanceMarginPercentage': maintenanceMarginPercentage,
|
|
@@ -10229,9 +10285,17 @@ class binance extends binance$1 {
|
|
|
10229
10285
|
* @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
10230
10286
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
10231
10287
|
*/
|
|
10232
|
-
const defaultValue = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
10233
10288
|
let defaultMethod = undefined;
|
|
10234
|
-
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method'
|
|
10289
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method');
|
|
10290
|
+
if (defaultMethod === undefined) {
|
|
10291
|
+
const options = this.safeDict(this.options, 'fetchPositions');
|
|
10292
|
+
if (options === undefined) {
|
|
10293
|
+
defaultMethod = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
10294
|
+
}
|
|
10295
|
+
else {
|
|
10296
|
+
defaultMethod = 'positionRisk';
|
|
10297
|
+
}
|
|
10298
|
+
}
|
|
10235
10299
|
if (defaultMethod === 'positionRisk') {
|
|
10236
10300
|
return await this.fetchPositionsRisk(symbols, params);
|
|
10237
10301
|
}
|
|
@@ -10242,7 +10306,7 @@ class binance extends binance$1 {
|
|
|
10242
10306
|
return await this.fetchOptionPositions(symbols, params);
|
|
10243
10307
|
}
|
|
10244
10308
|
else {
|
|
10245
|
-
throw new errors.NotSupported(this.id + '.options["fetchPositions"]
|
|
10309
|
+
throw new errors.NotSupported(this.id + '.options["fetchPositions"]["method"] or params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
10246
10310
|
}
|
|
10247
10311
|
}
|
|
10248
10312
|
async fetchAccountPositions(symbols = undefined, params = {}) {
|
|
@@ -10260,6 +10324,7 @@ class binance extends binance$1 {
|
|
|
10260
10324
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
|
10261
10325
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
10262
10326
|
* @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
|
|
10327
|
+
* @param {boolean} [params.useV2] set to true if you want to use obsolete endpoint, where some more additional fields were provided
|
|
10263
10328
|
* @returns {object} data on account positions
|
|
10264
10329
|
*/
|
|
10265
10330
|
if (symbols !== undefined) {
|
|
@@ -10282,7 +10347,80 @@ class binance extends binance$1 {
|
|
|
10282
10347
|
response = await this.papiGetUmAccount(params);
|
|
10283
10348
|
}
|
|
10284
10349
|
else {
|
|
10285
|
-
|
|
10350
|
+
let useV2 = undefined;
|
|
10351
|
+
[useV2, params] = this.handleOptionAndParams(params, 'fetchAccountPositions', 'useV2', false);
|
|
10352
|
+
if (!useV2) {
|
|
10353
|
+
response = await this.fapiPrivateV3GetAccount(params);
|
|
10354
|
+
}
|
|
10355
|
+
else {
|
|
10356
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
10357
|
+
}
|
|
10358
|
+
//
|
|
10359
|
+
// {
|
|
10360
|
+
// "totalInitialMargin": "99.62112386",
|
|
10361
|
+
// "totalMaintMargin": "11.95453485",
|
|
10362
|
+
// "totalWalletBalance": "99.84331553",
|
|
10363
|
+
// "totalUnrealizedProfit": "11.17675690",
|
|
10364
|
+
// "totalMarginBalance": "111.02007243",
|
|
10365
|
+
// "totalPositionInitialMargin": "99.62112386",
|
|
10366
|
+
// "totalOpenOrderInitialMargin": "0.00000000",
|
|
10367
|
+
// "totalCrossWalletBalance": "99.84331553",
|
|
10368
|
+
// "totalCrossUnPnl": "11.17675690",
|
|
10369
|
+
// "availableBalance": "11.39894857",
|
|
10370
|
+
// "maxWithdrawAmount": "11.39894857",
|
|
10371
|
+
// "feeTier": "0", // in v2
|
|
10372
|
+
// "canTrade": true, // in v2
|
|
10373
|
+
// "canDeposit": true, // in v2
|
|
10374
|
+
// "canWithdraw": true, // in v2
|
|
10375
|
+
// "feeBurn": true, // in v2
|
|
10376
|
+
// "tradeGroupId": "-1",// in v2
|
|
10377
|
+
// "updateTime": "0", // in v2
|
|
10378
|
+
// "multiAssetsMargin": true // in v2
|
|
10379
|
+
// "assets": [
|
|
10380
|
+
// {
|
|
10381
|
+
// "asset": "USDT",
|
|
10382
|
+
// "walletBalance": "72.72317863",
|
|
10383
|
+
// "unrealizedProfit": "11.17920750",
|
|
10384
|
+
// "marginBalance": "83.90238613",
|
|
10385
|
+
// "maintMargin": "11.95476475",
|
|
10386
|
+
// "initialMargin": "99.62303962",
|
|
10387
|
+
// "positionInitialMargin": "99.62303962",
|
|
10388
|
+
// "openOrderInitialMargin": "0.00000000",
|
|
10389
|
+
// "crossWalletBalance": "72.72317863",
|
|
10390
|
+
// "crossUnPnl": "11.17920750",
|
|
10391
|
+
// "availableBalance": "11.39916777",
|
|
10392
|
+
// "maxWithdrawAmount": "11.39916777",
|
|
10393
|
+
// "updateTime": "1721995605338",
|
|
10394
|
+
// "marginAvailable": true // in v2
|
|
10395
|
+
// },
|
|
10396
|
+
// ... and some few supported settle currencies: USDC, BTC, ETH, BNB ..
|
|
10397
|
+
// ],
|
|
10398
|
+
// "positions": [
|
|
10399
|
+
// {
|
|
10400
|
+
// "symbol": "WLDUSDT",
|
|
10401
|
+
// "positionSide": "BOTH",
|
|
10402
|
+
// "positionAmt": "-849",
|
|
10403
|
+
// "unrealizedProfit": "11.17920750",
|
|
10404
|
+
// "isolatedMargin": "0",
|
|
10405
|
+
// "isolatedWallet": "0",
|
|
10406
|
+
// "notional": "-1992.46079250",
|
|
10407
|
+
// "initialMargin": "99.62303962",
|
|
10408
|
+
// "maintMargin": "11.95476475",
|
|
10409
|
+
// "updateTime": "1721995760449"
|
|
10410
|
+
// "leverage": "50", // in v2
|
|
10411
|
+
// "entryPrice": "2.34", // in v2
|
|
10412
|
+
// "positionInitialMargin": "118.82116614", // in v2
|
|
10413
|
+
// "openOrderInitialMargin": "0", // in v2
|
|
10414
|
+
// "isolated": false, // in v2
|
|
10415
|
+
// "breakEvenPrice": "2.3395788", // in v2
|
|
10416
|
+
// "maxNotional": "25000", // in v2
|
|
10417
|
+
// "bidNotional": "0", // in v2
|
|
10418
|
+
// "askNotional": "0" // in v2
|
|
10419
|
+
// },
|
|
10420
|
+
// ...
|
|
10421
|
+
// ]
|
|
10422
|
+
// }
|
|
10423
|
+
//
|
|
10286
10424
|
}
|
|
10287
10425
|
}
|
|
10288
10426
|
else if (this.isInverse(type, subType)) {
|
|
@@ -10340,7 +10478,33 @@ class binance extends binance$1 {
|
|
|
10340
10478
|
response = await this.papiGetUmPositionRisk(this.extend(request, params));
|
|
10341
10479
|
}
|
|
10342
10480
|
else {
|
|
10343
|
-
response = await this.
|
|
10481
|
+
response = await this.fapiPrivateV3GetPositionRisk(this.extend(request, params));
|
|
10482
|
+
//
|
|
10483
|
+
// [
|
|
10484
|
+
// {
|
|
10485
|
+
// symbol: "WLDUSDT",
|
|
10486
|
+
// positionSide: "BOTH",
|
|
10487
|
+
// positionAmt: "5",
|
|
10488
|
+
// entryPrice: "2.3483",
|
|
10489
|
+
// breakEvenPrice: "2.349356735",
|
|
10490
|
+
// markPrice: "2.39560000",
|
|
10491
|
+
// unRealizedProfit: "0.23650000",
|
|
10492
|
+
// liquidationPrice: "0",
|
|
10493
|
+
// isolatedMargin: "0",
|
|
10494
|
+
// notional: "11.97800000",
|
|
10495
|
+
// isolatedWallet: "0",
|
|
10496
|
+
// updateTime: "1722062678998",
|
|
10497
|
+
// initialMargin: "2.39560000", // added in v3
|
|
10498
|
+
// maintMargin: "0.07186800", // added in v3
|
|
10499
|
+
// positionInitialMargin: "2.39560000", // added in v3
|
|
10500
|
+
// openOrderInitialMargin: "0", // added in v3
|
|
10501
|
+
// adl: "2", // added in v3
|
|
10502
|
+
// bidNotional: "0", // added in v3
|
|
10503
|
+
// askNotional: "0", // added in v3
|
|
10504
|
+
// marginAsset: "USDT", // added in v3
|
|
10505
|
+
// },
|
|
10506
|
+
// ]
|
|
10507
|
+
//
|
|
10344
10508
|
}
|
|
10345
10509
|
}
|
|
10346
10510
|
else if (this.isInverse(type, subType)) {
|
|
@@ -10360,18 +10524,18 @@ class binance extends binance$1 {
|
|
|
10360
10524
|
//
|
|
10361
10525
|
// [
|
|
10362
10526
|
// {
|
|
10527
|
+
// "symbol": "BTCUSDT",
|
|
10528
|
+
// "positionSide": "BOTH",
|
|
10529
|
+
// "positionAmt": "0.000",
|
|
10363
10530
|
// "entryPrice": "0.00000",
|
|
10531
|
+
// "markPrice": "6679.50671178",
|
|
10532
|
+
// "unRealizedProfit": "0.00000000",
|
|
10533
|
+
// "liquidationPrice": "0",
|
|
10534
|
+
// "isolatedMargin": "0.00000000",
|
|
10364
10535
|
// "marginType": "isolated",
|
|
10365
10536
|
// "isAutoAddMargin": "false",
|
|
10366
|
-
// "isolatedMargin": "0.00000000",
|
|
10367
10537
|
// "leverage": "10",
|
|
10368
|
-
// "liquidationPrice": "0",
|
|
10369
|
-
// "markPrice": "6679.50671178",
|
|
10370
10538
|
// "maxNotionalValue": "20000000",
|
|
10371
|
-
// "positionAmt": "0.000",
|
|
10372
|
-
// "symbol": "BTCUSDT",
|
|
10373
|
-
// "unRealizedProfit": "0.00000000",
|
|
10374
|
-
// "positionSide": "BOTH",
|
|
10375
10539
|
// "updateTime": 0
|
|
10376
10540
|
// }
|
|
10377
10541
|
// ]
|
|
@@ -10388,27 +10552,13 @@ class binance extends binance$1 {
|
|
|
10388
10552
|
// "liquidationPrice": "5930.78",
|
|
10389
10553
|
// "markPrice": "6679.50671178",
|
|
10390
10554
|
// "maxNotionalValue": "20000000",
|
|
10391
|
-
// "
|
|
10555
|
+
// "positionSide": "LONG",
|
|
10556
|
+
// "positionAmt": "20.000", // negative value for 'SHORT'
|
|
10392
10557
|
// "symbol": "BTCUSDT",
|
|
10393
10558
|
// "unRealizedProfit": "2316.83423560"
|
|
10394
|
-
// "positionSide": "LONG",
|
|
10395
10559
|
// "updateTime": 1625474304765
|
|
10396
10560
|
// },
|
|
10397
|
-
//
|
|
10398
|
-
// "entryPrice": "0.00000",
|
|
10399
|
-
// "marginType": "isolated",
|
|
10400
|
-
// "isAutoAddMargin": "false",
|
|
10401
|
-
// "isolatedMargin": "5413.95799991",
|
|
10402
|
-
// "leverage": "10",
|
|
10403
|
-
// "liquidationPrice": "7189.95",
|
|
10404
|
-
// "markPrice": "6679.50671178",
|
|
10405
|
-
// "maxNotionalValue": "20000000",
|
|
10406
|
-
// "positionAmt": "-10.000",
|
|
10407
|
-
// "symbol": "BTCUSDT",
|
|
10408
|
-
// "unRealizedProfit": "-1156.46711780",
|
|
10409
|
-
// "positionSide": "SHORT",
|
|
10410
|
-
// "updateTime": 0
|
|
10411
|
-
// }
|
|
10561
|
+
// .. second dict is similar, but with `positionSide: SHORT`
|
|
10412
10562
|
// ]
|
|
10413
10563
|
//
|
|
10414
10564
|
// inverse portfolio margin:
|
|
@@ -10452,10 +10602,9 @@ class binance extends binance$1 {
|
|
|
10452
10602
|
const result = [];
|
|
10453
10603
|
for (let i = 0; i < response.length; i++) {
|
|
10454
10604
|
const rawPosition = response[i];
|
|
10455
|
-
const
|
|
10456
|
-
if (
|
|
10457
|
-
|
|
10458
|
-
result.push(parsed);
|
|
10605
|
+
const entryPriceString = this.safeString(rawPosition, 'entryPrice');
|
|
10606
|
+
if (Precise["default"].stringGt(entryPriceString, '0')) {
|
|
10607
|
+
result.push(this.parsePositionRisk(response[i]));
|
|
10459
10608
|
}
|
|
10460
10609
|
}
|
|
10461
10610
|
symbols = this.marketSymbols(symbols);
|
|
@@ -11193,7 +11342,7 @@ class binance extends binance$1 {
|
|
|
11193
11342
|
throw new errors.AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
|
|
11194
11343
|
}
|
|
11195
11344
|
}
|
|
11196
|
-
else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi' && path !== 'ping')) {
|
|
11345
|
+
else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'fapiPrivateV3') || (api === 'papi' && path !== 'ping')) {
|
|
11197
11346
|
this.checkRequiredCredentials();
|
|
11198
11347
|
if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
|
|
11199
11348
|
// inject in implicit API calls
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -240,6 +240,7 @@ class bybit extends bybit$1 {
|
|
|
240
240
|
},
|
|
241
241
|
'private': {
|
|
242
242
|
'get': {
|
|
243
|
+
'v5/market/instruments-info': 5,
|
|
243
244
|
// Legacy inverse swap
|
|
244
245
|
'v2/private/wallet/fund/records': 25,
|
|
245
246
|
// spot
|
|
@@ -985,6 +986,7 @@ class bybit extends bybit$1 {
|
|
|
985
986
|
},
|
|
986
987
|
'precisionMode': number.TICK_SIZE,
|
|
987
988
|
'options': {
|
|
989
|
+
'usePrivateInstrumentsInfo': false,
|
|
988
990
|
'sandboxMode': false,
|
|
989
991
|
'enableDemoTrading': false,
|
|
990
992
|
'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
|
|
@@ -1479,7 +1481,14 @@ class bybit extends bybit$1 {
|
|
|
1479
1481
|
const request = {
|
|
1480
1482
|
'category': 'spot',
|
|
1481
1483
|
};
|
|
1482
|
-
const
|
|
1484
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1485
|
+
let response = undefined;
|
|
1486
|
+
if (usePrivateInstrumentsInfo) {
|
|
1487
|
+
response = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1488
|
+
}
|
|
1489
|
+
else {
|
|
1490
|
+
response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1491
|
+
}
|
|
1483
1492
|
//
|
|
1484
1493
|
// {
|
|
1485
1494
|
// "retCode": 0,
|
|
@@ -1589,14 +1598,27 @@ class bybit extends bybit$1 {
|
|
|
1589
1598
|
async fetchFutureMarkets(params) {
|
|
1590
1599
|
params = this.extend(params);
|
|
1591
1600
|
params['limit'] = 1000; // minimize number of requests
|
|
1592
|
-
const
|
|
1601
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1602
|
+
let response = undefined;
|
|
1603
|
+
if (usePrivateInstrumentsInfo) {
|
|
1604
|
+
response = await this.privateGetV5MarketInstrumentsInfo(params);
|
|
1605
|
+
}
|
|
1606
|
+
else {
|
|
1607
|
+
response = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1608
|
+
}
|
|
1593
1609
|
const data = this.safeDict(response, 'result', {});
|
|
1594
1610
|
let markets = this.safeList(data, 'list', []);
|
|
1595
1611
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
1596
1612
|
if (paginationCursor !== undefined) {
|
|
1597
1613
|
while (paginationCursor !== undefined) {
|
|
1598
1614
|
params['cursor'] = paginationCursor;
|
|
1599
|
-
|
|
1615
|
+
let responseInner = undefined;
|
|
1616
|
+
if (usePrivateInstrumentsInfo) {
|
|
1617
|
+
responseInner = await this.privateGetV5MarketInstrumentsInfo(params);
|
|
1618
|
+
}
|
|
1619
|
+
else {
|
|
1620
|
+
responseInner = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1621
|
+
}
|
|
1600
1622
|
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1601
1623
|
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1602
1624
|
const rawMarketsLength = rawMarkets.length;
|
|
@@ -1765,7 +1787,14 @@ class bybit extends bybit$1 {
|
|
|
1765
1787
|
const request = {
|
|
1766
1788
|
'category': 'option',
|
|
1767
1789
|
};
|
|
1768
|
-
const
|
|
1790
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1791
|
+
let response = undefined;
|
|
1792
|
+
if (usePrivateInstrumentsInfo) {
|
|
1793
|
+
response = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1794
|
+
}
|
|
1795
|
+
else {
|
|
1796
|
+
response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1797
|
+
}
|
|
1769
1798
|
const data = this.safeDict(response, 'result', {});
|
|
1770
1799
|
let markets = this.safeList(data, 'list', []);
|
|
1771
1800
|
if (this.options['loadAllOptions']) {
|
|
@@ -1774,7 +1803,13 @@ class bybit extends bybit$1 {
|
|
|
1774
1803
|
if (paginationCursor !== undefined) {
|
|
1775
1804
|
while (paginationCursor !== undefined) {
|
|
1776
1805
|
request['cursor'] = paginationCursor;
|
|
1777
|
-
|
|
1806
|
+
let responseInner = undefined;
|
|
1807
|
+
if (usePrivateInstrumentsInfo) {
|
|
1808
|
+
responseInner = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1809
|
+
}
|
|
1810
|
+
else {
|
|
1811
|
+
responseInner = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1812
|
+
}
|
|
1778
1813
|
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1779
1814
|
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1780
1815
|
const rawMarketsLength = rawMarkets.length;
|
|
@@ -7264,8 +7299,8 @@ class bybit extends bybit$1 {
|
|
|
7264
7299
|
let currency = undefined;
|
|
7265
7300
|
let request = {};
|
|
7266
7301
|
if (code !== undefined) {
|
|
7267
|
-
currency = this.
|
|
7268
|
-
request['coin'] = currency;
|
|
7302
|
+
currency = this.safeCurrency(code);
|
|
7303
|
+
request['coin'] = currency['id'];
|
|
7269
7304
|
}
|
|
7270
7305
|
if (since !== undefined) {
|
|
7271
7306
|
request['startTime'] = since;
|
package/dist/cjs/src/mexc.js
CHANGED
|
@@ -5235,7 +5235,7 @@ class mexc extends mexc$1 {
|
|
|
5235
5235
|
const networks = this.safeDict(this.options, 'networks', {});
|
|
5236
5236
|
let network = this.safeString2(params, 'network', 'netWork'); // this line allows the user to specify either ERC20 or ETH
|
|
5237
5237
|
network = this.safeString(networks, network, network); // handle ETH > ERC-20 alias
|
|
5238
|
-
network = this.
|
|
5238
|
+
network = this.networkIdToCode(network);
|
|
5239
5239
|
this.checkAddress(address);
|
|
5240
5240
|
await this.loadMarkets();
|
|
5241
5241
|
const currency = this.currency(code);
|