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

Futures websockets and REST APIs #42

Open
rodenwild opened this issue Jul 24, 2021 · 5 comments
Open

Futures websockets and REST APIs #42

rodenwild opened this issue Jul 24, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@rodenwild
Copy link

rodenwild commented Jul 24, 2021

Thanks for the great repo, I relatively new to C++, coming from python, is there any simple way to implement futures into both websockets and the REST API? Or any example codes you may have?

@niXman
Copy link
Owner

niXman commented Jul 26, 2021

please provide a link to the docs you are talking about.

@rodenwild
Copy link
Author

https://binance-docs.github.io/apidocs/futures/en/#change-log

Spot websocket URL: wss://stream.binance.com:9443/ws/btcusdt@kline_5m
Futures websocket URL: wss://fstream.binance.com/ws/btcusdt@kline_5m

@niXman
Copy link
Owner

niXman commented Jul 27, 2021

git it.
looks like a huge piece of work that I'm not ready to take on now.

@niXman niXman added the enhancement New feature or request label Aug 21, 2021
@alex290
Copy link

alex290 commented Apr 1, 2022

fstream.binance.com - port 443. I don't know why this is not in the documentation

@damian123
Copy link

fstream.binance.com - port 443. I don't know why this is not in the documentation

The futures stream sends messages in a slightly different format, so it does not work.

Here is what happens if I run the main.cpp in websockets

binapi/src/websocket.cpp(346): binapi/include/binapi/flatjson.hpp(1456): key not found
Raw JSON causing error: {"e":"trade","E":1712555891750,"T":1712555891750,"s":"BTCUSDT","t":4847858716,"p":"69723.00","q":"0.020","X":"MARKET","m":false}

I add an extra line in websockets.cpp

try {
                message_type message = message_type::construct(json);
                return cb(nullptr, 0, std::string{}, std::move(message));
            } catch (const std::exception &ex) {
                std::fprintf(stderr, "%s: %s\n", __MAKE_FILELINE, ex.what());
                std::fprintf(stderr, "Raw JSON causing error: %s\n", ptr);         // <-------
                std::fflush(stderr);
            }

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

No branches or pull requests

4 participants