ccxt 4.2.56 → 4.2.57

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.
@@ -7451,9 +7451,11 @@ class Exchange {
7451
7451
  'fetchLedger': undefined,
7452
7452
  'fetchLedgerEntry': undefined,
7453
7453
  'fetchLeverage': undefined,
7454
+ 'fetchLeverages': undefined,
7454
7455
  'fetchLeverageTiers': undefined,
7455
7456
  'fetchLiquidations': undefined,
7456
7457
  'fetchMarginMode': undefined,
7458
+ 'fetchMarginModes': undefined,
7457
7459
  'fetchMarketLeverageTiers': undefined,
7458
7460
  'fetchMarkets': true,
7459
7461
  'fetchMarketsWs': undefined,
@@ -8884,8 +8886,17 @@ class Exchange {
8884
8886
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
8885
8887
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
8886
8888
  }
8887
- async fetchMarginMode(symbol = undefined, params = {}) {
8888
- throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
8889
+ async fetchMarginMode(symbol, params = {}) {
8890
+ if (this.has['fetchMarginModes']) {
8891
+ const marginModes = await this.fetchMarginModes([symbol], params);
8892
+ return this.safeDict(marginModes, symbol);
8893
+ }
8894
+ else {
8895
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
8896
+ }
8897
+ }
8898
+ async fetchMarginModes(symbols = undefined, params = {}) {
8899
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginModes () is not supported yet');
8889
8900
  }
8890
8901
  async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
8891
8902
  const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
@@ -8996,6 +9007,9 @@ class Exchange {
8996
9007
  async fetchLeverage(symbol, params = {}) {
8997
9008
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverage() is not supported yet');
8998
9009
  }
9010
+ async fetchLeverages(symbols = undefined, params = {}) {
9011
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverages() is not supported yet');
9012
+ }
8999
9013
  async setPositionMode(hedged, symbol = undefined, params = {}) {
9000
9014
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setPositionMode() is not supported yet');
9001
9015
  }
@@ -12575,6 +12589,21 @@ class Exchange {
12575
12589
  parseGreeks(greeks, market = undefined) {
12576
12590
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseGreeks () is not supported yet');
12577
12591
  }
12592
+ parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
12593
+ const marginModeStructures = {};
12594
+ for (let i = 0; i < response.length; i++) {
12595
+ const info = response[i];
12596
+ const marketId = this.safeString(info, symbolKey);
12597
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
12598
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
12599
+ marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
12600
+ }
12601
+ }
12602
+ return marginModeStructures;
12603
+ }
12604
+ parseMarginMode(marginMode, market = undefined) {
12605
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginMode () is not supported yet');
12606
+ }
12578
12607
  }
12579
12608
 
12580
12609
 
@@ -18183,6 +18212,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18183
18212
  'fetchLeverage': true,
18184
18213
  'fetchLeverageTiers': true,
18185
18214
  'fetchLiquidations': false,
18215
+ 'fetchMarginMode': 'emulated',
18216
+ 'fetchMarginModes': true,
18186
18217
  'fetchMarketLeverageTiers': 'emulated',
18187
18218
  'fetchMarkets': true,
18188
18219
  'fetchMarkOHLCV': true,
@@ -30244,6 +30275,159 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30244
30275
  'hedged': dualSidePosition,
30245
30276
  };
30246
30277
  }
