diff --git a/js/huobi.js b/js/huobi.js index 17404550ed12..d8d876525b02 100644 --- a/js/huobi.js +++ b/js/huobi.js @@ -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; diff --git a/js/pro/huobi.js b/js/pro/huobi.js index 3fd2423a6d52..422a8140f32f 100644 --- a/js/pro/huobi.js +++ b/js/pro/huobi.js @@ -15,11 +15,11 @@ module.exports = class huobi extends huobiRest { 'ws': true, 'watchOrderBook': true, 'watchOrders': true, - 'watchTickers': false, // for now + 'watchTickers': false, 'watchTicker': true, 'watchTrades': true, 'watchMyTrades': true, - 'watchBalance': true, // for now + 'watchBalance': true, 'watchOHLCV': true, }, 'urls': { @@ -89,6 +89,9 @@ module.exports = class huobi extends huobiRest { 'ws': { 'gunzip': true, }, + 'watchTicker': { + 'name': 'market.{marketId}.detail', // 'market.{marketId}.bbo' or 'market.{marketId}.ticker' + }, }, 'exceptions': { 'ws': { @@ -123,13 +126,19 @@ module.exports = class huobi extends huobiRest { await this.loadMarkets (); const market = this.market (symbol); symbol = market['symbol']; - const messageHash = 'market.' + market['id'] + '.detail'; + const options = this.safeValue (this.options, 'watchTicker', {}); + const topic = this.safeString (options, 'name', 'market.{marketId}.detail'); + if (topic === 'market.{marketId}.ticker' && market['type'] !== 'spot') { + throw new BadRequest (this.id + ' watchTicker() with name market.{marketId}.ticker is only allowed for spot markets, use market.{marketId}.detail instead'); + } + 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, @@ -145,6 +154,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'); @@ -1572,6 +1595,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, };