Market Depth Chart - Total Orders
amelenetwork opened this issue · 4 comments
Hello there...
This is not looks like issue but I don't know how can I do that . I hope anybody can answer to me.
On binance.com web site there is showing Depth Chart, there is total orders explaining on chart . You can check screen shot .
I need like this chart , Im getting data with;
binance.websockets.depthCache('BTCUSDT', (symbol, depth) => {
......
......
});
But there is answer just price and quantity orders .
I'i doing SUM all BID or ASK orders then , step by step MINUS last one BACK to FORWARD .
It's looks like for me very "primitive" . Not looks like instant and taking time and cost .
Is there any good and modern option to get data MARKET DEPTH CHART ?
How can i do that ?
Thank you so much....
For this type of chart bids/asks are cumulative. So you add the btc value
I have a websocket function to return the values in cumulative format
I get the data like this:
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:bids, asks:asks};
// save information to json file
file.writeFile("json/depth/"+symbol+".json", JSON.stringify(output, null, 4), (err)=>{});
});
You are amazing my friend .
Thank you so much !
Good luck!
I just realized highcharts data needs to be in array format
So you will need to do this instead:
let output = {bids:binance.array(bids), asks:binance.array(asks)};
Thank you my friend .
i appreciate your help !