tardis-dev / tardis-machine

Locally runnable server with built-in data caching, providing both tick-level historical and consolidated real-time cryptocurrency market data via HTTP and WebSocket APIs
https://docs.tardis.dev/api/tardis-machine
Mozilla Public License 2.0
235 stars 46 forks source link

Set exchange update speed for receiving Diff. Book Depth Streams #4

Closed evgenyfedorenko closed 2 years ago

evgenyfedorenko commented 3 years ago

Looks like there is no way right now to configure update speed for exchanges. For instance binance gives an option to specify that https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams. I know there is a way to keep a local copy of book via computeBookSnapshots. But that will give me the message type book_snapshot and I need to limit the book size explicitly which I can not do. Is there way to let's say have messages type book_change every 250ms ? Thanks

thaaddeus commented 3 years ago

Hi, it's not supported right now, but pull requests are welcome.

evgenyfedorenko commented 3 years ago

What is the expectation for this change? Should BookChange type accept optional param 'interval' and accumulate changes based on it and yield only after that interval? Or we should it be an optional 'depth' param in BookSnapshot type so that it can contain entire book?

thaaddeus commented 3 years ago

I guess it should be one of computables in tardis-dev lib and then exposed via tardis-machine, so you'd be doing smth similar to what book snapshots logic does, but not compute snapshots just aggregate book_change messages by time, but frankly wouldn't it be easier to be done client side? You could buffer book_change messages by certain amount of time and then process as batch.