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/js/src/binance.js
CHANGED
|
@@ -192,8 +192,10 @@ export default class binance extends Exchange {
|
|
|
192
192
|
'dapiPrivateV2': 'https://testnet.binancefuture.com/dapi/v2',
|
|
193
193
|
'fapiPublic': 'https://testnet.binancefuture.com/fapi/v1',
|
|
194
194
|
'fapiPublicV2': 'https://testnet.binancefuture.com/fapi/v2',
|
|
195
|
+
'fapiPublicV3': 'https://testnet.binancefuture.com/fapi/v3',
|
|
195
196
|
'fapiPrivate': 'https://testnet.binancefuture.com/fapi/v1',
|
|
196
197
|
'fapiPrivateV2': 'https://testnet.binancefuture.com/fapi/v2',
|
|
198
|
+
'fapiPrivateV3': 'https://testnet.binancefuture.com/fapi/v3',
|
|
197
199
|
'public': 'https://testnet.binance.vision/api/v3',
|
|
198
200
|
'private': 'https://testnet.binance.vision/api/v3',
|
|
199
201
|
'v1': 'https://testnet.binance.vision/api/v1',
|
|
@@ -211,9 +213,11 @@ export default class binance extends Exchange {
|
|
|
211
213
|
'dapiData': 'https://dapi.binance.com/futures/data',
|
|
212
214
|
'fapiPublic': 'https://fapi.binance.com/fapi/v1',
|
|
213
215
|
'fapiPublicV2': 'https://fapi.binance.com/fapi/v2',
|
|
216
|
+
'fapiPublicV3': 'https://fapi.binance.com/fapi/v3',
|
|
214
217
|
'fapiPrivate': 'https://fapi.binance.com/fapi/v1',
|
|
215
|
-
'fapiData': 'https://fapi.binance.com/futures/data',
|
|
216
218
|
'fapiPrivateV2': 'https://fapi.binance.com/fapi/v2',
|
|
219
|
+
'fapiPrivateV3': 'https://fapi.binance.com/fapi/v3',
|
|
220
|
+
'fapiData': 'https://fapi.binance.com/futures/data',
|
|
217
221
|
'public': 'https://api.binance.com/api/v3',
|
|
218
222
|
'private': 'https://api.binance.com/api/v3',
|
|
219
223
|
'v1': 'https://api.binance.com/api/v1',
|
|
@@ -849,6 +853,8 @@ export default class binance extends Exchange {
|
|
|
849
853
|
'trade/asyn': 1000,
|
|
850
854
|
'trade/asyn/id': 10,
|
|
851
855
|
'feeBurn': 1,
|
|
856
|
+
'symbolConfig': 5,
|
|
857
|
+
'accountConfig': 5,
|
|
852
858
|
},
|
|
853
859
|
'post': {
|
|
854
860
|
'batchOrders': 5,
|
|
@@ -889,6 +895,16 @@ export default class binance extends Exchange {
|
|
|
889
895
|
'positionRisk': 1,
|
|
890
896
|
},
|
|
891
897
|
},
|
|
898
|
+
'fapiPublicV3': {
|
|
899
|
+
'get': {},
|
|
900
|
+
},
|
|
901
|
+
'fapiPrivateV3': {
|
|
902
|
+
'get': {
|
|
903
|
+
'account': 1,
|
|
904
|
+
'balance': 1,
|
|
905
|
+
'positionRisk': 1,
|
|
906
|
+
},
|
|
907
|
+
},
|
|
892
908
|
'eapiPublic': {
|
|
893
909
|
'get': {
|
|
894
910
|
'ping': 1,
|
|
@@ -3420,7 +3436,7 @@ export default class binance extends Exchange {
|
|
|
3420
3436
|
}
|
|
3421
3437
|
else if (this.isLinear(type, subType)) {
|
|
3422
3438
|
type = 'linear';
|
|
3423
|
-
response = await this.
|
|
3439
|
+
response = await this.fapiPrivateV3GetAccount(this.extend(request, query));
|
|
3424
3440
|
}
|
|
3425
3441
|
else if (this.isInverse(type, subType)) {
|
|
3426
3442
|
type = 'inverse';
|
|
@@ -9429,24 +9445,29 @@ export default class binance extends Exchange {
|
|
|
9429
9445
|
//
|
|
9430
9446
|
// usdm
|
|
9431
9447
|
//
|
|
9448
|
+
// v3 (similar for cross & isolated)
|
|
9449
|
+
//
|
|
9432
9450
|
// {
|
|
9433
|
-
//
|
|
9434
|
-
//
|
|
9435
|
-
//
|
|
9436
|
-
//
|
|
9437
|
-
//
|
|
9438
|
-
//
|
|
9439
|
-
//
|
|
9440
|
-
//
|
|
9441
|
-
//
|
|
9442
|
-
//
|
|
9443
|
-
//
|
|
9444
|
-
//
|
|
9445
|
-
//
|
|
9446
|
-
//
|
|
9447
|
-
//
|
|
9448
|
-
//
|
|
9449
|
-
//
|
|
9451
|
+
// "symbol": "WLDUSDT",
|
|
9452
|
+
// "positionSide": "BOTH",
|
|
9453
|
+
// "positionAmt": "-849",
|
|
9454
|
+
// "unrealizedProfit": "11.17920750",
|
|
9455
|
+
// "notional": "-1992.46079250",
|
|
9456
|
+
// "isolatedMargin": "0",
|
|
9457
|
+
// "isolatedWallet": "0",
|
|
9458
|
+
// "initialMargin": "99.62303962",
|
|
9459
|
+
// "maintMargin": "11.95476475",
|
|
9460
|
+
// "updateTime": "1721995760449"
|
|
9461
|
+
// "leverage": "50", // in v2
|
|
9462
|
+
// "entryPrice": "2.34", // in v2
|
|
9463
|
+
// "positionInitialMargin": "118.82116614", // in v2
|
|
9464
|
+
// "openOrderInitialMargin": "0", // in v2
|
|
9465
|
+
// "isolated": false, // in v2
|
|
9466
|
+
// "breakEvenPrice": "2.3395788", // in v2
|
|
9467
|
+
// "maxNotional": "25000", // in v2
|
|
9468
|
+
// "bidNotional": "0", // in v2
|
|
9469
|
+
// "askNotional": "0" // in v2
|
|
9470
|
+
// }
|
|
9450
9471
|
//
|
|
9451
9472
|
// coinm
|
|
9452
9473
|
//
|
|
@@ -9512,13 +9533,16 @@ export default class binance extends Exchange {
|
|
|
9512
9533
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
9513
9534
|
const symbol = this.safeString(market, 'symbol');
|
|
9514
9535
|
const leverageString = this.safeString(position, 'leverage');
|
|
9515
|
-
const leverage = parseInt(leverageString);
|
|
9536
|
+
const leverage = (leverageString !== undefined) ? parseInt(leverageString) : undefined;
|
|
9516
9537
|
const initialMarginString = this.safeString(position, 'initialMargin');
|
|
9517
9538
|
const initialMargin = this.parseNumber(initialMarginString);
|
|
9518
|
-
let initialMarginPercentageString =
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9539
|
+
let initialMarginPercentageString = undefined;
|
|
9540
|
+
if (leverageString !== undefined) {
|
|
9541
|
+
initialMarginPercentageString = Precise.stringDiv('1', leverageString, 8);
|
|
9542
|
+
const rational = this.isRoundNumber(1000 % leverage);
|
|
9543
|
+
if (!rational) {
|
|
9544
|
+
initialMarginPercentageString = Precise.stringDiv(Precise.stringAdd(initialMarginPercentageString, '1e-8'), '1', 8);
|
|
9545
|
+
}
|
|
9522
9546
|
}
|
|
9523
9547
|
// as oppose to notionalValue
|
|
9524
9548
|
const usdm = ('notional' in position);
|
|
@@ -9555,7 +9579,11 @@ export default class binance extends Exchange {
|
|
|
9555
9579
|
if (timestamp === 0) {
|
|
9556
9580
|
timestamp = undefined;
|
|
9557
9581
|
}
|
|
9558
|
-
|
|
9582
|
+
let isolated = this.safeBool(position, 'isolated');
|
|
9583
|
+
if (isolated === undefined) {
|
|
9584
|
+
const isolatedMarginRaw = this.safeString(position, 'isolatedMargin');
|
|
9585
|
+
isolated = !Precise.stringEq(isolatedMarginRaw, '0');
|
|
9586
|
+
}
|
|
9559
9587
|
let marginMode = undefined;
|
|
9560
9588
|
let collateralString = undefined;
|
|
9561
9589
|
let walletBalance = undefined;
|
|
@@ -9671,23 +9699,34 @@ export default class binance extends Exchange {
|
|
|
9671
9699
|
//
|
|
9672
9700
|
// usdm
|
|
9673
9701
|
//
|
|
9674
|
-
//
|
|
9675
|
-
//
|
|
9676
|
-
//
|
|
9677
|
-
//
|
|
9678
|
-
//
|
|
9679
|
-
//
|
|
9680
|
-
//
|
|
9681
|
-
//
|
|
9682
|
-
//
|
|
9683
|
-
//
|
|
9684
|
-
//
|
|
9685
|
-
//
|
|
9686
|
-
//
|
|
9687
|
-
//
|
|
9688
|
-
//
|
|
9689
|
-
//
|
|
9690
|
-
//
|
|
9702
|
+
// {
|
|
9703
|
+
// symbol: "WLDUSDT",
|
|
9704
|
+
// positionSide: "BOTH",
|
|
9705
|
+
// positionAmt: "5",
|
|
9706
|
+
// entryPrice: "2.3483",
|
|
9707
|
+
// breakEvenPrice: "2.349356735",
|
|
9708
|
+
// markPrice: "2.39560000",
|
|
9709
|
+
// unRealizedProfit: "0.23650000",
|
|
9710
|
+
// liquidationPrice: "0",
|
|
9711
|
+
// isolatedMargin: "0",
|
|
9712
|
+
// notional: "11.97800000",
|
|
9713
|
+
// isolatedWallet: "0",
|
|
9714
|
+
// updateTime: "1722062678998",
|
|
9715
|
+
// initialMargin: "2.39560000", // not in v2
|
|
9716
|
+
// maintMargin: "0.07186800", // not in v2
|
|
9717
|
+
// positionInitialMargin: "2.39560000", // not in v2
|
|
9718
|
+
// openOrderInitialMargin: "0", // not in v2
|
|
9719
|
+
// adl: "2", // not in v2
|
|
9720
|
+
// bidNotional: "0", // not in v2
|
|
9721
|
+
// askNotional: "0", // not in v2
|
|
9722
|
+
// marginAsset: "USDT", // not in v2
|
|
9723
|
+
// // the below fields are only in v2
|
|
9724
|
+
// leverage: "5",
|
|
9725
|
+
// maxNotionalValue: "6000000",
|
|
9726
|
+
// marginType: "cross",
|
|
9727
|
+
// isAutoAddMargin: "false",
|
|
9728
|
+
// isolated: false,
|
|
9729
|
+
// adlQuantile: "2",
|
|
9691
9730
|
//
|
|
9692
9731
|
// coinm
|
|
9693
9732
|
//
|
|
@@ -9745,6 +9784,7 @@ export default class binance extends Exchange {
|
|
|
9745
9784
|
const marketId = this.safeString(position, 'symbol');
|
|
9746
9785
|
market = this.safeMarket(marketId, market, undefined, 'contract');
|
|
9747
9786
|
const symbol = this.safeString(market, 'symbol');
|
|
9787
|
+
const isolatedMarginString = this.safeString(position, 'isolatedMargin');
|
|
9748
9788
|
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets', {});
|
|
9749
9789
|
const leverageBracket = this.safeList(leverageBrackets, symbol, []);
|
|
9750
9790
|
const notionalString = this.safeString2(position, 'notional', 'notionalValue');
|
|
@@ -9762,12 +9802,13 @@ export default class binance extends Exchange {
|
|
|
9762
9802
|
const contracts = this.parseNumber(contractsAbs);
|
|
9763
9803
|
const unrealizedPnlString = this.safeString(position, 'unRealizedProfit');
|
|
9764
9804
|
const unrealizedPnl = this.parseNumber(unrealizedPnlString);
|
|
9765
|
-
const leverageString = this.safeString(position, 'leverage');
|
|
9766
|
-
const leverage = parseInt(leverageString);
|
|
9767
9805
|
const liquidationPriceString = this.omitZero(this.safeString(position, 'liquidationPrice'));
|
|
9768
9806
|
const liquidationPrice = this.parseNumber(liquidationPriceString);
|
|
9769
9807
|
let collateralString = undefined;
|
|
9770
|
-
|
|
9808
|
+
let marginMode = this.safeString(position, 'marginType');
|
|
9809
|
+
if (marginMode === undefined && isolatedMarginString !== undefined) {
|
|
9810
|
+
marginMode = Precise.stringEq(isolatedMarginString, '0') ? 'cross' : 'isolated';
|
|
9811
|
+
}
|
|
9771
9812
|
let side = undefined;
|
|
9772
9813
|
if (Precise.stringGt(notionalString, '0')) {
|
|
9773
9814
|
side = 'long';
|
|
@@ -9837,15 +9878,30 @@ export default class binance extends Exchange {
|
|
|
9837
9878
|
timestamp = undefined;
|
|
9838
9879
|
}
|
|
9839
9880
|
const maintenanceMarginPercentage = this.parseNumber(maintenanceMarginPercentageString);
|
|
9840
|
-
|
|
9881
|
+
let maintenanceMarginString = Precise.stringMul(maintenanceMarginPercentageString, notionalStringAbs);
|
|
9882
|
+
if (maintenanceMarginString === undefined) {
|
|
9883
|
+
// for a while, this new value was a backup to the existing calculations, but in future we might prioritize this
|
|
9884
|
+
maintenanceMarginString = this.safeString(position, 'maintMargin');
|
|
9885
|
+
}
|
|
9841
9886
|
const maintenanceMargin = this.parseNumber(maintenanceMarginString);
|
|
9842
|
-
let
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9887
|
+
let initialMarginString = undefined;
|
|
9888
|
+
let initialMarginPercentageString = undefined;
|
|
9889
|
+
const leverageString = this.safeString(position, 'leverage');
|
|
9890
|
+
if (leverageString !== undefined) {
|
|
9891
|
+
const leverage = parseInt(leverageString);
|
|
9892
|
+
const rational = this.isRoundNumber(1000 % leverage);
|
|
9893
|
+
initialMarginPercentageString = Precise.stringDiv('1', leverageString, 8);
|
|
9894
|
+
if (!rational) {
|
|
9895
|
+
initialMarginPercentageString = Precise.stringAdd(initialMarginPercentageString, '1e-8');
|
|
9896
|
+
}
|
|
9897
|
+
const unrounded = Precise.stringMul(notionalStringAbs, initialMarginPercentageString);
|
|
9898
|
+
initialMarginString = Precise.stringDiv(unrounded, '1', 8);
|
|
9899
|
+
}
|
|
9900
|
+
else {
|
|
9901
|
+
initialMarginString = this.safeString(position, 'initialMargin');
|
|
9902
|
+
const unrounded = Precise.stringMul(initialMarginString, '1');
|
|
9903
|
+
initialMarginPercentageString = Precise.stringDiv(unrounded, notionalStringAbs, 8);
|
|
9846
9904
|
}
|
|
9847
|
-
const initialMarginString = Precise.stringDiv(Precise.stringMul(notionalStringAbs, initialMarginPercentageString), '1', 8);
|
|
9848
|
-
const initialMargin = this.parseNumber(initialMarginString);
|
|
9849
9905
|
let marginRatio = undefined;
|
|
9850
9906
|
let percentage = undefined;
|
|
9851
9907
|
if (!Precise.stringEquals(collateralString, '0')) {
|
|
@@ -9868,7 +9924,7 @@ export default class binance extends Exchange {
|
|
|
9868
9924
|
'markPrice': markPrice,
|
|
9869
9925
|
'entryPrice': entryPrice,
|
|
9870
9926
|
'timestamp': timestamp,
|
|
9871
|
-
'initialMargin':
|
|
9927
|
+
'initialMargin': this.parseNumber(initialMarginString),
|
|
9872
9928
|
'initialMarginPercentage': this.parseNumber(initialMarginPercentageString),
|
|
9873
9929
|
'maintenanceMargin': maintenanceMargin,
|
|
9874
9930
|
'maintenanceMarginPercentage': maintenanceMarginPercentage,
|
|
@@ -10232,9 +10288,17 @@ export default class binance extends Exchange {
|
|
|
10232
10288
|
* @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
|
|
10233
10289
|
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
10234
10290
|
*/
|
|
10235
|
-
const defaultValue = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
10236
10291
|
let defaultMethod = undefined;
|
|
10237
|
-
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method'
|
|
10292
|
+
[defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method');
|
|
10293
|
+
if (defaultMethod === undefined) {
|
|
10294
|
+
const options = this.safeDict(this.options, 'fetchPositions');
|
|
10295
|
+
if (options === undefined) {
|
|
10296
|
+
defaultMethod = this.safeString(this.options, 'fetchPositions', 'positionRisk');
|
|
10297
|
+
}
|
|
10298
|
+
else {
|
|
10299
|
+
defaultMethod = 'positionRisk';
|
|
10300
|
+
}
|
|
10301
|
+
}
|
|
10238
10302
|
if (defaultMethod === 'positionRisk') {
|
|
10239
10303
|
return await this.fetchPositionsRisk(symbols, params);
|
|
10240
10304
|
}
|
|
@@ -10245,7 +10309,7 @@ export default class binance extends Exchange {
|
|
|
10245
10309
|
return await this.fetchOptionPositions(symbols, params);
|
|
10246
10310
|
}
|
|
10247
10311
|
else {
|
|
10248
|
-
throw new NotSupported(this.id + '.options["fetchPositions"]
|
|
10312
|
+
throw new NotSupported(this.id + '.options["fetchPositions"]["method"] or params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
|
|
10249
10313
|
}
|
|
10250
10314
|
}
|
|
10251
10315
|
async fetchAccountPositions(symbols = undefined, params = {}) {
|
|
@@ -10263,6 +10327,7 @@ export default class binance extends Exchange {
|
|
|
10263
10327
|
* @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
|
|
10264
10328
|
* @param {string} [params.subType] "linear" or "inverse"
|
|
10265
10329
|
* @param {boolean} [params.filterClosed] set to true if you would like to filter out closed positions, default is false
|
|
10330
|
+
* @param {boolean} [params.useV2] set to true if you want to use obsolete endpoint, where some more additional fields were provided
|
|
10266
10331
|
* @returns {object} data on account positions
|
|
10267
10332
|
*/
|
|
10268
10333
|
if (symbols !== undefined) {
|
|
@@ -10285,7 +10350,80 @@ export default class binance extends Exchange {
|
|
|
10285
10350
|
response = await this.papiGetUmAccount(params);
|
|
10286
10351
|
}
|
|
10287
10352
|
else {
|
|
10288
|
-
|
|
10353
|
+
let useV2 = undefined;
|
|
10354
|
+
[useV2, params] = this.handleOptionAndParams(params, 'fetchAccountPositions', 'useV2', false);
|
|
10355
|
+
if (!useV2) {
|
|
10356
|
+
response = await this.fapiPrivateV3GetAccount(params);
|
|
10357
|
+
}
|
|
10358
|
+
else {
|
|
10359
|
+
response = await this.fapiPrivateV2GetAccount(params);
|
|
10360
|
+
}
|
|
10361
|
+
//
|
|
10362
|
+
// {
|
|
10363
|
+
// "totalInitialMargin": "99.62112386",
|
|
10364
|
+
// "totalMaintMargin": "11.95453485",
|
|
10365
|
+
// "totalWalletBalance": "99.84331553",
|
|
10366
|
+
// "totalUnrealizedProfit": "11.17675690",
|
|
10367
|
+
// "totalMarginBalance": "111.02007243",
|
|
10368
|
+
// "totalPositionInitialMargin": "99.62112386",
|
|
10369
|
+
// "totalOpenOrderInitialMargin": "0.00000000",
|
|
10370
|
+
// "totalCrossWalletBalance": "99.84331553",
|
|
10371
|
+
// "totalCrossUnPnl": "11.17675690",
|
|
10372
|
+
// "availableBalance": "11.39894857",
|
|
10373
|
+
// "maxWithdrawAmount": "11.39894857",
|
|
10374
|
+
// "feeTier": "0", // in v2
|
|
10375
|
+
// "canTrade": true, // in v2
|
|
10376
|
+
// "canDeposit": true, // in v2
|
|
10377
|
+
// "canWithdraw": true, // in v2
|
|
10378
|
+
// "feeBurn": true, // in v2
|
|
10379
|
+
// "tradeGroupId": "-1",// in v2
|
|
10380
|
+
// "updateTime": "0", // in v2
|
|
10381
|
+
// "multiAssetsMargin": true // in v2
|
|
10382
|
+
// "assets": [
|
|
10383
|
+
// {
|
|
10384
|
+
// "asset": "USDT",
|
|
10385
|
+
// "walletBalance": "72.72317863",
|
|
10386
|
+
// "unrealizedProfit": "11.17920750",
|
|
10387
|
+
// "marginBalance": "83.90238613",
|
|
10388
|
+
// "maintMargin": "11.95476475",
|
|
10389
|
+
// "initialMargin": "99.62303962",
|
|
10390
|
+
// "positionInitialMargin": "99.62303962",
|
|
10391
|
+
// "openOrderInitialMargin": "0.00000000",
|
|
10392
|
+
// "crossWalletBalance": "72.72317863",
|
|
10393
|
+
// "crossUnPnl": "11.17920750",
|
|
10394
|
+
// "availableBalance": "11.39916777",
|
|
10395
|
+
// "maxWithdrawAmount": "11.39916777",
|
|
10396
|
+
// "updateTime": "1721995605338",
|
|
10397
|
+
// "marginAvailable": true // in v2
|
|
10398
|
+
// },
|
|
10399
|
+
// ... and some few supported settle currencies: USDC, BTC, ETH, BNB ..
|
|
10400
|
+
// ],
|
|
10401
|
+
// "positions": [
|
|
10402
|
+
// {
|
|
10403
|
+
// "symbol": "WLDUSDT",
|
|
10404
|
+
// "positionSide": "BOTH",
|
|
10405
|
+
// "positionAmt": "-849",
|
|
10406
|
+
// "unrealizedProfit": "11.17920750",
|
|
10407
|
+
// "isolatedMargin": "0",
|
|
10408
|
+
// "isolatedWallet": "0",
|
|
10409
|
+
// "notional": "-1992.46079250",
|
|
10410
|
+
// "initialMargin": "99.62303962",
|
|
10411
|
+
// "maintMargin": "11.95476475",
|
|
10412
|
+
// "updateTime": "1721995760449"
|
|
10413
|
+
// "leverage": "50", // in v2
|
|
10414
|
+
// "entryPrice": "2.34", // in v2
|
|
10415
|
+
// "positionInitialMargin": "118.82116614", // in v2
|
|
10416
|
+
// "openOrderInitialMargin": "0", // in v2
|
|
10417
|
+
// "isolated": false, // in v2
|
|
10418
|
+
// "breakEvenPrice": "2.3395788", // in v2
|
|
10419
|
+
// "maxNotional": "25000", // in v2
|
|
10420
|
+
// "bidNotional": "0", // in v2
|
|
10421
|
+
// "askNotional": "0" // in v2
|
|
10422
|
+
// },
|
|
10423
|
+
// ...
|
|
10424
|
+
// ]
|
|
10425
|
+
// }
|
|
10426
|
+
//
|
|
10289
10427
|
}
|
|
10290
10428
|
}
|
|
10291
10429
|
else if (this.isInverse(type, subType)) {
|
|
@@ -10343,7 +10481,33 @@ export default class binance extends Exchange {
|
|
|
10343
10481
|
response = await this.papiGetUmPositionRisk(this.extend(request, params));
|
|
10344
10482
|
}
|
|
10345
10483
|
else {
|
|
10346
|
-
response = await this.
|
|
10484
|
+
response = await this.fapiPrivateV3GetPositionRisk(this.extend(request, params));
|
|
10485
|
+
//
|
|
10486
|
+
// [
|
|
10487
|
+
// {
|
|
10488
|
+
// symbol: "WLDUSDT",
|
|
10489
|
+
// positionSide: "BOTH",
|
|
10490
|
+
// positionAmt: "5",
|
|
10491
|
+
// entryPrice: "2.3483",
|
|
10492
|
+
// breakEvenPrice: "2.349356735",
|
|
10493
|
+
// markPrice: "2.39560000",
|
|
10494
|
+
// unRealizedProfit: "0.23650000",
|
|
10495
|
+
// liquidationPrice: "0",
|
|
10496
|
+
// isolatedMargin: "0",
|
|
10497
|
+
// notional: "11.97800000",
|
|
10498
|
+
// isolatedWallet: "0",
|
|
10499
|
+
// updateTime: "1722062678998",
|
|
10500
|
+
// initialMargin: "2.39560000", // added in v3
|
|
10501
|
+
// maintMargin: "0.07186800", // added in v3
|
|
10502
|
+
// positionInitialMargin: "2.39560000", // added in v3
|
|
10503
|
+
// openOrderInitialMargin: "0", // added in v3
|
|
10504
|
+
// adl: "2", // added in v3
|
|
10505
|
+
// bidNotional: "0", // added in v3
|
|
10506
|
+
// askNotional: "0", // added in v3
|
|
10507
|
+
// marginAsset: "USDT", // added in v3
|
|
10508
|
+
// },
|
|
10509
|
+
// ]
|
|
10510
|
+
//
|
|
10347
10511
|
}
|
|
10348
10512
|
}
|
|
10349
10513
|
else if (this.isInverse(type, subType)) {
|
|
@@ -10363,18 +10527,18 @@ export default class binance extends Exchange {
|
|
|
10363
10527
|
//
|
|
10364
10528
|
// [
|
|
10365
10529
|
// {
|
|
10530
|
+
// "symbol": "BTCUSDT",
|
|
10531
|
+
// "positionSide": "BOTH",
|
|
10532
|
+
// "positionAmt": "0.000",
|
|
10366
10533
|
// "entryPrice": "0.00000",
|
|
10534
|
+
// "markPrice": "6679.50671178",
|
|
10535
|
+
// "unRealizedProfit": "0.00000000",
|
|
10536
|
+
// "liquidationPrice": "0",
|
|
10537
|
+
// "isolatedMargin": "0.00000000",
|
|
10367
10538
|
// "marginType": "isolated",
|
|
10368
10539
|
// "isAutoAddMargin": "false",
|
|
10369
|
-
// "isolatedMargin": "0.00000000",
|
|
10370
10540
|
// "leverage": "10",
|
|
10371
|
-
// "liquidationPrice": "0",
|
|
10372
|
-
// "markPrice": "6679.50671178",
|
|
10373
10541
|
// "maxNotionalValue": "20000000",
|
|
10374
|
-
// "positionAmt": "0.000",
|
|
10375
|
-
// "symbol": "BTCUSDT",
|
|
10376
|
-
// "unRealizedProfit": "0.00000000",
|
|
10377
|
-
// "positionSide": "BOTH",
|
|
10378
10542
|
// "updateTime": 0
|
|
10379
10543
|
// }
|
|
10380
10544
|
// ]
|
|
@@ -10391,27 +10555,13 @@ export default class binance extends Exchange {
|
|
|
10391
10555
|
// "liquidationPrice": "5930.78",
|
|
10392
10556
|
// "markPrice": "6679.50671178",
|
|
10393
10557
|
// "maxNotionalValue": "20000000",
|
|
10394
|
-
// "
|
|
10558
|
+
// "positionSide": "LONG",
|
|
10559
|
+
// "positionAmt": "20.000", // negative value for 'SHORT'
|
|
10395
10560
|
// "symbol": "BTCUSDT",
|
|
10396
10561
|
// "unRealizedProfit": "2316.83423560"
|
|
10397
|
-
// "positionSide": "LONG",
|
|
10398
10562
|
// "updateTime": 1625474304765
|
|
10399
10563
|
// },
|
|
10400
|
-
//
|
|
10401
|
-
// "entryPrice": "0.00000",
|
|
10402
|
-
// "marginType": "isolated",
|
|
10403
|
-
// "isAutoAddMargin": "false",
|
|
10404
|
-
// "isolatedMargin": "5413.95799991",
|
|
10405
|
-
// "leverage": "10",
|
|
10406
|
-
// "liquidationPrice": "7189.95",
|
|
10407
|
-
// "markPrice": "6679.50671178",
|
|
10408
|
-
// "maxNotionalValue": "20000000",
|
|
10409
|
-
// "positionAmt": "-10.000",
|
|
10410
|
-
// "symbol": "BTCUSDT",
|
|
10411
|
-
// "unRealizedProfit": "-1156.46711780",
|
|
10412
|
-
// "positionSide": "SHORT",
|
|
10413
|
-
// "updateTime": 0
|
|
10414
|
-
// }
|
|
10564
|
+
// .. second dict is similar, but with `positionSide: SHORT`
|
|
10415
10565
|
// ]
|
|
10416
10566
|
//
|
|
10417
10567
|
// inverse portfolio margin:
|
|
@@ -10455,10 +10605,9 @@ export default class binance extends Exchange {
|
|
|
10455
10605
|
const result = [];
|
|
10456
10606
|
for (let i = 0; i < response.length; i++) {
|
|
10457
10607
|
const rawPosition = response[i];
|
|
10458
|
-
const
|
|
10459
|
-
if (
|
|
10460
|
-
|
|
10461
|
-
result.push(parsed);
|
|
10608
|
+
const entryPriceString = this.safeString(rawPosition, 'entryPrice');
|
|
10609
|
+
if (Precise.stringGt(entryPriceString, '0')) {
|
|
10610
|
+
result.push(this.parsePositionRisk(response[i]));
|
|
10462
10611
|
}
|
|
10463
10612
|
}
|
|
10464
10613
|
symbols = this.marketSymbols(symbols);
|
|
@@ -11196,7 +11345,7 @@ export default class binance extends Exchange {
|
|
|
11196
11345
|
throw new AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
|
|
11197
11346
|
}
|
|
11198
11347
|
}
|
|
11199
|
-
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')) {
|
|
11348
|
+
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')) {
|
|
11200
11349
|
this.checkRequiredCredentials();
|
|
11201
11350
|
if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
|
|
11202
11351
|
// inject in implicit API calls
|
package/js/src/bybit.js
CHANGED
|
@@ -243,6 +243,7 @@ export default class bybit extends Exchange {
|
|
|
243
243
|
},
|
|
244
244
|
'private': {
|
|
245
245
|
'get': {
|
|
246
|
+
'v5/market/instruments-info': 5,
|
|
246
247
|
// Legacy inverse swap
|
|
247
248
|
'v2/private/wallet/fund/records': 25,
|
|
248
249
|
// spot
|
|
@@ -988,6 +989,7 @@ export default class bybit extends Exchange {
|
|
|
988
989
|
},
|
|
989
990
|
'precisionMode': TICK_SIZE,
|
|
990
991
|
'options': {
|
|
992
|
+
'usePrivateInstrumentsInfo': false,
|
|
991
993
|
'sandboxMode': false,
|
|
992
994
|
'enableDemoTrading': false,
|
|
993
995
|
'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
|
|
@@ -1482,7 +1484,14 @@ export default class bybit extends Exchange {
|
|
|
1482
1484
|
const request = {
|
|
1483
1485
|
'category': 'spot',
|
|
1484
1486
|
};
|
|
1485
|
-
const
|
|
1487
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1488
|
+
let response = undefined;
|
|
1489
|
+
if (usePrivateInstrumentsInfo) {
|
|
1490
|
+
response = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1491
|
+
}
|
|
1492
|
+
else {
|
|
1493
|
+
response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1494
|
+
}
|
|
1486
1495
|
//
|
|
1487
1496
|
// {
|
|
1488
1497
|
// "retCode": 0,
|
|
@@ -1592,14 +1601,27 @@ export default class bybit extends Exchange {
|
|
|
1592
1601
|
async fetchFutureMarkets(params) {
|
|
1593
1602
|
params = this.extend(params);
|
|
1594
1603
|
params['limit'] = 1000; // minimize number of requests
|
|
1595
|
-
const
|
|
1604
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1605
|
+
let response = undefined;
|
|
1606
|
+
if (usePrivateInstrumentsInfo) {
|
|
1607
|
+
response = await this.privateGetV5MarketInstrumentsInfo(params);
|
|
1608
|
+
}
|
|
1609
|
+
else {
|
|
1610
|
+
response = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1611
|
+
}
|
|
1596
1612
|
const data = this.safeDict(response, 'result', {});
|
|
1597
1613
|
let markets = this.safeList(data, 'list', []);
|
|
1598
1614
|
let paginationCursor = this.safeString(data, 'nextPageCursor');
|
|
1599
1615
|
if (paginationCursor !== undefined) {
|
|
1600
1616
|
while (paginationCursor !== undefined) {
|
|
1601
1617
|
params['cursor'] = paginationCursor;
|
|
1602
|
-
|
|
1618
|
+
let responseInner = undefined;
|
|
1619
|
+
if (usePrivateInstrumentsInfo) {
|
|
1620
|
+
responseInner = await this.privateGetV5MarketInstrumentsInfo(params);
|
|
1621
|
+
}
|
|
1622
|
+
else {
|
|
1623
|
+
responseInner = await this.publicGetV5MarketInstrumentsInfo(params);
|
|
1624
|
+
}
|
|
1603
1625
|
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1604
1626
|
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1605
1627
|
const rawMarketsLength = rawMarkets.length;
|
|
@@ -1768,7 +1790,14 @@ export default class bybit extends Exchange {
|
|
|
1768
1790
|
const request = {
|
|
1769
1791
|
'category': 'option',
|
|
1770
1792
|
};
|
|
1771
|
-
const
|
|
1793
|
+
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1794
|
+
let response = undefined;
|
|
1795
|
+
if (usePrivateInstrumentsInfo) {
|
|
1796
|
+
response = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1797
|
+
}
|
|
1798
|
+
else {
|
|
1799
|
+
response = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1800
|
+
}
|
|
1772
1801
|
const data = this.safeDict(response, 'result', {});
|
|
1773
1802
|
let markets = this.safeList(data, 'list', []);
|
|
1774
1803
|
if (this.options['loadAllOptions']) {
|
|
@@ -1777,7 +1806,13 @@ export default class bybit extends Exchange {
|
|
|
1777
1806
|
if (paginationCursor !== undefined) {
|
|
1778
1807
|
while (paginationCursor !== undefined) {
|
|
1779
1808
|
request['cursor'] = paginationCursor;
|
|
1780
|
-
|
|
1809
|
+
let responseInner = undefined;
|
|
1810
|
+
if (usePrivateInstrumentsInfo) {
|
|
1811
|
+
responseInner = await this.privateGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1812
|
+
}
|
|
1813
|
+
else {
|
|
1814
|
+
responseInner = await this.publicGetV5MarketInstrumentsInfo(this.extend(request, params));
|
|
1815
|
+
}
|
|
1781
1816
|
const dataNew = this.safeDict(responseInner, 'result', {});
|
|
1782
1817
|
const rawMarkets = this.safeList(dataNew, 'list', []);
|
|
1783
1818
|
const rawMarketsLength = rawMarkets.length;
|
|
@@ -7270,8 +7305,8 @@ export default class bybit extends Exchange {
|
|
|
7270
7305
|
let currency = undefined;
|
|
7271
7306
|
let request = {};
|
|
7272
7307
|
if (code !== undefined) {
|
|
7273
|
-
currency = this.
|
|
7274
|
-
request['coin'] = currency;
|
|
7308
|
+
currency = this.safeCurrency(code);
|
|
7309
|
+
request['coin'] = currency['id'];
|
|
7275
7310
|
}
|
|
7276
7311
|
if (since !== undefined) {
|
|
7277
7312
|
request['startTime'] = since;
|
package/js/src/mexc.js
CHANGED
|
@@ -5239,7 +5239,7 @@ export default class mexc extends Exchange {
|
|
|
5239
5239
|
const networks = this.safeDict(this.options, 'networks', {});
|
|
5240
5240
|
let network = this.safeString2(params, 'network', 'netWork'); // this line allows the user to specify either ERC20 or ETH
|
|
5241
5241
|
network = this.safeString(networks, network, network); // handle ETH > ERC-20 alias
|
|
5242
|
-
network = this.
|
|
5242
|
+
network = this.networkIdToCode(network);
|
|
5243
5243
|
this.checkAddress(address);
|
|
5244
5244
|
await this.loadMarkets();
|
|
5245
5245
|
const currency = this.currency(code);
|