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.
package/dist/cjs/ccxt.js CHANGED
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
176
176
 
177
177
  //-----------------------------------------------------------------------------
178
178
  // this is updated by vss.js when building
179
- const version = '4.2.56';
179
+ const version = '4.2.57';
180
180
  Exchange["default"].ccxtVersion = version;
181
181
  const exchanges = {
182
182
  'ace': ace,
@@ -436,9 +436,11 @@ class Exchange {
436
436
  'fetchLedger': undefined,
437
437
  'fetchLedgerEntry': undefined,
438
438
  'fetchLeverage': undefined,
439
+ 'fetchLeverages': undefined,
439
440
  'fetchLeverageTiers': undefined,
440
441
  'fetchLiquidations': undefined,
441
442
  'fetchMarginMode': undefined,
443
+ 'fetchMarginModes': undefined,
442
444
  'fetchMarketLeverageTiers': undefined,
443
445
  'fetchMarkets': true,
444
446
  'fetchMarketsWs': undefined,
@@ -1867,8 +1869,17 @@ class Exchange {
1867
1869
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
1868
1870
  throw new errors.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
1869
1871
  }
1870
- async fetchMarginMode(symbol = undefined, params = {}) {
1871
- throw new errors.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
1872
+ async fetchMarginMode(symbol, params = {}) {
1873
+ if (this.has['fetchMarginModes']) {
1874
+ const marginModes = await this.fetchMarginModes([symbol], params);
1875
+ return this.safeDict(marginModes, symbol);
1876
+ }
1877
+ else {
1878
+ throw new errors.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
1879
+ }
1880
+ }
1881
+ async fetchMarginModes(symbols = undefined, params = {}) {
1882
+ throw new errors.NotSupported(this.id + ' fetchMarginModes () is not supported yet');
1872
1883
  }
1873
1884
  async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
1874
1885
  const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
@@ -1979,6 +1990,9 @@ class Exchange {
1979
1990
  async fetchLeverage(symbol, params = {}) {
1980
1991
  throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
1981
1992
  }
1993
+ async fetchLeverages(symbols = undefined, params = {}) {
1994
+ throw new errors.NotSupported(this.id + ' fetchLeverages() is not supported yet');
1995
+ }
1982
1996
  async setPositionMode(hedged, symbol = undefined, params = {}) {
1983
1997
  throw new errors.NotSupported(this.id + ' setPositionMode() is not supported yet');
1984
1998
  }
@@ -5558,6 +5572,21 @@ class Exchange {
5558
5572
  parseGreeks(greeks, market = undefined) {
5559
5573
  throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
5560
5574
  }
5575
+ parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5576
+ const marginModeStructures = {};
5577
+ for (let i = 0; i < response.length; i++) {
5578
+ const info = response[i];
5579
+ const marketId = this.safeString(info, symbolKey);
5580
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
5581
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
5582
+ marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
5583
+ }
5584
+ }
5585
+ return marginModeStructures;
5586
+ }
5587
+ parseMarginMode(marginMode, market = undefined) {
5588
+ throw new errors.NotSupported(this.id + ' parseMarginMode () is not supported yet');
5589
+ }
5561
5590
  }
5562
5591
 
5563
5592
  exports.Exchange = Exchange;
@@ -97,6 +97,8 @@ class binance extends binance$1 {
97
97
  'fetchLeverage': true,
98
98
  'fetchLeverageTiers': true,
99
99
  'fetchLiquidations': false,
100
+ 'fetchMarginMode': 'emulated',
101
+ 'fetchMarginModes': true,
100
102
  'fetchMarketLeverageTiers': 'emulated',
101
103
  'fetchMarkets': true,
102
104
  'fetchMarkOHLCV': true,
@@ -12158,6 +12160,159 @@ class binance extends binance$1 {
12158
12160
  'hedged': dualSidePosition,
12159
12161
  };
12160
12162
  }
12163
+ async fetchMarginModes(symbols = undefined, params = {}) {
12164
+ /**
12165
+ * @method
12166
+ * @name binance#fetchMarginMode
12167
+ * @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
12168
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
12169
+ * @param {string} symbol unified symbol of the market the order was made in
12170
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12171
+ * @returns {object} struct of marginMode
12172
+ */
12173
+ await this.loadMarkets();
12174
+ let market = undefined;
12175
+ if (symbols !== undefined) {
12176
+ symbols = this.marketSymbols(symbols);
12177
+ market = this.market(symbols[0]);
12178
+ }
12179
+ let subType = undefined;
12180
+ [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
12181
+ let response = undefined;
12182
+ if (subType === 'linear') {
12183
+ response = await this.fapiPrivateV2GetAccount(params);
12184
+ //
12185
+ // {
12186
+ // feeTier: '0',
12187
+ // canTrade: true,
12188
+ // canDeposit: true,
12189
+ // canWithdraw: true,
12190
+ // tradeGroupId: '-1',
12191
+ // updateTime: '0',
12192
+ // multiAssetsMargin: true,
12193
+ // totalInitialMargin: '438.31134352',
12194
+ // totalMaintMargin: '5.90847101',
12195
+ // totalWalletBalance: '4345.15626338',
12196
+ // totalUnrealizedProfit: '376.45220224',
12197
+ // totalMarginBalance: '4721.60846562',
12198
+ // totalPositionInitialMargin: '425.45252687',
12199
+ // totalOpenOrderInitialMargin: '12.85881664',
12200
+ // totalCrossWalletBalance: '4345.15626338',
12201
+ // totalCrossUnPnl: '376.45220224',
12202
+ // availableBalance: '4281.84764041',
12203
+ // maxWithdrawAmount: '4281.84764041',
12204
+ // assets: [
12205
+ // {
12206
+ // asset: 'ETH',
12207
+ // walletBalance: '0.00000000',
12208
+ // unrealizedProfit: '0.00000000',
12209
+ // marginBalance: '0.00000000',
12210
+ // maintMargin: '0.00000000',
12211
+ // initialMargin: '0.00000000',
12212
+ // positionInitialMargin: '0.00000000',
12213
+ // openOrderInitialMargin: '0.00000000',
12214
+ // maxWithdrawAmount: '0.00000000',
12215
+ // crossWalletBalance: '0.00000000',
12216
+ // crossUnPnl: '0.00000000',
12217
+ // availableBalance: '1.26075574',
12218
+ // marginAvailable: true,
12219
+ // updateTime: '0'
12220
+ // },
12221
+ // ...
12222
+ // ],
12223
+ // positions: [
12224
+ // {
12225
+ // symbol: 'SNTUSDT',
12226
+ // initialMargin: '0',
12227
+ // maintMargin: '0',
12228
+ // unrealizedProfit: '0.00000000',
12229
+ // positionInitialMargin: '0',
12230
+ // openOrderInitialMargin: '0',
12231
+ // leverage: '20',
12232
+ // isolated: false,
12233
+ // entryPrice: '0.0',
12234
+ // breakEvenPrice: '0.0',
12235
+ // maxNotional: '25000',
12236
+ // positionSide: 'BOTH',
12237
+ // positionAmt: '0',
12238
+ // notional: '0',
12239
+ // isolatedWallet: '0',
12240
+ // updateTime: '0',
12241
+ // bidNotional: '0',
12242
+ // askNotional: '0'
12243
+ // },
12244
+ // ...
12245
+ // ]
12246
+ // }
12247
+ //
12248
+ }
12249
+ else if (subType === 'inverse') {
12250
+ response = await this.dapiPrivateGetAccount(params);
12251
+ //
12252
+ // {
12253
+ // feeTier: '0',
12254
+ // canTrade: true,
12255
+ // canDeposit: true,
12256
+ // canWithdraw: true,
12257
+ // updateTime: '0',
12258
+ // assets: [
12259
+ // {
12260
+ // asset: 'APT',
12261
+ // walletBalance: '0.00000000',
12262
+ // unrealizedProfit: '0.00000000',
12263
+ // marginBalance: '0.00000000',
12264
+ // maintMargin: '0.00000000',
12265
+ // initialMargin: '0.00000000',
12266
+ // positionInitialMargin: '0.00000000',
12267
+ // openOrderInitialMargin: '0.00000000',
12268
+ // maxWithdrawAmount: '0.00000000',
12269
+ // crossWalletBalance: '0.00000000',
12270
+ // crossUnPnl: '0.00000000',
12271
+ // availableBalance: '0.00000000',
12272
+ // updateTime: '0'
12273
+ // },
12274
+ // ...
12275
+ // ],
12276
+ // positions: [
12277
+ // {
12278
+ // symbol: 'BCHUSD_240329',
12279
+ // initialMargin: '0',
12280
+ // maintMargin: '0',
12281
+ // unrealizedProfit: '0.00000000',
12282
+ // positionInitialMargin: '0',
12283
+ // openOrderInitialMargin: '0',
12284
+ // leverage: '20',
12285
+ // isolated: false,
12286
+ // positionSide: 'BOTH',
12287
+ // entryPrice: '0.00000000',
12288
+ // maxQty: '1000',
12289
+ // notionalValue: '0',
12290
+ // isolatedWallet: '0',
12291
+ // updateTime: '0',
12292
+ // positionAmt: '0',
12293
+ // breakEvenPrice: '0.00000000'
12294
+ // },
12295
+ // ...
12296
+ // ]
12297
+ // }
12298
+ //
12299
+ }
12300
+ else {
12301
+ throw new errors.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
12302
+ }
12303
+ const assets = this.safeValue(response, 'positions', []);
12304
+ return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
12305
+ }
12306
+ parseMarginMode(marginMode, market = undefined) {
12307
+ const marketId = this.safeString(marginMode, 'symbol');
12308
+ market = this.safeMarket(marketId, market);
12309
+ const isIsolated = this.safeBool(marginMode, 'isolated');
12310
+ return {
12311
+ 'info': marginMode,
12312
+ 'symbol': market['symbol'],
12313
+ 'marginMode': isIsolated ? 'isolated' : 'cross',
12314
+ };
12315
+ }
12161
12316
  }
12162
12317
 
12163
12318
  module.exports = binance;
@@ -59,7 +59,8 @@ class bitmex extends bitmex$1 {
59
59
  'fetchFundingRates': true,
60
60
  'fetchIndexOHLCV': false,
61
61
  'fetchLedger': true,
62
- 'fetchLeverage': false,
62
+ 'fetchLeverage': true,
63
+ 'fetchLeverages': true,
63
64
  'fetchLeverageTiers': false,
64
65
  'fetchLiquidations': true,
65
66
  'fetchMarketLeverageTiers': false,
@@ -2114,6 +2115,46 @@ class bitmex extends bitmex$1 {
2114
2115
  //
2115
2116
  return this.parseOrders(response, market);
2116
2117
  }
2118
+ async fetchLeverages(symbols = undefined, params = {}) {
2119
+ /**
2120
+ * @method
2121
+ * @name bitmex#fetchLeverages
2122
+ * @description fetch the set leverage for all contract markets
2123
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
2124
+ * @param {string[]} [symbols] a list of unified market symbols
2125
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2126
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2127
+ */
2128
+ await this.loadMarkets();
2129
+ const positions = await this.fetchPositions(symbols, params);
2130
+ const result = [];
2131
+ for (let i = 0; i < positions.length; i++) {
2132
+ const entry = positions[i];
2133
+ const marketId = this.safeString(entry, 'symbol');
2134
+ const market = this.safeMarket(marketId, undefined, undefined, 'contract');
2135
+ result.push({
2136
+ 'info': entry,
2137
+ 'symbol': market['symbol'],
2138
+ 'leverage': this.safeInteger(entry, 'leverage'),
2139
+ 'marginMode': this.safeString(entry, 'marginMode'),
2140
+ });
2141
+ }
2142
+ return result;
2143
+ }
2144
+ async fetchLeverage(symbol, params = {}) {
2145
+ /**
2146
+ * @method
2147
+ * @name bitmex#fetchLeverage
2148
+ * @description fetch the set leverage for a market
2149
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
2150
+ * @param {string} symbol unified market symbol
2151
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2152
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2153
+ */
2154
+ await this.loadMarkets();
2155
+ const leverage = await this.fetchLeverages([symbol], params);
2156
+ return leverage;
2157
+ }
2117
2158
  async fetchPositions(symbols = undefined, params = {}) {
2118
2159
  /**
2119
2160
  * @method
@@ -63,7 +63,8 @@ class hitbtc extends hitbtc$1 {
63
63
  'fetchLeverage': true,
64
64
  'fetchLeverageTiers': undefined,
65
65
  'fetchLiquidations': false,
66
- 'fetchMarginMode': true,
66
+ 'fetchMarginMode': 'emulated',
67
+ 'fetchMarginModes': true,
67
68
  'fetchMarketLeverageTiers': false,
68
69
  'fetchMarkets': true,
69
70
  'fetchMarkOHLCV': true,
@@ -2507,7 +2508,7 @@ class hitbtc extends hitbtc$1 {
2507
2508
  'stopLossPrice': undefined,
2508
2509
  }, market);
2509
2510
  }
2510
- async fetchMarginMode(symbol = undefined, params = {}) {
2511
+ async fetchMarginModes(symbols = undefined, params = {}) {
2511
2512
  /**
2512
2513
  * @method
2513
2514
  * @name hitbtc#fetchMarginMode
@@ -2520,70 +2521,66 @@ class hitbtc extends hitbtc$1 {
2520
2521
  */
2521
2522
  await this.loadMarkets();
2522
2523
  let market = undefined;
2523
- if (symbol !== undefined) {
2524
- market = this.market(symbol);
2524
+ if (symbols !== undefined) {
2525
+ symbols = this.marketSymbols(symbols);
2526
+ market = this.market(symbols[0]);
2525
2527
  }
2526
2528
  let marketType = undefined;
2527
2529
  [marketType, params] = this.handleMarketTypeAndParams('fetchMarginMode', market, params);
2528
2530
  let response = undefined;
2529
2531
  if (marketType === 'margin') {
2530
2532
  response = await this.privateGetMarginConfig(params);
2533
+ //
2534
+ // {
2535
+ // "config": [{
2536
+ // "symbol": "BTCUSD",
2537
+ // "margin_call_leverage_mul": "1.50",
2538
+ // "liquidation_leverage_mul": "2.00",
2539
+ // "max_initial_leverage": "10.00",
2540
+ // "margin_mode": "Isolated",
2541
+ // "force_close_fee": "0.05",
2542
+ // "enabled": true,
2543
+ // "active": true,
2544
+ // "limit_base": "50000.00",
2545
+ // "limit_power": "2.2",
2546
+ // "unlimited_threshold": "10.0"
2547
+ // }]
2548
+ // }
2549
+ //
2531
2550
  }
2532
2551
  else if (marketType === 'swap') {
2533
2552
  response = await this.privateGetFuturesConfig(params);
2553
+ //
2554
+ // {
2555
+ // "config": [{
2556
+ // "symbol": "BTCUSD_PERP",
2557
+ // "margin_call_leverage_mul": "1.20",
2558
+ // "liquidation_leverage_mul": "2.00",
2559
+ // "max_initial_leverage": "100.00",
2560
+ // "margin_mode": "Isolated",
2561
+ // "force_close_fee": "0.001",
2562
+ // "enabled": true,
2563
+ // "active": false,
2564
+ // "limit_base": "5000000.000000000000",
2565
+ // "limit_power": "1.25",
2566
+ // "unlimited_threshold": "2.00"
2567
+ // }]
2568
+ // }
2569
+ //
2534
2570
  }
2535
2571
  else {
2536
- throw new errors.BadSymbol(this.id + ' fetchMarginMode() supports swap contracts and margin only');
2537
- }
2538
- //
2539
- // margin
2540
- // {
2541
- // "config": [{
2542
- // "symbol": "BTCUSD",
2543
- // "margin_call_leverage_mul": "1.50",
2544
- // "liquidation_leverage_mul": "2.00",
2545
- // "max_initial_leverage": "10.00",
2546
- // "margin_mode": "Isolated",
2547
- // "force_close_fee": "0.05",
2548
- // "enabled": true,
2549
- // "active": true,
2550
- // "limit_base": "50000.00",
2551
- // "limit_power": "2.2",
2552
- // "unlimited_threshold": "10.0"
2553
- // }]
2554
- // }
2555
- //
2556
- // swap
2557
- // {
2558
- // "config": [{
2559
- // "symbol": "BTCUSD_PERP",
2560
- // "margin_call_leverage_mul": "1.20",
2561
- // "liquidation_leverage_mul": "2.00",
2562
- // "max_initial_leverage": "100.00",
2563
- // "margin_mode": "Isolated",
2564
- // "force_close_fee": "0.001",
2565
- // "enabled": true,
2566
- // "active": false,
2567
- // "limit_base": "5000000.000000000000",
2568
- // "limit_power": "1.25",
2569
- // "unlimited_threshold": "2.00"
2570
- // }]
2571
- // }
2572
- //
2573
- const config = this.safeValue(response, 'config', []);
2574
- const marginModes = [];
2575
- for (let i = 0; i < config.length; i++) {
2576
- const data = this.safeValue(config, i);
2577
- const marketId = this.safeString(data, 'symbol');
2578
- const marketInner = this.safeMarket(marketId);
2579
- marginModes.push({
2580
- 'info': data,
2581
- 'symbol': this.safeString(marketInner, 'symbol'),
2582
- 'marginMode': this.safeStringLower(data, 'margin_mode'),
2583
- });
2572
+ throw new errors.BadSymbol(this.id + ' fetchMarginModes () supports swap contracts and margin only');
2584
2573
  }
2585
- const filteredMargin = this.filterBySymbol(marginModes, symbol);
2586
- return this.safeValue(filteredMargin, 0);
2574
+ const config = this.safeList(response, 'config', []);
2575
+ return this.parseMarginModes(config, symbols, 'symbol');
2576
+ }
2577
+ parseMarginMode(marginMode, market = undefined) {
2578
+ const marketId = this.safeString(marginMode, 'symbol');
2579
+ return {
2580
+ 'info': marginMode,
2581
+ 'symbol': this.safeSymbol(marketId, market),
2582
+ 'marginMode': this.safeStringLower(marginMode, 'margin_mode'),
2583
+ };
2587
2584
  }
2588
2585
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
2589
2586
  /**
@@ -71,6 +71,8 @@ class mexc extends mexc$1 {
71
71
  'fetchL2OrderBook': true,
72
72
  'fetchLedger': undefined,
73
73
  'fetchLedgerEntry': undefined,
74
+ 'fetchLeverage': true,
75
+ 'fetchLeverages': false,
74
76
  'fetchLeverageTiers': true,
75
77
  'fetchMarginMode': false,
76
78
  'fetchMarketLeverageTiers': undefined,
@@ -5373,6 +5375,79 @@ class mexc extends mexc$1 {
5373
5375
  }
5374
5376
  return this.assignDefaultDepositWithdrawFees(result);
5375
5377
  }
5378
+ async fetchLeverage(symbol, params = {}) {
5379
+ /**
5380
+ * @method
5381
+ * @name mexc#fetchLeverage
5382
+ * @description fetch the set leverage for a market
5383
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
5384
+ * @param {string} symbol unified market symbol
5385
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
5386
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
5387
+ */
5388
+ await this.loadMarkets();
5389
+ const market = this.market(symbol);
5390
+ const request = {
5391
+ 'symbol': market['id'],
5392
+ };
5393
+ const response = await this.contractPrivateGetPositionLeverage(this.extend(request, params));
5394
+ //
5395
+ // {
5396
+ // "success": true,
5397
+ // "code": 0,
5398
+ // "data": [
5399
+ // {
5400
+ // "level": 1,
5401
+ // "maxVol": 463300,
5402
+ // "mmr": 0.004,
5403
+ // "imr": 0.005,
5404
+ // "positionType": 1,
5405
+ // "openType": 1,
5406
+ // "leverage": 20,
5407
+ // "limitBySys": false,
5408
+ // "currentMmr": 0.004
5409
+ // },
5410
+ // {
5411
+ // "level": 1,
5412
+ // "maxVol": 463300,
5413
+ // "mmr": 0.004,
5414
+ // "imr": 0.005,
5415
+ // "positionType": 2,
5416
+ // "openType": 1,
5417
+ // "leverage": 20,
5418
+ // "limitBySys": false,
5419
+ // "currentMmr": 0.004
5420
+ // }
5421
+ // ]
5422
+ // }
5423
+ //
5424
+ const data = this.safeList(response, 'data', []);
5425
+ const longLeverage = this.safeDict(data, 0);
5426
+ return this.parseLeverage(longLeverage, market);
5427
+ }
5428
+ parseLeverage(leverage, market = undefined) {
5429
+ //
5430
+ // {
5431
+ // "level": 1,
5432
+ // "maxVol": 463300,
5433
+ // "mmr": 0.004,
5434
+ // "imr": 0.005,
5435
+ // "positionType": 1,
5436
+ // "openType": 1,
5437
+ // "leverage": 20,
5438
+ // "limitBySys": false,
5439
+ // "currentMmr": 0.004
5440
+ // }
5441
+ //
5442
+ const marketId = this.safeString(leverage, 'symbol');
5443
+ market = this.safeMarket(marketId, market, undefined, 'contract');
5444
+ return {
5445
+ 'info': leverage,
5446
+ 'symbol': market['symbol'],
5447
+ 'leverage': this.safeInteger(leverage, 'leverage'),
5448
+ 'marginMode': undefined,
5449
+ };
5450
+ }
5376
5451
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
5377
5452
  /**
5378
5453
  * @ignore
@@ -60,17 +60,9 @@ class bitmex extends bitmex$1 {
60
60
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
61
61
  */
62
62
  await this.loadMarkets();
63
- const market = this.market(symbol);
64
- const name = 'instrument';
65
- const messageHash = name + ':' + market['id'];
66
- const url = this.urls['api']['ws'];
67
- const request = {
68
- 'op': 'subscribe',
69
- 'args': [
70
- messageHash,
71
- ],
72
- };
73
- return await this.watch(url, messageHash, this.extend(request, params), messageHash);
63
+ symbol = this.symbol(symbol);
64
+ const tickers = await this.watchTickers([symbol], params);
65
+ return tickers[symbol];
74
66
  }
75
67
  async watchTickers(symbols = undefined, params = {}) {
76
68
  /**
@@ -86,26 +78,27 @@ class bitmex extends bitmex$1 {
86
78
  const name = 'instrument';
87
79
  const url = this.urls['api']['ws'];
88
80
  const messageHashes = [];
81
+ const rawSubscriptions = [];
89
82
  if (symbols !== undefined) {
90
83
  for (let i = 0; i < symbols.length; i++) {
91
84
  const symbol = symbols[i];
92
85
  const market = this.market(symbol);
93
- const hash = name + ':' + market['id'];
94
- messageHashes.push(hash);
86
+ const subscription = name + ':' + market['id'];
87
+ rawSubscriptions.push(subscription);
88
+ const messageHash = 'ticker:' + symbol;
89
+ messageHashes.push(messageHash);
95
90
  }
96
91
  }
97
92
  else {
98
- messageHashes.push(name);
93
+ rawSubscriptions.push(name);
94
+ messageHashes.push('alltickers');
99
95
  }
100
96
  const request = {
101
97
  'op': 'subscribe',
102
- 'args': messageHashes,
98
+ 'args': rawSubscriptions,
103
99
  };
104
- const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
100
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), rawSubscriptions);
105
101
  if (this.newUpdates) {
106
- if (symbols === undefined) {
107
- return ticker;
108
- }
109
102
  const result = {};
110
103
  result[ticker['symbol']] = ticker;
111
104
  return result;
@@ -339,23 +332,21 @@ class bitmex extends bitmex$1 {
339
332
  // ]
340
333
  // }
341
334
  //
342
- const table = this.safeString(message, 'table');
343
335
  const data = this.safeList(message, 'data', []);
344
- const tickers = {};
345
336
  for (let i = 0; i < data.length; i++) {
346
337
  const update = data[i];
347
338
  const marketId = this.safeString(update, 'symbol');
348
- const market = this.safeMarket(marketId);
349
- const symbol = market['symbol'];
350
- const messageHash = table + ':' + marketId;
351
- const ticker = this.safeDict(this.tickers, symbol, {});
352
- const info = this.safeDict(ticker, 'info', {});
353
- const parsedTicker = this.parseTicker(this.extend(info, update), market);
354
- tickers[symbol] = parsedTicker;
355
- this.tickers[symbol] = parsedTicker;
356
- client.resolve(ticker, messageHash);
339
+ const symbol = this.safeSymbol(marketId);
340
+ if (!(symbol in this.tickers)) {
341
+ this.tickers[symbol] = this.parseTicker({});
342
+ }
343
+ const updatedTicker = this.parseTicker(update);
344
+ const fullParsedTicker = this.deepExtend(this.tickers[symbol], updatedTicker);
345
+ this.tickers[symbol] = fullParsedTicker;
346
+ const messageHash = 'ticker:' + symbol;
347
+ client.resolve(fullParsedTicker, messageHash);
348
+ client.resolve(fullParsedTicker, 'alltickers');
357
349
  }
358
- client.resolve(tickers, 'instrument');
359
350
  return message;
360
351
  }
361
352
  async watchBalance(params = {}) {
@@ -1335,7 +1326,7 @@ class bitmex extends bitmex$1 {
1335
1326
  const messageHash = table + ':' + market['id'];
1336
1327
  const result = [
1337
1328
  this.parse8601(this.safeString(candle, 'timestamp')) - duration * 1000,
1338
- this.safeFloat(candle, 'open'),
1329
+ undefined,
1339
1330
  this.safeFloat(candle, 'high'),
1340
1331
  this.safeFloat(candle, 'low'),
1341
1332
  this.safeFloat(candle, 'close'),
@@ -1088,7 +1088,10 @@ class cex extends cex$1 {
1088
1088
  for (let i = 0; i < sorted.length; i++) {
1089
1089
  stored.append(this.parseOHLCV(sorted[i], market));
1090
1090
  }
1091
- this.ohlcvs[symbol] = stored;
1091
+ if (!(symbol in this.ohlcvs)) {
1092
+ this.ohlcvs[symbol] = {};
1093
+ }
1094
+ this.ohlcvs[symbol]['unknown'] = stored;
1092
1095
  client.resolve(stored, messageHash);
1093
1096
  }
1094
1097
  handleOHLCV24(client, message) {
@@ -1147,7 +1150,8 @@ class cex extends cex$1 {
1147
1150
  const pair = this.safeString(message, 'pair');
1148
1151
  const symbol = this.pairToSymbol(pair);
1149
1152
  const messageHash = 'ohlcv:' + symbol;
1150
- const stored = this.safeValue(this.ohlcvs, symbol);
1153
+ // const stored = this.safeValue (this.ohlcvs, symbol);
1154
+ const stored = this.ohlcvs[symbol]['unknown'];
1151
1155
  for (let i = 0; i < data.length; i++) {
1152
1156
  const ohlcv = [
1153
1157
  this.safeTimestamp(data[i], 0),