ccxt 4.3.72 → 4.3.74
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/base/ws/Client.js +2 -2
- package/dist/cjs/src/binance.js +236 -87
- package/dist/cjs/src/bybit.js +2 -2
- package/dist/cjs/src/pro/alpaca.js +5 -0
- package/dist/cjs/src/pro/binance.js +31 -3
- package/dist/cjs/src/pro/bitfinex.js +5 -0
- package/dist/cjs/src/pro/kucoin.js +7 -2
- package/dist/cjs/src/pro/woo.js +129 -12
- 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/ace.js +1 -1
- package/js/src/base/ws/Client.js +2 -2
- package/js/src/binance.js +236 -87
- package/js/src/bybit.js +2 -2
- package/js/src/pro/alpaca.js +5 -0
- package/js/src/pro/binance.js +31 -3
- package/js/src/pro/bitfinex.js +5 -0
- package/js/src/pro/kucoin.js +7 -2
- package/js/src/pro/woo.d.ts +5 -0
- package/js/src/pro/woo.js +129 -12
- 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) {
|
|
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
|
@@ -7270,8 +7270,8 @@ export default class bybit extends Exchange {
|
|
|
7270
7270
|
let currency = undefined;
|
|
7271
7271
|
let request = {};
|
|
7272
7272
|
if (code !== undefined) {
|
|
7273
|
-
currency = this.
|
|
7274
|
-
request['coin'] = currency;
|
|
7273
|
+
currency = this.safeCurrency(code);
|
|
7274
|
+
request['coin'] = currency['id'];
|
|
7275
7275
|
}
|
|
7276
7276
|
if (since !== undefined) {
|
|
7277
7277
|
request['startTime'] = since;
|
package/js/src/pro/alpaca.js
CHANGED
|
@@ -52,6 +52,7 @@ export default class alpaca extends alpacaRest {
|
|
|
52
52
|
* @method
|
|
53
53
|
* @name alpaca#watchTicker
|
|
54
54
|
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
55
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes
|
|
55
56
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
56
57
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
57
58
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
@@ -127,6 +128,7 @@ export default class alpaca extends alpacaRest {
|
|
|
127
128
|
* @method
|
|
128
129
|
* @name alpaca#watchOHLCV
|
|
129
130
|
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
131
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#bars
|
|
130
132
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
131
133
|
* @param {string} timeframe the length of time each candle represents
|
|
132
134
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -183,6 +185,7 @@ export default class alpaca extends alpacaRest {
|
|
|
183
185
|
* @method
|
|
184
186
|
* @name alpaca#watchOrderBook
|
|
185
187
|
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
188
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks
|
|
186
189
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
187
190
|
* @param {int} [limit] the maximum amount of order book entries to return.
|
|
188
191
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -262,6 +265,7 @@ export default class alpaca extends alpacaRest {
|
|
|
262
265
|
* @method
|
|
263
266
|
* @name alpaca#watchTrades
|
|
264
267
|
* @description watches information on multiple trades made in a market
|
|
268
|
+
* @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades
|
|
265
269
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
266
270
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
267
271
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
@@ -314,6 +318,7 @@ export default class alpaca extends alpacaRest {
|
|
|
314
318
|
* @method
|
|
315
319
|
* @name alpaca#watchMyTrades
|
|
316
320
|
* @description watches information on multiple trades made by the user
|
|
321
|
+
* @see https://docs.alpaca.markets/docs/websocket-streaming#trade-updates
|
|
317
322
|
* @param {string} symbol unified market symbol of the market trades were made in
|
|
318
323
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
319
324
|
* @param {int} [limit] the maximum number of trade structures to retrieve
|