30278
+ async fetchMarginModes(symbols = undefined, params = {}) {
30279
+ /**
30280
+ * @method
30281
+ * @name binance#fetchMarginMode
30282
+ * @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
30283
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
30284
+ * @param {string} symbol unified symbol of the market the order was made in
30285
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30286
+ * @returns {object} struct of marginMode
30287
+ */
30288
+ await this.loadMarkets();
30289
+ let market = undefined;
30290
+ if (symbols !== undefined) {
30291
+ symbols = this.marketSymbols(symbols);
30292
+ market = this.market(symbols[0]);
30293
+ }
30294
+ let subType = undefined;
30295
+ [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
30296
+ let response = undefined;
30297
+ if (subType === 'linear') {
30298
+ response = await this.fapiPrivateV2GetAccount(params);
30299
+ //
30300
+ // {
30301
+ // feeTier: '0',
30302
+ // canTrade: true,
30303
+ // canDeposit: true,
30304
+ // canWithdraw: true,
30305
+ // tradeGroupId: '-1',
30306
+ // updateTime: '0',
30307
+ // multiAssetsMargin: true,
30308
+ // totalInitialMargin: '438.31134352',
30309
+ // totalMaintMargin: '5.90847101',
30310
+ // totalWalletBalance: '4345.15626338',
30311
+ // totalUnrealizedProfit: '376.45220224',
30312
+ // totalMarginBalance: '4721.60846562',
30313
+ // totalPositionInitialMargin: '425.45252687',
30314
+ // totalOpenOrderInitialMargin: '12.85881664',
30315
+ // totalCrossWalletBalance: '4345.15626338',
30316
+ // totalCrossUnPnl: '376.45220224',
30317
+ // availableBalance: '4281.84764041',
30318
+ // maxWithdrawAmount: '4281.84764041',
30319
+ // assets: [
30320
+ // {
30321
+ // asset: 'ETH',
30322
+ // walletBalance: '0.00000000',
30323
+ // unrealizedProfit: '0.00000000',
30324
+ // marginBalance: '0.00000000',
30325
+ // maintMargin: '0.00000000',
30326
+ // initialMargin: '0.00000000',
30327
+ // positionInitialMargin: '0.00000000',
30328
+ // openOrderInitialMargin: '0.00000000',
30329
+ // maxWithdrawAmount: '0.00000000',
30330
+ // crossWalletBalance: '0.00000000',
30331
+ // crossUnPnl: '0.00000000',
30332
+ // availableBalance: '1.26075574',
30333
+ // marginAvailable: true,
30334
+ // updateTime: '0'
30335
+ // },
30336
+ // ...
30337
+ // ],
30338
+ // positions: [
30339
+ // {
30340
+ // symbol: 'SNTUSDT',
30341
+ // initialMargin: '0',
30342
+ // maintMargin: '0',
30343
+ // unrealizedProfit: '0.00000000',
30344
+ // positionInitialMargin: '0',
30345
+ // openOrderInitialMargin: '0',
30346
+ // leverage: '20',
30347
+ // isolated: false,
30348
+ // entryPrice: '0.0',
30349
+ // breakEvenPrice: '0.0',
30350
+ // maxNotional: '25000',
30351
+ // positionSide: 'BOTH',
30352
+ // positionAmt: '0',
30353
+ // notional: '0',
30354
+ // isolatedWallet: '0',
30355
+ // updateTime: '0',
30356
+ // bidNotional: '0',
30357
+ // askNotional: '0'
30358
+ // },
30359
+ // ...
30360
+ // ]
30361
+ // }
30362
+ //
30363
+ }
30364
+ else if (subType === 'inverse') {
30365
+ response = await this.dapiPrivateGetAccount(params);
30366
+ //
30367
+ // {
30368
+ // feeTier: '0',
30369
+ // canTrade: true,
30370
+ // canDeposit: true,
30371
+ // canWithdraw: true,
30372
+ // updateTime: '0',
30373
+ // assets: [
30374
+ // {
30375
+ // asset: 'APT',
30376
+ // walletBalance: '0.00000000',
30377
+ // unrealizedProfit: '0.00000000',
30378
+ // marginBalance: '0.00000000',
30379
+ // maintMargin: '0.00000000',
30380
+ // initialMargin: '0.00000000',
30381
+ // positionInitialMargin: '0.00000000',
30382
+ // openOrderInitialMargin: '0.00000000',
30383
+ // maxWithdrawAmount: '0.00000000',
30384
+ // crossWalletBalance: '0.00000000',
30385
+ // crossUnPnl: '0.00000000',
30386
+ // availableBalance: '0.00000000',
30387
+ // updateTime: '0'
30388
+ // },
30389
+ // ...
30390
+ // ],
30391
+ // positions: [
30392
+ // {
30393
+ // symbol: 'BCHUSD_240329',
30394
+ // initialMargin: '0',
30395
+ // maintMargin: '0',
30396
+ // unrealizedProfit: '0.00000000',
30397
+ // positionInitialMargin: '0',
30398
+ // openOrderInitialMargin: '0',
30399
+ // leverage: '20',
30400
+ // isolated: false,
30401
+ // positionSide: 'BOTH',
30402
+ // entryPrice: '0.00000000',
30403
+ // maxQty: '1000',
30404
+ // notionalValue: '0',
30405
+ // isolatedWallet: '0',
30406
+ // updateTime: '0',
30407
+ // positionAmt: '0',
30408
+ // breakEvenPrice: '0.00000000'
30409
+ // },
30410
+ // ...
30411
+ // ]
30412
+ // }
30413
+ //
30414
+ }
30415
+ else {
30416
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
30417
+ }
30418
+ const assets = this.safeValue(response, 'positions', []);
30419
+ return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
30420
+ }
30421
+ parseMarginMode(marginMode, market = undefined) {
30422
+ const marketId = this.safeString(marginMode, 'symbol');
30423
+ market = this.safeMarket(marketId, market);
30424
+ const isIsolated = this.safeBool(marginMode, 'isolated');
30425
+ return {
30426
+ 'info': marginMode,
30427
+ 'symbol': market['symbol'],
30428
+ 'marginMode': isIsolated ? 'isolated' : 'cross',
30429
+ };
30430
+ }
30247
30431
  }
