binance-exchange/node-binance-api

Exchange data chart type

amelenetwork opened this issue ยท 5 comments

Hello there !

I need help again.. I hope you can answer...

https://prnt.sc/ioga36

Which chart is this ? Highchart or what ? Where can i found this chart sources ? I want to build same as like this look for mobile resolutions .

What is your ideas fellows ?

Thank you for sharing.

This is kline: https://github.com/chxj1992/kline
I have code to make it work with this library. My version uses PHP to get around CORS security issues

image

image

Thank you so much....

no problem, there are two undocumented built-in functions in this library that are very useful for charting.
.highstock(chart) will return the data in array format [open, high, low, close, volume]
.ohlc(chart) will return the data in object format .open .high .low .close .volume

        // convert chart data to highstock array [timestamp,open,high,low,close]
        highstock: function(chart, include_volume = false) {
            let array = [];
            for ( let timestamp in chart ) {
                let obj = chart[timestamp];
                let line = [
                    Number(timestamp),
                    parseFloat(obj.open),
                    parseFloat(obj.high),
                    parseFloat(obj.low),
                    parseFloat(obj.close)
                ];
                if ( include_volume ) line.push(parseFloat(obj.volume));
                array.push(line);
            }
            return array;
        },
        ohlc: function(chart) {
            let open = [], high = [], low = [], close = [], volume = [];
            for ( let timestamp in chart ) { //ohlc[symbol][interval]
                let obj = chart[timestamp];
                open.push(parseFloat(obj.open));
                high.push(parseFloat(obj.high));
                low.push(parseFloat(obj.low));
                close.push(parseFloat(obj.close));
                volume.push(parseFloat(obj.volume));
            }
            return {open:open, high:high, low:low, close:close, volume:volume};
        },