Skip to content

Commit

Permalink
fix #16009
Browse files Browse the repository at this point in the history
  • Loading branch information
pcriadoperez committed Dec 25, 2022
1 parent d3ce5ff commit 4413a9d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
13 changes: 12 additions & 1 deletion js/huobi.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,9 +1766,20 @@ module.exports = class huobi extends Exchange {
// askSize: 0.4156
// }
//
// watchTikcer - bbo
// {
// seqId: 161499562790,
// ask: 16829.51,
// askSize: 0.707776,
// bid: 16829.5,
// bidSize: 1.685945,
// quoteTime: 1671941599612,
// symbol: 'btcusdt'
// }
//
const marketId = this.safeString2 (ticker, 'symbol', 'contract_code');
const symbol = this.safeSymbol (marketId, market);
const timestamp = this.safeInteger (ticker, 'ts');
const timestamp = this.safeInteger2 (ticker, 'ts', 'quoteTime');
let bid = undefined;
let bidVolume = undefined;
let ask = undefined;
Expand Down
21 changes: 20 additions & 1 deletion js/pro/huobi.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ module.exports = class huobi extends huobiRest {
'ws': {
'gunzip': true,
},
'watchTickerTopic': 'market.{marketId}.detail', // 'market.{marketId}.bbo' or 'market.{marketId}.ticker'
},
'exceptions': {
'ws': {
Expand Down Expand Up @@ -123,13 +124,15 @@ module.exports = class huobi extends huobiRest {
await this.loadMarkets ();
const market = this.market (symbol);
symbol = market['symbol'];
const messageHash = 'market.' + market['id'] + '.detail';
const topic = this.safeString (this.options, 'watchTickerTopic', 'market.{marketId}.detail');
const messageHash = this.implodeParams (topic, { 'marketId': market['id'] });
const url = this.getUrlByMarketType (market['type'], market['linear']);
return await this.subscribePublic (url, symbol, messageHash, undefined, params);
}

handleTicker (client, message) {
//
// 'market.btcusdt.detail'
// {
// ch: 'market.btcusdt.detail',
// ts: 1583494163784,
Expand All @@ -145,6 +148,20 @@ module.exports = class huobi extends huobiRest {
// count: 265673
// }
// }
// 'market.btcusdt.bbo'
// {
// ch: 'market.btcusdt.bbo',
// ts: 1671941599613,
// tick: {
// seqId: 161499562790,
// ask: 16829.51,
// askSize: 0.707776,
// bid: 16829.5,
// bidSize: 1.685945,
// quoteTime: 1671941599612,
// symbol: 'btcusdt'
// }
// }
//
const tick = this.safeValue (message, 'tick', {});
const ch = this.safeString (message, 'ch');
Expand Down Expand Up @@ -1572,6 +1589,8 @@ module.exports = class huobi extends huobiRest {
'depth': this.handleOrderBook,
'mbp': this.handleOrderBook,
'detail': this.handleTicker,
'bbo': this.handleTicker,
'ticker': this.handleTicker,
'trade': this.handleTrades,
'kline': this.handleOHLCV,
};
Expand Down

0 comments on commit 4413a9d

Please sign in to comment.