diff --git a/app.js b/app.js new file mode 100644 index 0000000..680f62d --- /dev/null +++ b/app.js @@ -0,0 +1,108 @@ +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