bitfinexcom / bitfinex-api-node

BITFINEX NodeJS trading API - Bitcoin, Litecoin, and Ether exchange
https://www.bitfinex.com/
MIT License
462 stars 213 forks source link

Breaking change in trades subscription #517

Closed wierzbix83 closed 4 years ago

wierzbix83 commented 4 years ago

Issue type

Brief description

Since 4.0.2 subscribing to trades with symbol tBTCUSD no longer works, instead I need to use BTCUSD which is inconsistent with for example candles trades trade:1m:tBTCUSD. Are you planning to fix it more make more changes in symbols?

https://github.com/bitfinexcom/bitfinex-api-node/compare/v3.0.2...4.0.2

Steps to reproduce

Execute following with 3.0.2 version and then upgrade to later versions and see that there is a change in symbols for trades

'use strict'

process.env.DEBUG = 'bfx:examples:*'

const debug = require('debug')('bfx:examples:ws2-manager')

const Manager = require('bitfinex-api-node/lib/ws2_manager')

const m = new Manager({
    //autoReconnect: true,
    seqAudit: true,
    //packetWDDelay: 10 * 1000,
    transform: true,
    //manageCandles: false
  })

debug('fetching symbol details...')

  const symbols = ['tBTCUSD', 'fUSD', 'BTCUSD']

  m.on('error', (err) => {
    debug('error: %s', err)
  })

  m.once('open', () => {
    debug('open')

    symbols.forEach(symbol => {
      m.subscribeTrades(symbol)
      m.onTrades({ symbol }, (trades) => {
        debug('recv %d trades on channel %s, content %s', trades.length, symbol, JSON.stringify(trades))
      })
    })

  })

  m.openSocket()
Additional Notes:

-

f3rno commented 4 years ago

Fixed by https://github.com/bitfinexcom/bitfinex-api-node/pull/524