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

Websocket - Binance Websocket.chart is not working 2024 #903

Open
jhonyjss opened this issue Jan 11, 2024 · 3 comments
Open

Websocket - Binance Websocket.chart is not working 2024 #903

jhonyjss opened this issue Jan 11, 2024 · 3 comments

Comments

@jhonyjss
Copy link

`
const binance = new Binance().options({
APIKEY: apiKey,
APISECRET: apiSecret,
useServerTime: true
});

binance.websockets.chart(
"BTCUSDT",
"1m",
(symbol, interval, chart) => {
console.info(chart);
}
);`

  • For some reason that I don;t know this is not working as before:

result: {}

Can you please check what's wrong ?

@vitaly-t
Copy link

vitaly-t commented Feb 6, 2024

Same here, just tried to use it, but the callback is streaming back the symbol string, not the data.

@jhonyjss Were you able to get to the bottom of it or find an alternative?

@jhonyjss
Copy link
Author

jhonyjss commented Feb 6, 2024

Hi @vitaly-t , I didn't find any alternative yet. let's watch together.

@vitaly-t
Copy link

vitaly-t commented Feb 6, 2024

@jhonyjss Thank you for coming back to me on this!

After poking around with the API, I found that futuresCandlesticks works and gives me exactly what I wanted - socket subscription for candle updates, which is essentially the same stuff you would expect for the charting data.

            ['1m', '3m', '5m'].forEach(i => {
                const endpoint = binance.futuresCandlesticks('BTCUSDT', i, c => {
                    if (c.k.x) {
                        // candle has been closed, time to update:
                        this.updateCandles(i, {
                            open: c.k.o,
                            close: c.k.c,
                            high: c.k.h,
                            low: c.k.l,
                            openTime: c.k.t,
                            closeTime: c.k.T,
                            volume: c.k.v,
                            tradesCount: c.k.n
                        });
                    }
                });
                this.socketEndpoints.push(endpoint); // save the endpoint, to close later
            });

P.S. I work with Binance Futures only, I'm not interested in Spot stuff 😸

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