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

TypeError: bfx.ws is not a function #301

Closed Alonzo-Coeus closed 6 years ago

Alonzo-Coeus commented 6 years ago

I have been having an issue in my trading bot with instantiating a connection. This problem started recently, after upgrading to the new version my main bot worked for a while but has now completely broken.

I have some example code so someone can point out what i need to change to get my bots up again.

const BFX = require('bitfinex-api-node')

const API_KEY = '', API_SECRET = '', WS_URL = 'wss://api.bitfinex.com/ws/2'

const bfx = new BFX({
  apiKey: API_KEY,
  apiSecret: API_SECRET,

  ws: {
    url: WS_URL
  }
})

const ws = bfx.ws(2)

ws.on('open', () => {
  debug('open')
  ws.subscribeTrades('tBTCUSD')
})

ws.onTradeEntry({ pair: 'BTCUSD' }, (trade) => {
  console.log('te: %j', trade)
})

ws.onTradeUpdate({ pair: 'BTCUSD' }, (trade) => {
  console.log('tu: %j', trade)
})

ws.onTrades({ pair: 'BTCUSD' }, (trades) => {
    console.log('trades: %j', trades)
})
f3rno commented 6 years ago

@Alonzo-Coeus hmm, which version of bitfinex-api-node do you have in your package.json?

f3rno commented 6 years ago

I'm closing this as it shouldn't be happening with the latest 2.0.0-beta.1 (or the prev 2.0.0-beta). If you can confirm it occurs with an updated copy of the library, please re-open.