ccxt 4.2.46 → 4.2.48

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.
@@ -46,6 +46,9 @@ class indodax extends indodax$1 {
46
46
  'fetchCrossBorrowRate': false,
47
47
  'fetchCrossBorrowRates': false,
48
48
  'fetchDeposit': false,
49
+ 'fetchDepositAddress': 'emulated',
50
+ 'fetchDepositAddresses': true,
51
+ 'fetchDepositAddressesByNetwork': false,
49
52
  'fetchDeposits': false,
50
53
  'fetchDepositsWithdrawals': true,
51
54
  'fetchFundingHistory': false,
@@ -94,7 +97,7 @@ class indodax extends indodax$1 {
94
97
  'urls': {
95
98
  'logo': 'https://user-images.githubusercontent.com/51840849/87070508-9358c880-c221-11ea-8dc5-5391afbbb422.jpg',
96
99
  'api': {
97
- 'public': 'https://indodax.com/api',
100
+ 'public': 'https://indodax.com',
98
101
  'private': 'https://indodax.com/tapi',
99
102
  },
100
103
  'www': 'https://www.indodax.com',
@@ -104,14 +107,15 @@ class indodax extends indodax$1 {
104
107
  'api': {
105
108
  'public': {
106
109
  'get': {
107
- 'server_time': 5,
108
- 'pairs': 5,
109
- 'price_increments': 5,
110
- 'summaries': 5,
111
- 'ticker_all': 5,
112
- '{pair}/ticker': 5,
113
- '{pair}/trades': 5,
114
- '{pair}/depth': 5,
110
+ 'api/server_time': 5,
111
+ 'api/pairs': 5,
112
+ 'api/price_increments': 5,
113
+ 'api/summaries': 5,
114
+ 'api/ticker/{pair}': 5,
115
+ 'api/ticker_all': 5,
116
+ 'api/trades/{pair}': 5,
117
+ 'api/depth/{pair}': 5,
118
+ 'tradingview/history_v2': 5,
115
119
  },
116
120
  },
117
121
  'private': {
@@ -157,7 +161,35 @@ class indodax extends indodax$1 {
157
161
  'options': {
158
162
  'recvWindow': 5 * 1000,
159
163
  'timeDifference': 0,
160
- 'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation
164
+ 'adjustForTimeDifference': false,
165
+ 'networks': {
166
+ 'XLM': 'Stellar Token',
167
+ 'BSC': 'bep20',
168
+ 'TRC20': 'trc20',
169
+ 'MATIC': 'polygon',
170
+ // 'BEP2': 'bep2',
171
+ // 'ARB': 'arb',
172
+ // 'ERC20': 'erc20',
173
+ // 'KIP7': 'kip7',
174
+ // 'MAINNET': 'mainnet', // TODO: does mainnet just mean the default?
175
+ // 'OEP4': 'oep4',
176
+ // 'OP': 'op',
177
+ // 'SPL': 'spl',
178
+ // 'TRC10': 'trc10',
179
+ // 'ZRC2': 'zrc2'
180
+ // 'ETH': 'eth'
181
+ // 'BASE': 'base'
182
+ },
183
+ 'timeframes': {
184
+ '1m': '1',
185
+ '15m': '15',
186
+ '30m': '30',
187
+ '1h': '60',
188
+ '4h': '240',
189
+ '1d': '1D',
190
+ '3d': '3D',
191
+ '1w': '1W',
192
+ },
161
193
  },
162
194
  'commonCurrencies': {
163
195
  'STR': 'XLM',
@@ -177,10 +209,11 @@ class indodax extends indodax$1 {
177
209
  * @method
178
210
  * @name indodax#fetchTime
179
211
  * @description fetches the current integer timestamp in milliseconds from the exchange server
212
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#server-time
180
213
  * @param {object} [params] extra parameters specific to the exchange API endpoint
181
214
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
182
215
  */
183
- const response = await this.publicGetServerTime(params);
216
+ const response = await this.publicGetApiServerTime(params);
184
217
  //
185
218
  // {
186
219
  // "timezone": "UTC",
@@ -194,10 +227,11 @@ class indodax extends indodax$1 {
194
227
  * @method
195
228
  * @name indodax#fetchMarkets
196
229
  * @description retrieves data on all markets for indodax
230
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#pairs
197
231
  * @param {object} [params] extra parameters specific to the exchange API endpoint
198
232
  * @returns {object[]} an array of objects representing market data
199
233
  */
200
- const response = await this.publicGetPairs(params);
234
+ const response = await this.publicGetApiPairs(params);
201
235
  //
202
236
  // [
203
237
  // {
@@ -314,6 +348,7 @@ class indodax extends indodax$1 {
314
348
  * @method
315
349
  * @name indodax#fetchBalance
316
350
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
351
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-info-endpoint
317
352
  * @param {object} [params] extra parameters specific to the exchange API endpoint
318
353
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
319
354
  */
@@ -356,6 +391,7 @@ class indodax extends indodax$1 {
356
391
  * @method
357
392
  * @name indodax#fetchOrderBook
358
393
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
394
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#depth
359
395
  * @param {string} symbol unified symbol of the market to fetch the order book for
360
396
  * @param {int} [limit] the maximum amount of order book entries to return
361
397
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -364,9 +400,9 @@ class indodax extends indodax$1 {
364
400
  await this.loadMarkets();
365
401
  const market = this.market(symbol);
366
402
  const request = {
367
- 'pair': market['id'],
403
+ 'pair': market['base'] + market['quote'],
368
404
  };
369
- const orderbook = await this.publicGetPairDepth(this.extend(request, params));
405
+ const orderbook = await this.publicGetApiDepthPair(this.extend(request, params));
370
406
  return this.parseOrderBook(orderbook, market['symbol'], undefined, 'buy', 'sell');
371
407
  }
372
408
  parseTicker(ticker, market = undefined) {
@@ -415,6 +451,7 @@ class indodax extends indodax$1 {
415
451
  * @method
416
452
  * @name indodax#fetchTicker
417
453
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
454
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#ticker
418
455
  * @param {string} symbol unified symbol of the market to fetch the ticker for
419
456
  * @param {object} [params] extra parameters specific to the exchange API endpoint
420
457
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -422,9 +459,9 @@ class indodax extends indodax$1 {
422
459
  await this.loadMarkets();
423
460
  const market = this.market(symbol);
424
461
  const request = {
425
- 'pair': market['id'],
462
+ 'pair': market['base'] + market['quote'],
426
463
  };
427
- const response = await this.publicGetPairTicker(this.extend(request, params));
464
+ const response = await this.publicGetApiTickerPair(this.extend(request, params));
428
465
  //
429
466
  // {
430
467
  // "ticker": {
@@ -469,7 +506,7 @@ class indodax extends indodax$1 {
469
506
  // }
470
507
  // }
471
508
  //
472
- const response = await this.publicGetTickerAll(params);
509
+ const response = await this.publicGetApiTickerAll(params);
473
510
  const tickers = this.safeValue(response, 'tickers');
474
511
  return this.parseTickers(tickers, symbols);
475
512
  }
@@ -496,6 +533,7 @@ class indodax extends indodax$1 {
496
533
  * @method
497
534
  * @name indodax#fetchTrades
498
535
  * @description get the list of most recent trades for a particular symbol
536
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#trades
499
537
  * @param {string} symbol unified symbol of the market to fetch trades for
500
538
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
501
539
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -505,11 +543,81 @@ class indodax extends indodax$1 {
505
543
  await this.loadMarkets();
506
544
  const market = this.market(symbol);
507
545
  const request = {
508
- 'pair': market['id'],
546
+ 'pair': market['base'] + market['quote'],
509
547
  };
510
- const response = await this.publicGetPairTrades(this.extend(request, params));
548
+ const response = await this.publicGetApiTradesPair(this.extend(request, params));
511
549
  return this.parseTrades(response, market, since, limit);
512
550
  }
551
+ parseOHLCV(ohlcv, market = undefined) {
552
+ //
553
+ // {
554
+ // "Time": 1708416900,
555
+ // "Open": 51707.52,
556
+ // "High": 51707.52,
557
+ // "Low": 51707.52,
558
+ // "Close": 51707.52,
559
+ // "Volume": "0"
560
+ // }
561
+ //
562
+ return [
563
+ this.safeTimestamp(ohlcv, 'Time'),
564
+ this.safeNumber(ohlcv, 'Open'),
565
+ this.safeNumber(ohlcv, 'High'),
566
+ this.safeNumber(ohlcv, 'Low'),
567
+ this.safeNumber(ohlcv, 'Close'),
568
+ this.safeNumber(ohlcv, 'Volume'),
569
+ ];
570
+ }
571
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
572
+ /**
573
+ * @method
574
+ * @name indodax#fetchOHLCV
575
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
576
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
577
+ * @param {string} timeframe the length of time each candle represents
578
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
579
+ * @param {int} [limit] the maximum amount of candles to fetch
580
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
581
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
582
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
583
+ */
584
+ await this.loadMarkets();
585
+ const market = this.market(symbol);
586
+ const timeframes = this.options['timeframes'];
587
+ const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
588
+ const now = this.seconds();
589
+ const until = this.safeInteger2(params, 'until', 'till', now);
590
+ params = this.omit(params, ['until', 'till']);
591
+ const request = {
592
+ 'to': until,
593
+ 'tf': selectedTimeframe,
594
+ 'symbol': market['base'] + market['quote'],
595
+ };
596
+ if (limit === undefined) {
597
+ limit = 1000;
598
+ }
599
+ if (since !== undefined) {
600
+ request['from'] = Math.floor(since / 1000);
601
+ }
602
+ else {
603
+ const duration = this.parseTimeframe(timeframe);
604
+ request['from'] = now - limit * duration - 1;
605
+ }
606
+ const response = await this.publicGetTradingviewHistoryV2(this.extend(request, params));
607
+ //
608
+ // [
609
+ // {
610
+ // "Time": 1708416900,
611
+ // "Open": 51707.52,
612
+ // "High": 51707.52,
613
+ // "Low": 51707.52,
614
+ // "Close": 51707.52,
615
+ // "Volume": "0"
616
+ // }
617
+ // ]
618
+ //
619
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
620
+ }
513
621
  parseOrderStatus(status) {
514
622
  const statuses = {
515
623
  'open': 'open',
@@ -601,6 +709,7 @@ class indodax extends indodax$1 {
601
709
  * @method
602
710
  * @name indodax#fetchOrder
603
711
  * @description fetches information on an order made by the user
712
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-order-endpoints
604
713
  * @param {string} symbol unified symbol of the market the order was made in
605
714
  * @param {object} [params] extra parameters specific to the exchange API endpoint
606
715
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -625,6 +734,7 @@ class indodax extends indodax$1 {
625
734
  * @method
626
735
  * @name indodax#fetchOpenOrders
627
736
  * @description fetch all unfilled currently open orders
737
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#open-orders-endpoints
628
738
  * @param {string} symbol unified market symbol
629
739
  * @param {int} [since] the earliest time in ms to fetch open orders for
630
740
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -665,6 +775,7 @@ class indodax extends indodax$1 {
665
775
  * @method
666
776
  * @name indodax#fetchClosedOrders
667
777
  * @description fetches information on multiple closed orders made by the user
778
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#order-history
668
779
  * @param {string} symbol unified market symbol of the market orders were made in
669
780
  * @param {int} [since] the earliest time in ms to fetch orders for
670
781
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -689,6 +800,7 @@ class indodax extends indodax$1 {
689
800
  * @method
690
801
  * @name indodax#createOrder
691
802
  * @description create a trade order
803
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#trade-endpoints
692
804
  * @param {string} symbol unified symbol of the market to create an order in
693
805
  * @param {string} type 'market' or 'limit'
694
806
  * @param {string} side 'buy' or 'sell'
@@ -728,6 +840,7 @@ class indodax extends indodax$1 {
728
840
  * @method
729
841
  * @name indodax#cancelOrder
730
842
  * @description cancels an open order
843
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#cancel-order-endpoints
731
844
  * @param {string} id order id
732
845
  * @param {string} symbol unified symbol of the market the order was made in
733
846
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -754,6 +867,7 @@ class indodax extends indodax$1 {
754
867
  * @method
755
868
  * @name indodax#fetchTransactionFee
756
869
  * @description fetch the fee for a transaction
870
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-fee-endpoints
757
871
  * @param {string} code unified currency code
758
872
  * @param {object} [params] extra parameters specific to the exchange API endpoint
759
873
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -787,6 +901,7 @@ class indodax extends indodax$1 {
787
901
  * @method
788
902
  * @name indodax#fetchDepositsWithdrawals
789
903
  * @description fetch history of deposits and withdrawals
904
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#transaction-history-endpoints
790
905
  * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
791
906
  * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
792
907
  * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
@@ -888,6 +1003,7 @@ class indodax extends indodax$1 {
888
1003
  * @method
889
1004
  * @name indodax#withdraw
890
1005
  * @description make a withdrawal
1006
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-coin-endpoints
891
1007
  * @param {string} code unified currency code
892
1008
  * @param {float} amount the amount to withdraw
893
1009
  * @param {string} address the address to withdraw to
@@ -1016,10 +1132,100 @@ class indodax extends indodax$1 {
1016
1132
  };
1017
1133
  return this.safeString(statuses, status, status);
1018
1134
  }
1135
+ async fetchDepositAddresses(codes = undefined, params = {}) {
1136
+ /**
1137
+ * @method
1138
+ * @name indodax#fetchDepositAddresses
1139
+ * @description fetch deposit addresses for multiple currencies and chain types
1140
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#general-information-on-endpoints
1141
+ * @param {string[]} [codes] list of unified currency codes, default is undefined
1142
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1143
+ * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
1144
+ */
1145
+ await this.loadMarkets();
1146
+ const response = await this.privatePostGetInfo(params);
1147
+ //
1148
+ // {
1149
+ // success: '1',
1150
+ // return: {
1151
+ // server_time: '1708031570',
1152
+ // balance: {
1153
+ // idr: '29952',
1154
+ // ...
1155
+ // },
1156
+ // balance_hold: {
1157
+ // idr: '0',
1158
+ // ...
1159
+ // },
1160
+ // address: {
1161
+ // btc: '1KMntgzvU7iTSgMBWc11nVuJjAyfW3qJyk',
1162
+ // ...
1163
+ // },
1164
+ // memo_is_required: {
1165
+ // btc: { mainnet: false },
1166
+ // ...
1167
+ // },
1168
+ // network: {
1169
+ // btc: 'mainnet',
1170
+ // ...
1171
+ // },
1172
+ // user_id: '276011',
1173
+ // name: '',
1174
+ // email: 'testbitcoincoid@mailforspam.com',
1175
+ // profile_picture: null,
1176
+ // verification_status: 'unverified',
1177
+ // gauth_enable: true,
1178
+ // withdraw_status: '0'
1179
+ // }
1180
+ // }
1181
+ //
1182
+ const data = this.safeDict(response, 'return');
1183
+ const addresses = this.safeDict(data, 'address', {});
1184
+ const networks = this.safeDict(data, 'network', {});
1185
+ const addressKeys = Object.keys(addresses);
1186
+ const result = {
1187
+ 'info': data,
1188
+ };
1189
+ for (let i = 0; i < addressKeys.length; i++) {
1190
+ const marketId = addressKeys[i];
1191
+ const code = this.safeCurrencyCode(marketId);
1192
+ const address = this.safeString(addresses, marketId);
1193
+ if ((address !== undefined) && ((codes === undefined) || (this.inArray(code, codes)))) {
1194
+ this.checkAddress(address);
1195
+ let network = undefined;
1196
+ if (marketId in networks) {
1197
+ const networkId = this.safeString(networks, marketId);
1198
+ if (networkId.indexOf(',') >= 0) {
1199
+ network = [];
1200
+ const networkIds = networkId.split(',');
1201
+ for (let j = 0; j < networkIds.length; j++) {
1202
+ network.push(this.networkIdToCode(networkIds[j]).toUpperCase());
1203
+ }
1204
+ }
1205
+ else {
1206
+ network = this.networkIdToCode(networkId).toUpperCase();
1207
+ }
1208
+ }
1209
+ result[code] = {
1210
+ 'info': {},
1211
+ 'currency': code,
1212
+ 'address': address,
1213
+ 'network': network,
1214
+ 'tag': undefined,
1215
+ };
1216
+ }
1217
+ }
1218
+ return result;
1219
+ }
1019
1220
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1020
1221
  let url = this.urls['api'][api];
1021
1222
  if (api === 'public') {
1022
- url += '/' + this.implodeParams(path, params);
1223
+ const query = this.omit(params, this.extractParams(path));
1224
+ const requestPath = '/' + this.implodeParams(path, params);
1225
+ url = url + requestPath;
1226
+ if (Object.keys(query).length) {
1227
+ url += '?' + this.urlencodeWithArrayRepeat(query);
1228
+ }
1023
1229
  }
1024
1230
  else {
1025
1231
  this.checkRequiredCredentials();
@@ -5228,6 +5228,7 @@ class okx extends okx$1 {
5228
5228
  * @method
5229
5229
  * @name okx#fetchPositions
5230
5230
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
5231
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history history
5231
5232
  * @description fetch all open positions
5232
5233
  * @param {string[]|undefined} symbols list of unified market symbols
5233
5234
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5368,13 +5369,38 @@ class okx extends okx$1 {
5368
5369
  // "vegaBS": "",
5369
5370
  // "vegaPA": ""
5370
5371
  // }
5372
+ // history
5373
+ // {
5374
+ // "cTime":"1708351230102",
5375
+ // "ccy":"USDT",
5376
+ // "closeAvgPx":"1.2567",
5377
+ // "closeTotalPos":"40",
5378
+ // "direction":"short",
5379
+ // "fee":"-0.0351036",
5380
+ // "fundingFee":"0",
5381
+ // "instId":"SUSHI-USDT-SWAP",
5382
+ // "instType":"SWAP",
5383
+ // "lever":"10.0",
5384
+ // "liqPenalty":"0",
5385
+ // "mgnMode":"isolated",
5386
+ // "openAvgPx":"1.2462",
5387
+ // "openMaxPos":"40",
5388
+ // "pnl":"-0.42",
5389
+ // "pnlRatio":"-0.0912982667308618",
5390
+ // "posId":"666159086676836352",
5391
+ // "realizedPnl":"-0.4551036",
5392
+ // "triggerPx":"",
5393
+ // "type":"2",
5394
+ // "uTime":"1708354805699",
5395
+ // "uly":"SUSHI-USDT"
5396
+ // }
5371
5397
  //
5372
5398
  const marketId = this.safeString(position, 'instId');
5373
5399
  market = this.safeMarket(marketId, market);
5374
5400
  const symbol = market['symbol'];
5375
5401
  const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
5376
5402
  const contractsAbs = Precise["default"].stringAbs(pos);
5377
- let side = this.safeString(position, 'posSide');
5403
+ let side = this.safeString2(position, 'posSide', 'direction');
5378
5404
  const hedged = side !== 'net';
5379
5405
  const contracts = this.parseNumber(contractsAbs);
5380
5406
  if (market['margin']) {
@@ -5415,7 +5441,7 @@ class okx extends okx$1 {
5415
5441
  const notional = this.parseNumber(notionalString);
5416
5442
  const marginMode = this.safeString(position, 'mgnMode');
5417
5443
  let initialMarginString = undefined;
5418
- const entryPriceString = this.safeString(position, 'avgPx');
5444
+ const entryPriceString = this.safeString2(position, 'avgPx', 'openAvgPx');
5419
5445
  const unrealizedPnlString = this.safeString(position, 'upl');
5420
5446
  const leverageString = this.safeString(position, 'lever');
5421
5447
  let initialMarginPercentage = undefined;
@@ -5446,23 +5472,24 @@ class okx extends okx$1 {
5446
5472
  const marginRatio = this.parseNumber(Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4));
5447
5473
  return this.safePosition({
5448
5474
  'info': position,
5449
- 'id': undefined,
5475
+ 'id': this.safeString(position, 'posId'),
5450
5476
  'symbol': symbol,
5451
5477
  'notional': notional,
5452
5478
  'marginMode': marginMode,
5453
5479
  'liquidationPrice': liquidationPrice,
5454
5480
  'entryPrice': this.parseNumber(entryPriceString),
5455
5481
  'unrealizedPnl': this.parseNumber(unrealizedPnlString),
5482
+ 'realizedPnl': this.safeNumber(position, 'realizedPnl'),
5456
5483
  'percentage': percentage,
5457
5484
  'contracts': contracts,
5458
5485
  'contractSize': contractSize,
5459
5486
  'markPrice': this.parseNumber(markPriceString),
5460
- 'lastPrice': undefined,
5487
+ 'lastPrice': this.safeNumber(position, 'closeAvgPx'),
5461
5488
  'side': side,
5462
5489
  'hedged': hedged,
5463
5490
  'timestamp': timestamp,
5464
5491
  'datetime': this.iso8601(timestamp),
5465
- 'lastUpdateTimestamp': undefined,
5492
+ 'lastUpdateTimestamp': this.safeInteger(position, 'uTime'),
5466
5493
  'maintenanceMargin': maintenanceMargin,
5467
5494
  'maintenanceMarginPercentage': maintenanceMarginPercentage,
5468
5495
  'collateral': this.parseNumber(collateralString),
@@ -220,7 +220,7 @@ class hitbtc extends hitbtc$1 {
220
220
  'symbols': [market['id']],
221
221
  },
222
222
  };
223
- const orderbook = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
223
+ const orderbook = await this.subscribePublic(name, 'orderbooks', [symbol], this.deepExtend(request, params));
224
224
  return orderbook.limit();
225
225
  }
226
226
  handleOrderBook(client, message) {
@@ -249,13 +249,12 @@ class hitbtc extends hitbtc$1 {
249
249
  //
250
250
  const data = this.safeValue2(message, 'snapshot', 'update', {});
251
251
  const marketIds = Object.keys(data);
252
- const channel = this.safeString(message, 'ch');
253
252
  for (let i = 0; i < marketIds.length; i++) {
254
253
  const marketId = marketIds[i];
255
254
  const market = this.safeMarket(marketId);
256
255
  const symbol = market['symbol'];
257
256
  const item = data[marketId];
258
- const messageHash = channel + '::' + symbol;
257
+ const messageHash = 'orderbooks::' + symbol;
259
258
  if (!(symbol in this.orderbooks)) {
260
259
  const subscription = this.safeValue(client.subscriptions, messageHash, {});
261
260
  const limit = this.safeInteger(subscription, 'limit');
@@ -313,7 +312,7 @@ class hitbtc extends hitbtc$1 {
313
312
  'symbols': [market['id']],
314
313
  },
315
314
  };
316
- const result = await this.subscribePublic(name, 'ticker', [symbol], this.deepExtend(request, params));
315
+ const result = await this.subscribePublic(name, 'tickers', [symbol], this.deepExtend(request, params));
317
316
  return this.safeValue(result, symbol);
318
317
  }
319
318
  async watchTickers(symbols = undefined, params = {}) {
@@ -396,7 +395,6 @@ class hitbtc extends hitbtc$1 {
396
395
  //
397
396
  const data = this.safeValue(message, 'data', {});
398
397
  const marketIds = Object.keys(data);
399
- const channel = this.safeString(message, 'ch');
400
398
  const newTickers = {};
401
399
  for (let i = 0; i < marketIds.length; i++) {
402
400
  const marketId = marketIds[i];
@@ -405,8 +403,6 @@ class hitbtc extends hitbtc$1 {
405
403
  const ticker = this.parseWsTicker(data[marketId], market);
406
404
  this.tickers[symbol] = ticker;
407
405
  newTickers[symbol] = ticker;
408
- const messageHash = channel + '::' + symbol;
409
- client.resolve(newTickers, messageHash);
410
406
  }
411
407
  client.resolve(newTickers, 'tickers');
412
408
  const messageHashes = this.findMessageHashes(client, 'tickers::');
@@ -422,7 +418,6 @@ class hitbtc extends hitbtc$1 {
422
418
  client.resolve(tickers, messageHash);
423
419
  }
424
420
  }
425
- client.resolve(this.tickers, channel);
426
421
  return message;
427
422
  }
428
423
  parseWsTicker(ticker, market = undefined) {
@@ -503,7 +498,7 @@ class hitbtc extends hitbtc$1 {
503
498
  request['limit'] = limit;
504
499
  }
505
500
  const name = 'trades';
506
- const trades = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
501
+ const trades = await this.subscribePublic(name, 'trades', [symbol], this.deepExtend(request, params));
507
502
  if (this.newUpdates) {
508
503
  limit = trades.getLimit(symbol, limit);
509
504
  }
@@ -632,7 +627,7 @@ class hitbtc extends hitbtc$1 {
632
627
  if (limit !== undefined) {
633
628
  request['params']['limit'] = limit;
634
629
  }
635
- const ohlcv = await this.subscribePublic(name, name, [symbol], this.deepExtend(request, params));
630
+ const ohlcv = await this.subscribePublic(name, 'candles', [symbol], this.deepExtend(request, params));
636
631
  if (this.newUpdates) {
637
632
  limit = ohlcv.getLimit(symbol, limit);
638
633
  }
@@ -693,7 +688,7 @@ class hitbtc extends hitbtc$1 {
693
688
  for (let j = 0; j < ohlcvs.length; j++) {
694
689
  stored.append(ohlcvs[j]);
695
690
  }
696
- const messageHash = channel + '::' + symbol;
691
+ const messageHash = 'candles::' + symbol;
697
692
  client.resolve(stored, messageHash);
698
693
  }
699
694
  return message;