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

Is futures websocket stream not implemented? #46

Closed
SpaceMonkeyForever opened this issue Aug 10, 2022 · 10 comments
Closed

Is futures websocket stream not implemented? #46

SpaceMonkeyForever opened this issue Aug 10, 2022 · 10 comments

Comments

@SpaceMonkeyForever
Copy link

I see the endpoint is available in the code but it is not used anywhere, spot endpoint is used by default in connect and connect_multiple.

@fdary
Copy link

fdary commented Aug 11, 2022

I think it's not implemented. I also need this feature, and I am currently working on it.

It's going smooth so far, but it will still take some time to do it right, especially since I'm new with Rust.

@SpaceMonkeyForever
Copy link
Author

I actually managed to get it working yesterday by just changing the URL.

However, I didn't have time to look into whether the library is building the orderbook from deltas or just getting the entire orderbook every time because that wouldn't be very efficient. Do you know? I don't even know if Binance supports sending orderbook deltas to avoid sending the entire book every 100 ms

@fdary
Copy link

fdary commented Aug 12, 2022

I don't use the orderbooks in my application. Fom what I understood you can ask for the orderbook of a market, specifying the depth you want, and after that you can subscribe to a websocket that will send you new additions to the order book in real time. You are supposed to match the orders yourself.

@Igosuki
Copy link
Owner

Igosuki commented Oct 18, 2022

Hi, sorry for the long delay, I was unavailable.
Futures need some work to work properly.

In spot, binance offers two modes for orderbooks, one with deltas and one where you get updates every 100ms. It maybe your opinion that getting ticks for orderbooks is overkill, however you will find that maintaining an orderbook from deltas is quite the headache because of failure management.

If you'd like example/library code for orderbook management specifically we can work on that.

@CodeForcer
Copy link

CodeForcer commented Jan 3, 2023

however you will find that maintaining an orderbook from deltas is quite the headache because of failure management.

@Igosuki is there a better way than just refreshing the book from a new snapshot when you miss a delta, it doesn't seem to happen often to me?

I'm using the following flow in general for Binance:

  1. Start buffering deltas into a channel BEFORE I take a snapshot
  2. Initiate the data structure for the orderbook from a snapshot
  3. Start updating from deltas and just discard deltas which are pre-snapshot timestamp
  4. If there is some count or timestamp mismatch on the incoming delta then refresh the snapshot and continue

It would be great to see a suggested example implementation though in this library of following the futures orderbooks. I've had to write my own implementation by hacking together logic from this package and binance-rs as I couldn't get it to work either. Also re-initiating on failure can make the data collection for backtesting buggy

@Igosuki
Copy link
Owner

Igosuki commented Feb 16, 2023

Ideally, you'll manage fault tolerance with having multiple websocket streams up, and a way to realign your data with live data in case the main data stream fails.
Each stream has to monitor update ids and they have to be continuous, if they aren't, the stream should go into failure and restart.

I have code from last year I can rework to match this spec, it's not complicated.

@zelenij
Copy link

zelenij commented Aug 16, 2023

Hi @Igosuki are futures coming to the library?

Also, I can see that Binance allows live subscription/unsubscription to new instruments for depth, for example:

https://binance-docs.github.io/apidocs/spot/en/#live-subscribing-unsubscribing-to-streams

However this doesn't seem to be supported in the library.

I'm quite happy to help with the coding, in needed :)

@Igosuki
Copy link
Owner

Igosuki commented Aug 17, 2023 via email

@zelenij
Copy link

zelenij commented Aug 18, 2023

Hasn't it been published and in use for quite a bit? The .NET library has had support for futures for awhile now.

Also, the "dynamic subscription" support sounds like an easy win. Without it, if you want to subscribe to more/fewer instruments with this library, you have to recreate the web sockets (unless I'm missing something?)

@Igosuki
Copy link
Owner

Igosuki commented Jan 19, 2024

The latest PRs added support for futures websocket streaming

@Igosuki Igosuki closed this as completed Jan 19, 2024
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

5 participants