30248
30432
 
30249
30433
 
@@ -58531,7 +58715,8 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
58531
58715
  'fetchFundingRates': true,
58532
58716
  'fetchIndexOHLCV': false,
58533
58717
  'fetchLedger': true,
58534
- 'fetchLeverage': false,
58718
+ 'fetchLeverage': true,
58719
+ 'fetchLeverages': true,
58535
58720
  'fetchLeverageTiers': false,
58536
58721
  'fetchLiquidations': true,
58537
58722
  'fetchMarketLeverageTiers': false,
@@ -60586,6 +60771,46 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
60586
60771
  //
60587
60772
  return this.parseOrders(response, market);
60588
60773
  }
60774
+ async fetchLeverages(symbols = undefined, params = {}) {
60775
+ /**
60776
+ * @method
60777
+ * @name bitmex#fetchLeverages
60778
+ * @description fetch the set leverage for all contract markets
60779
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
60780
+ * @param {string[]} [symbols] a list of unified market symbols
60781
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
60782
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
60783
+ */
60784
+ await this.loadMarkets();
60785
+ const positions = await this.fetchPositions(symbols, params);
60786
+ const result = [];
60787
+ for (let i = 0; i < positions.length; i++) {
60788
+ const entry = positions[i];
60789
+ const marketId = this.safeString(entry, 'symbol');
60790
+ const market = this.safeMarket(marketId, undefined, undefined, 'contract');
60791
+ result.push({
60792
+ 'info': entry,
60793
+ 'symbol': market['symbol'],
60794
+ 'leverage': this.safeInteger(entry, 'leverage'),
60795
+ 'marginMode': this.safeString(entry, 'marginMode'),
60796
+ });
60797
+ }
60798
+ return result;
60799
+ }
60800
+ async fetchLeverage(symbol, params = {}) {
60801
+ /**
60802
+ * @method
60803
+ * @name bitmex#fetchLeverage
60804
+ * @description fetch the set leverage for a market
60805
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
60806
+ * @param {string} symbol unified market symbol
60807
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
60808
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
60809
+ */
60810
+ await this.loadMarkets();
60811
+ const leverage = await this.fetchLeverages([symbol], params);
60812
+ return leverage;
60813
+ }
60589
60814
  async fetchPositions(symbols = undefined, params = {}) {
60590
60815
  /**
60591
60816
  * @method
@@ -141191,7 +141416,8 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141191
141416
  'fetchLeverage': true,
141192
141417
  'fetchLeverageTiers': undefined,
141193
141418
  'fetchLiquidations': false,
141194
- 'fetchMarginMode': true,
141419
+ 'fetchMarginMode': 'emulated',
141420
+ 'fetchMarginModes': true,
141195
141421
  'fetchMarketLeverageTiers': false,
141196
141422
  'fetchMarkets': true,
141197
141423
  'fetchMarkOHLCV': true,
@@ -143635,7 +143861,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
143635
143861
  'stopLossPrice': undefined,
143636
143862
  }, market);
143637
143863
  }
143638
- async fetchMarginMode(symbol = undefined, params = {}) {
143864
+ async fetchMarginModes(symbols = undefined, params = {}) {
143639
143865
  /**
143640
143866
  * @method
143641
143867
  * @name hitbtc#fetchMarginMode
@@ -143648,70 +143874,66 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
143648
143874
  */
143649
143875
  await this.loadMarkets();
143650
143876
  let market = undefined;
143651
- if (symbol !== undefined) {
143652
- market = this.market(symbol);
143877
+ if (symbols !== undefined) {
143878
+ symbols = this.marketSymbols(symbols);
143879
+ market = this.market(symbols[0]);
143653
143880
  }
143654
143881
  let marketType = undefined;
143655
143882
  [marketType, params] = this.handleMarketTypeAndParams('fetchMarginMode', market, params);
143656
143883
  let response = undefined;
143657
143884
  if (marketType === 'margin') {
143658
143885
  response = await this.privateGetMarginConfig(params);
143886
+ //
143887
+ // {
143888
+ // "config": [{
143889
+ // "symbol": "BTCUSD",
143890
+ // "margin_call_leverage_mul": "1.50",
143891
+ // "liquidation_leverage_mul": "2.00",
143892
+ // "max_initial_leverage": "10.00",
143893
+ // "margin_mode": "Isolated",
143894
+ // "force_close_fee": "0.05",
143895
+ // "enabled": true,
143896
+ // "active": true,
143897
+ // "limit_base": "50000.00",
143898
+ // "limit_power": "2.2",
143899
+ // "unlimited_threshold": "10.0"
143900
+ // }]
143901
+ // }
143902
+ //
143659
143903
  }
143660
143904
  else if (marketType === 'swap') {
143661
143905
  response = await this.privateGetFuturesConfig(params);
143906
+ //
143907
+ // {
143908
+ // "config": [{
143909
+ // "symbol": "BTCUSD_PERP",
143910
+ // "margin_call_leverage_mul": "1.20",
143911
+ // "liquidation_leverage_mul": "2.00",
143912
+ // "max_initial_leverage": "100.00",
143913
+ // "margin_mode": "Isolated",
143914
+ // "force_close_fee": "0.001",
143915
+ // "enabled": true,
143916
+ // "active": false,
143917
+ // "limit_base": "5000000.000000000000",
143918
+ // "limit_power": "1.25",
143919
+ // "unlimited_threshold": "2.00"
143920
+ // }]
143921
+ // }
143922
+ //
143662
143923
  }
143663
143924
  else {
143664
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchMarginMode() supports swap contracts and margin only');
143925
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchMarginModes () supports swap contracts and margin only');
143665
143926
  }
143666
- //
143667
- // margin
143668
- // {
143669
- // "config": [{
143670
- // "symbol": "BTCUSD",
143671
- // "margin_call_leverage_mul": "1.50",
143672
- // "liquidation_leverage_mul": "2.00",
143673
- // "max_initial_leverage": "10.00",
143674
- // "margin_mode": "Isolated",
143675
- // "force_close_fee": "0.05",
143676
- // "enabled": true,
143677
- // "active": true,
143678
- // "limit_base": "50000.00",
143679
- // "limit_power": "2.2",
143680
- // "unlimited_threshold": "10.0"
143681
- // }]
143682
- // }
143683
- //
143684
- // swap
143685
- // {
143686
- // "config": [{
143687
- // "symbol": "BTCUSD_PERP",
143688
- // "margin_call_leverage_mul": "1.20",
143689
- // "liquidation_leverage_mul": "2.00",
143690
- // "max_initial_leverage": "100.00",
143691
- // "margin_mode": "Isolated",
143692
- // "force_close_fee": "0.001",
143693
- // "enabled": true,
143694
- // "active": false,
143695
- // "limit_base": "5000000.000000000000",
143696
- // "limit_power": "1.25",
143697
- // "unlimited_threshold": "2.00"
143698
- // }]
143699
- // }
143700
- //
143701
- const config = this.safeValue(response, 'config', []);
143702
- const marginModes = [];
143703
- for (let i = 0; i < config.length; i++) {
143704
- const data = this.safeValue(config, i);
143705
- const marketId = this.safeString(data, 'symbol');
143706
- const marketInner = this.safeMarket(marketId);
143707
- marginModes.push({
143708
- 'info': data,
143709
- 'symbol': this.safeString(marketInner, 'symbol'),
143710
- 'marginMode': this.safeStringLower(data, 'margin_mode'),
143711
- });
143712
- }
143713
- const filteredMargin = this.filterBySymbol(marginModes, symbol);
143714
- return this.safeValue(filteredMargin, 0);
143927
+ const config = this.safeList(response, 'config', []);
143928
+ return this.parseMarginModes(config, symbols, 'symbol');
143929
+ }
143930
+ parseMarginMode(marginMode, market = undefined) {
143931
+ const marketId = this.safeString(marginMode, 'symbol');
143932
+ return {
143933
+ 'info': marginMode,
143934
+ 'symbol': this.safeSymbol(marketId, market),
143935
+ 'marginMode': this.safeStringLower(marginMode, 'margin_mode'),
143936
+ };
143715
143937
  }
143716
143938
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
143717
143939
  /**
@@ -184476,6 +184698,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184476
184698
  'fetchL2OrderBook': true,
184477
184699
  'fetchLedger': undefined,
184478
184700
  'fetchLedgerEntry': undefined,
184701
+ 'fetchLeverage': true,
184702
+ 'fetchLeverages': false,
184479
184703
  'fetchLeverageTiers': true,
184480
184704
  'fetchMarginMode': false,
184481
184705
  'fetchMarketLeverageTiers': undefined,
@@ -189779,6 +190003,79 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
189779
190003
  }
189780
190004
  return this.assignDefaultDepositWithdrawFees(result);
189781
190005
  }
190006
+ async fetchLeverage(symbol, params = {}) {
190007
+ /**
190008
+ * @method
190009
+ * @name mexc#fetchLeverage
190010
+ * @description fetch the set leverage for a market
190011
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
190012
+ * @param {string} symbol unified market symbol
190013
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
190014
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
190015
+ */
190016
+ await this.loadMarkets();
190017
+ const market = this.market(symbol);
190018
+ const request = {
190019
+ 'symbol': market['id'],
190020
+ };
190021
+ const response = await this.contractPrivateGetPositionLeverage(this.extend(request, params));
190022
+ //
190023
+ // {
190024
+ // "success": true,
190025
+ // "code": 0,
190026
+ // "data": [
190027
+ // {
190028
+ // "level": 1,
190029
+ // "maxVol": 463300,
190030
+ // "mmr": 0.004,
190031
+ // "imr": 0.005,
190032
+ // "positionType": 1,
190033
+ // "openType": 1,
190034
+ // "leverage": 20,
190035
+ // "limitBySys": false,
190036
+ // "currentMmr": 0.004
190037
+ // },
190038
+ // {
190039
+ // "level": 1,
190040
+ // "maxVol": 463300,
190041
+ // "mmr": 0.004,
190042
+ // "imr": 0.005,
190043
+ // "positionType": 2,
190044
+ // "openType": 1,
190045
+ // "leverage": 20,
190046
+ // "limitBySys": false,
190047
+ // "currentMmr": 0.004
190048
+ // }
190049
+ // ]
190050
+ // }
190051
+ //
190052
+ const data = this.safeList(response, 'data', []);
190053
+ const longLeverage = this.safeDict(data, 0);
190054
+ return this.parseLeverage(longLeverage, market);
190055
+ }
190056
+ parseLeverage(leverage, market = undefined) {
190057
+ //
190058
+ // {
190059
+ // "level": 1,
190060
+ // "maxVol": 463300,
190061
+ // "mmr": 0.004,
190062
+ // "imr": 0.005,
190063
+ // "positionType": 1,
190064
+ // "openType": 1,
190065
+ // "leverage": 20,
190066
+ // "limitBySys": false,
190067
+ // "currentMmr": 0.004
190068
+ // }
190069
+ //
190070
+ const marketId = this.safeString(leverage, 'symbol');
190071
+ market = this.safeMarket(marketId, market, undefined, 'contract');
190072
+ return {
190073
+ 'info': leverage,
190074
+ 'symbol': market['symbol'],
190075
+ 'leverage': this.safeInteger(leverage, 'leverage'),
190076
+ 'marginMode': undefined,
190077
+ };
190078
+ }
189782
190079
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
189783
190080
  /**
189784
190081
  * @ignore
@@ -229659,17 +229956,9 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229659
229956
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
229660
229957
  */
