Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get historical Candle stick Data #893

Open
Mas313 opened this issue Jun 20, 2023 · 1 comment
Open

Get historical Candle stick Data #893

Mas313 opened this issue Jun 20, 2023 · 1 comment

Comments

@Mas313
Copy link

Mas313 commented Jun 20, 2023

I a using following code to get real-time candlestick data as long as the candle closes each minute

binance.websockets.candlesticks([trading_pair], "1m", (candlesticks) => {    
    let { e:eventType, E:eventTime, s:symbol, k:ticks } = candlesticks;
    let { o:open, h:high, l:low, c:close, v:volume, n:trades, i:interval, x:isFinal, q:quoteVolume, V:buyVolume, Q:quoteBuyVolume } = ticks;

I get here also 7 to 8 packets of candlestick data when candle is not closed along with last packet containing candle close price.
How I can modify the above code to get last say 100 candles close data when I start script for the first time then I can use above code to get the current candle close data.

@GTedZ
Copy link

GTedZ commented Jul 1, 2023

You need to use the binance.candlestick() function with a limit of 100 to get the current candlestick and the last 99, but the problem is, I tried using it, I was actually unable to get it to work.
Try using my library binance-lib instead, I'm working on v3.0.0 currently, which is coming out in the coming days. It has intellisense documentation for everything too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants