flashnuke / BinanceExtensionCPP

An extension for the API of Binance (https://www.binance.com/)
GNU General Public License v3.0
14 stars 4 forks source link

Creating user data stream #57

Open gitkornel opened 3 years ago

gitkornel commented 3 years ago

Hello, I've been wondering how can you create a user data listen stream?

There is no example and quite didn't understand the code.

What I came up to (but doesn't compile neither works):

SomeFunctor ws_stream_read{};
std::string cust_stream = "fapi/v1/listenKey";
std::thread t1(&FuturesClientUSDT::stream_userStream<SomeFunctor>, cust_stream, std::ref(ws_stream_read.msg_buffer), std::ref(ws_stream_read));
t1.join();

Any ideas?

Best Regards.

flashnuke commented 3 years ago

You are attempting to send a custom stream name into a userStream method that is not a custom stream. Also, in general, if you do want to start a user stream by using the custom stream method, the name should be in this case the listen key.

I've created the following example to illustrate how to start a user stream - https://github.com/adanikel/BinanceExtensionCPP/blob/master/examples/futures_user_stream.cpp

tested and works for me (futures account)

let me know if that helps @gitkornel

gitkornel commented 3 years ago

You are attempting to send a custom stream name into a userStream method that is not a custom stream. Also, in general, if you do want to start a user stream by using the custom stream method, the name should be in this case the listen key.

I've created the following example to illustrate how to start a user stream - https://github.com/adanikel/BinanceExtensionCPP/blob/master/examples/futures_user_stream.cpp

tested and works for me (futures account)

let me know if that helps @gitkornel

Hello, it doesn't do anything, doesn't print.

I copied the exact code from the example.

flashnuke commented 3 years ago

If you copied the exact snippet it should work.

The user stream only pushes updates when there are updates to push, such as new orders.

Try cancelling / opening a new FUTURES USDT order and see if an update goes through. Also make sure the key is supporting futures trading.