229661
229958
  await this.loadMarkets();
229662
- const market = this.market(symbol);
229663
- const name = 'instrument';
229664
- const messageHash = name + ':' + market['id'];
229665
- const url = this.urls['api']['ws'];
229666
- const request = {
229667
- 'op': 'subscribe',
229668
- 'args': [
229669
- messageHash,
229670
- ],
229671
- };
229672
- return await this.watch(url, messageHash, this.extend(request, params), messageHash);
229959
+ symbol = this.symbol(symbol);
229960
+ const tickers = await this.watchTickers([symbol], params);
229961
+ return tickers[symbol];
229673
229962
  }
229674
229963
  async watchTickers(symbols = undefined, params = {}) {
229675
229964
  /**
@@ -229685,26 +229974,27 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229685
229974
  const name = 'instrument';
229686
229975
  const url = this.urls['api']['ws'];
229687
229976
  const messageHashes = [];
229977
+ const rawSubscriptions = [];
229688
229978
  if (symbols !== undefined) {
229689
229979
  for (let i = 0; i < symbols.length; i++) {
229690
229980
  const symbol = symbols[i];
229691
229981
  const market = this.market(symbol);
229692
- const hash = name + ':' + market['id'];
229693
- messageHashes.push(hash);
229982
+ const subscription = name + ':' + market['id'];
229983
+ rawSubscriptions.push(subscription);
229984
+ const messageHash = 'ticker:' + symbol;
229985
+ messageHashes.push(messageHash);
229694
229986
  }
229695
229987
  }
229696
229988
  else {
229697
- messageHashes.push(name);
229989
+ rawSubscriptions.push(name);
229990
+ messageHashes.push('alltickers');
229698
229991
  }
229699
229992
  const request = {
229700
229993
  'op': 'subscribe',
229701
- 'args': messageHashes,
229994
+ 'args': rawSubscriptions,
229702
229995
  };
229703
- const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
229996
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), rawSubscriptions);
229704
229997
  if (this.newUpdates) {
229705
- if (symbols === undefined) {
229706
- return ticker;
229707
- }
229708
229998
  const result = {};
229709
229999
  result[ticker['symbol']] = ticker;
229710
230000
  return result;
@@ -229938,23 +230228,23 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229938
230228
  // ]
229939
230229
  // }
229940
230230
  //
229941
- const table = this.safeString(message, 'table');
229942
230231
  const data = this.safeList(message, 'data', []);
229943
230232
  const tickers = {};
229944
230233
  for (let i = 0; i < data.length; i++) {
229945
230234
  const update = data[i];
229946
230235
  const marketId = this.safeString(update, 'symbol');
229947
- const market = this.safeMarket(marketId);
229948
- const symbol = market['symbol'];
229949
- const messageHash = table + ':' + marketId;
229950
- const ticker = this.safeDict(this.tickers, symbol, {});
229951
- const info = this.safeDict(ticker, 'info', {});
229952
- const parsedTicker = this.parseTicker(this.extend(info, update), market);
229953
- tickers[symbol] = parsedTicker;
229954
- this.tickers[symbol] = parsedTicker;
229955
- client.resolve(ticker, messageHash);
230236
+ const symbol = this.safeSymbol(marketId);
230237
+ if (!(symbol in this.tickers)) {
230238
+ this.tickers[symbol] = this.parseTicker({});
230239
+ }
230240
+ const updatedTicker = this.parseTicker(update);
230241
+ const fullParsedTicker = this.deepExtend(this.tickers[symbol], updatedTicker);
230242
+ tickers[symbol] = fullParsedTicker;
230243
+ this.tickers[symbol] = fullParsedTicker;
230244
+ const messageHash = 'ticker:' + symbol;
230245
+ client.resolve(fullParsedTicker, messageHash);
230246
+ client.resolve(fullParsedTicker, 'alltickers');
229956
230247
  }
229957
- client.resolve(tickers, 'instrument');
229958
230248
  return message;
229959
230249
  }
229960
230250
  async watchBalance(params = {}) {
@@ -230934,7 +231224,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
230934
231224
  const messageHash = table + ':' + market['id'];
230935
231225
  const result = [
230936
231226
  this.parse8601(this.safeString(candle, 'timestamp')) - duration * 1000,
230937
- this.safeFloat(candle, 'open'),
231227
+ undefined,
230938
231228
  this.safeFloat(candle, 'high'),
230939
231229
  this.safeFloat(candle, 'low'),
230940
231230
  this.safeFloat(candle, 'close'),
@@ -237860,7 +238150,10 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
237860
238150
  for (let i = 0; i < sorted.length; i++) {
237861
238151
  stored.append(this.parseOHLCV(sorted[i], market));
237862
238152
  }
237863
- this.ohlcvs[symbol] = stored;
238153
+ if (!(symbol in this.ohlcvs)) {
238154
+ this.ohlcvs[symbol] = {};
238155
+ }
238156
+ this.ohlcvs[symbol]['unknown'] = stored;
237864
238157
  client.resolve(stored, messageHash);
237865
238158
  }
237866
238159
  handleOHLCV24(client, message) {
@@ -237919,7 +238212,8 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
237919
238212
  const pair = this.safeString(message, 'pair');
237920
238213
  const symbol = this.pairToSymbol(pair);
237921
238214
  const messageHash = 'ohlcv:' + symbol;
237922
- const stored = this.safeValue(this.ohlcvs, symbol);
238215
+ // const stored = this.safeValue (this.ohlcvs, symbol);
238216
+ const stored = this.ohlcvs[symbol]['unknown'];
237923
238217
  for (let i = 0; i < data.length; i++) {
237924
238218
  const ohlcv = [
237925
238219
  this.safeTimestamp(data[i], 0),
@@ -240444,14 +240738,17 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
240444
240738
  const keys = Object.keys(this.ohlcvs);
240445
240739
  const keysLength = keys.length;
240446
240740
  if (keysLength === 0) {
240741
+ this.ohlcvs['unknown'] = {};
240447
240742
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
240448
- this.ohlcvs = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
240743
+ const stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
240744
+ this.ohlcvs['unknown']['unknown'] = stored;
240449
240745
  }
240746
+ const ohlcv = this.ohlcvs['unknown']['unknown'];
240450
240747
  for (let i = 0; i < ohlcvs.length; i++) {
240451
240748
  const candle = ohlcvs[i];
240452
- this.ohlcvs.append(candle);
240749
+ ohlcv.append(candle);
240453
240750
  }
240454
- client.resolve(this.ohlcvs, messageHash);
240751
+ client.resolve(ohlcv, messageHash);
240455
240752
  }
240456
240753
  async watchTicker(symbol, params = {}) {
240457
240754
  /**
@@ -259427,7 +259724,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
259427
259724
  // "d": {
259428
259725
  // "e": "spot@public.kline.v3.api",
259429
259726
  // "k": {
259430
- // "t": 1678642260,
259727
+ // "t": 1678642261,
259431
259728
  // "o": 20626.94,
259432
259729
  // "c": 20599.69,
259433
259730
  // "h": 20626.94,
@@ -259640,7 +259937,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
259640
259937
  client.subscriptions[messageHash] = 1;
259641
259938
  this.orderbooks[symbol] = this.countedOrderBook({});
259642
259939
  }
259643
- const storedOrderBook = this.safeValue(this.orderbooks, symbol);
259940
+ const storedOrderBook = this.orderbooks[symbol];
259644
259941
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
259645
259942
  if (nonce === undefined) {
259646
259943
  const cacheLength = storedOrderBook.cache.length;
@@ -270673,15 +270970,19 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
270673
270970
  const symbol = market['symbol'];
270674
270971
  const messageHash = 'candles' + ':' + symbol;
270675
270972
  const parsed = this.parseOHLCV(data, market);
270676
- this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol);
270677
- let stored = this.ohlcvs[symbol];
270678
- if (stored === undefined) {
270973
+ // this.ohlcvs[symbol] = this.safeValue (this.ohlcvs, symbol);
270974
+ if (!(symbol in this.ohlcvs)) {
270975
+ this.ohlcvs[symbol] = {};
270976
+ }
270977
+ // let stored = this.ohlcvs[symbol]['unknown']; // we don't know the timeframe but we need to respect the type
270978
+ if (!('unknown' in this.ohlcvs[symbol])) {
270679
270979
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
270680
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
270681
- this.ohlcvs[symbol] = stored;
270980
+ const stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
270981
+ this.ohlcvs[symbol]['unknown'] = stored;
270682
270982
  }
270683
- stored.append(parsed);
270684
- client.resolve(stored, messageHash);
270983
+ const ohlcv = this.ohlcvs[symbol]['unknown'];
270984
+ ohlcv.append(parsed);
270985
+ client.resolve(ohlcv, messageHash);
270685
270986
  }
270686
270987
  return message;
270687
270988
  }
@@ -307689,7 +307990,7 @@ SOFTWARE.
307689
307990
 
307690
307991
  //-----------------------------------------------------------------------------
307691
307992
  // this is updated by vss.js when building
307692
- const version = '4.2.56';
307993
+ const version = '4.2.57';
307693
307994
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
307694
307995
  //-----------------------------------------------------------------------------
307695
307996