var bs = require('binarysearch'); var Gdax = require('gdax'); var orderBook = []; orderBook['bids'] = []; orderBook['bids']['price'] = []; orderBook['bids']['size'] = []; orderBook['asks'] = []; orderBook['asks']['price'] = []; orderBook['asks']['size'] = []; var wsGdax = new Gdax.WebsocketClient( ['BTC-EUR'], 'wss://ws-feed.gdax.com', null, {channels: ['level2', 'heartbeat']} ); function array_keys(input) { var output = []; 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