var bs = require('binarysearch'); var Gdax = require('gdax'); var orderBook = { bids: {}, asks: {} }; var wsGdax = new Gdax.WebsocketClient( ['BTC-EUR'], 'wss://ws-feed.gdax.com', null, {channels: ['level2', 'heartbeat']} ); function array_keys(input) { var output = new Array(); var counter = 0; for (i in input) { output[counter++] = i; } return output; } wsGdax.on('message', function(data) { if(data.type === 'snapshot') { // save snapshot on orderBook object for(var i=0; i