ccxt 4.3.73 → 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/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.73';
197
+ const version = '4.3.74';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -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
  }
@@ -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.fapiPrivateV2GetAccount(this.extend(request, query));
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
- // "symbol": "BTCBUSD",
9431
- // "initialMargin": "0",
9432
- // "maintMargin": "0",
9433
- // "unrealizedProfit": "0.00000000",
9434
- // "positionInitialMargin": "0",
9435
- // "openOrderInitialMargin": "0",
9436
- // "leverage": "20",
9437
- // "isolated": false,
9438
- // "entryPrice": "0.0000",
9439
- // "maxNotional": "100000",
9440
- // "positionSide": "BOTH",
9441
- // "positionAmt": "0.000",
9442
- // "notional": "0",
9443
- // "isolatedWallet": "0",
9444
- // "updateTime": "0",
9445
- // "crossMargin": "100.93634809",
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 = Precise["default"].stringDiv('1', leverageString, 8);
9516
- const rational = this.isRoundNumber(1000 % leverage);
9517
- if (!rational) {
9518
- initialMarginPercentageString = Precise["default"].stringDiv(Precise["default"].stringAdd(initialMarginPercentageString, '1e-8'), '1', 8);
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
- const isolated = this.safeBool(position, 'isolated');
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
- // "symbol": "BTCUSDT",
9673
- // "positionAmt": "0.001",
9674
- // "entryPrice": "43578.07000",
9675
- // "markPrice": "43532.30000000",
9676
- // "unRealizedProfit": "-0.04577000",
9677
- // "liquidationPrice": "21841.24993976",
9678
- // "leverage": "2",
9679
- // "maxNotionalValue": "300000000",
9680
- // "marginType": "isolated",
9681
- // "isolatedMargin": "21.77841506",
9682
- // "isAutoAddMargin": "false",
9683
- // "positionSide": "BOTH",
9684
- // "notional": "43.53230000",
9685
- // "isolatedWallet": "21.82418506",
9686
- // "updateTime": "1621358023886"
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
- const marginMode = this.safeString(position, 'marginType');
9805
+ let marginMode = this.safeString(position, 'marginType');
9806
+ if (marginMode === undefined && isolatedMarginString) {
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
- const maintenanceMarginString = Precise["default"].stringMul(maintenanceMarginPercentageString, notionalStringAbs);
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 initialMarginPercentageString = Precise["default"].stringDiv('1', leverageString, 8);
9840
- const rational = this.isRoundNumber(1000 % leverage);
9841
- if (!rational) {
9842
- initialMarginPercentageString = Precise["default"].stringAdd(initialMarginPercentageString, '1e-8');
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': 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', defaultValue);
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"]/params["method"] = "' + defaultMethod + '" is invalid, please choose between "account", "positionRisk" and "option"');
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
- response = await this.fapiPrivateV2GetAccount(params);
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.fapiPrivateV2GetPositionRisk(this.extend(request, params));
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
- // "positionAmt": "20.000",
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 entryPrice = this.safeString(rawPosition, 'entryPrice');
10456
- if ((entryPrice !== '0') && (entryPrice !== '0.0') && (entryPrice !== '0.00000000')) {
10457
- const parsed = this.parsePositionRisk(response[i]);
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
@@ -7264,8 +7264,8 @@ class bybit extends bybit$1 {
7264
7264
  let currency = undefined;
7265
7265
  let request = {};
7266
7266
  if (code !== undefined) {
7267
- currency = this.safeCurrencyCode(code);
7268
- request['coin'] = currency;
7267
+ currency = this.safeCurrency(code);
7268
+ request['coin'] = currency['id'];
7269
7269
  }
7270
7270
  if (since !== undefined) {
7271
7271
  request['startTime'] = since;
@@ -49,6 +49,7 @@ class alpaca extends alpaca$1 {
49
49
  * @method
50
50
  * @name alpaca#watchTicker
51
51
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
52
+ * @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes
52
53
  * @param {string} symbol unified symbol of the market to fetch the ticker for
53
54
  * @param {object} [params] extra parameters specific to the exchange API endpoint
54
55
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -124,6 +125,7 @@ class alpaca extends alpaca$1 {
124
125
  * @method
125
126
  * @name alpaca#watchOHLCV
126
127
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
128
+ * @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#bars
127
129
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
128
130
  * @param {string} timeframe the length of time each candle represents
129
131
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -180,6 +182,7 @@ class alpaca extends alpaca$1 {
180
182
  * @method
181
183
  * @name alpaca#watchOrderBook
182
184
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
185
+ * @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks
183
186
  * @param {string} symbol unified symbol of the market to fetch the order book for
184
187
  * @param {int} [limit] the maximum amount of order book entries to return.
185
188
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -259,6 +262,7 @@ class alpaca extends alpaca$1 {
259
262
  * @method
260
263
  * @name alpaca#watchTrades
261
264
  * @description watches information on multiple trades made in a market
265
+ * @see https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades
262
266
  * @param {string} symbol unified market symbol of the market trades were made in
263
267
  * @param {int} [since] the earliest time in ms to fetch orders for
264
268
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -311,6 +315,7 @@ class alpaca extends alpaca$1 {
311
315
  * @method
312
316
  * @name alpaca#watchMyTrades
313
317
  * @description watches information on multiple trades made by the user
318
+ * @see https://docs.alpaca.markets/docs/websocket-streaming#trade-updates
314
319
  * @param {string} symbol unified market symbol of the market trades were made in
315
320
  * @param {int} [since] the earliest time in ms to fetch trades for
316
321
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -931,10 +931,15 @@ class binance extends binance$1 {
931
931
  * @method
932
932
  * @name binance#watchTradesForSymbols
933
933
  * @description get the list of most recent trades for a list of symbols
934
+ * @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
935
+ * @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
936
+ * @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
937
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
934
938
  * @param {string[]} symbols unified symbol of the market to fetch trades for
935
939
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
936
940
  * @param {int} [limit] the maximum amount of trades to fetch
937
941
  * @param {object} [params] extra parameters specific to the exchange API endpoint
942
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
938
943
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
939
944
  */
940
945
  await this.loadMarkets();
@@ -947,8 +952,9 @@ class binance extends binance$1 {
947
952
  }
948
953
  streamHash += '::' + symbols.join(',');
949
954
  }
950
- const options = this.safeValue(this.options, 'watchTradesForSymbols', {});
951
- const name = this.safeString(options, 'name', 'trade');
955
+ let name = undefined;
956
+ [name, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'name', 'trade');
957
+ params = this.omit(params, 'callerMethodName');
952
958
  const firstMarket = this.market(symbols[0]);
953
959
  let type = firstMarket['type'];
954
960
  if (firstMarket['contract']) {
@@ -988,12 +994,18 @@ class binance extends binance$1 {
988
994
  * @method
989
995
  * @name binance#watchTrades
990
996
  * @description get the list of most recent trades for a particular symbol
997
+ * @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
998
+ * @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
999
+ * @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
1000
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
991
1001
  * @param {string} symbol unified symbol of the market to fetch trades for
992
1002
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
993
1003
  * @param {int} [limit] the maximum amount of trades to fetch
994
1004
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1005
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
995
1006
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
996
1007
  */
1008
+ params['callerMethodName'] = 'watchTrades';
997
1009
  return await this.watchTradesForSymbols([symbol], since, limit, params);
998
1010
  }
999
1011
  parseWsTrade(trade, market = undefined) {
@@ -1255,6 +1267,7 @@ class binance extends binance$1 {
1255
1267
  const subscribe = {
1256
1268
  'id': requestId,
1257
1269
  };
1270
+ params = this.omit(params, 'callerMethodName');
1258
1271
  const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscribe);
1259
1272
  if (this.newUpdates) {
1260
1273
  limit = candles.getLimit(symbol, limit);