Last active
October 6, 2019 03:06
-
-
Save modster/057c44412439659fa77191cd03ad6a60 to your computer and use it in GitHub Desktop.
Highchart market depth binance-node-api
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
// by jaggedsoft https://github.com/binance-exchange/node-binance-api/issues/111#issuecomment-370715955 | |
const file = require('fs'); | |
binance.websockets.depthCache(['BTCUSDT','BNBBTC'], (symbol, depth) => { | |
const limit = 1000; | |
let bids = binance.sortBids(depth.bids, limit, 'cumulative'); | |
let asks = binance.sortAsks(depth.asks, limit, 'cumulative'); | |
console.log(symbol+" depth cache update"); | |
console.log("best bid: "+binance.first(bids)); | |
console.log("best ask: "+binance.first(asks)); | |
let output = {bids:binance.array(bids), asks:binance.array(asks)}; | |
// save information to json file | |
file.writeFile("json/depth/"+symbol+".json", JSON.stringify(output, null, 4), (err)=>{}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment