Created
September 24, 2018 13:18
-
-
Save plutoegg/089ae44a88b8d76ff4337abfca9df107 to your computer and use it in GitHub Desktop.
Trustless Developer Guide - 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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