Skip to content

Instantly share code, notes, and snippets.

@plutoegg
Created September 24, 2018 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plutoegg/089ae44a88b8d76ff4337abfca9df107 to your computer and use it in GitHub Desktop.
Save plutoegg/089ae44a88b8d76ff4337abfca9df107 to your computer and use it in GitHub Desktop.
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