Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Trustless Developer Guide - 0
const BFX = require('bitfinex-api-node')
const { Order } = require('./node_modules/bitfinex-api-node/lib/models')
const bfx = new BFX({
apiKey: '',
apiSecret: '',
ws: {
autoReconnect: true,
seqAudit: false,
packetWDDelay: 10 * 1000,
manageOrderBooks: true,
transform: true,
url: 'wss://api.ethfinex.com/ws/2'
}
})
let pair = 'tETHUSD'
const ws = bfx.ws()
ws.on('error', (err) => console.log(err))
ws.on('open', () => {
console.log('open')
ws.subscribeOrderBook(pair)
})
ws.on('open', ws.auth.bind(ws))
ws.onOrderBook({ symbol: pair }, (ob) => {
// Your Trading Strategy Here
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment