Problem Statement
Orderbook data is a rich source of information often containing elements that can predict future market shifts. Few tools for traders exist to visualize and interpret this information however.
What I Built
bookedblocks is a low latency orderbook visualizer running in the terminal that reads data from Kraken's Websocket APIs and splats it onto the screen in real time. Traders that need the right information, right away and before the trade happens should love it!
Key Features
When running, the application pulls data from the Kraken API in the background and shows 4 elements for the selected ticker:
- Order Map: A main central heat map with time on the x axis and price on the y axis. Volume is encoded through color intensity.
- Order Volumes: A projection onto the time axis of the heat map reading as booked volume over time.
- Depth: A projection onto the price axis reading as current market depth.
- A snapshot of the current status using the ticker information.
Technical Highlights
bookedblocks is a rust project for maximum speed and robustness in the terminal.
The various capabilities of the application are based on different open source technologies:
- tokio: for the asynchronous runtime and managing threads
- ratatui: as a TUI library for handling rendering data to the screen
- kraken_async_rs: for facilitating websocket connections to the Kraken API
bookedblocks is technically unique thanks to these implementations:
- a live websocket feed to Kraken's API that sends and receives information in different threads
- a book caching system that is continuously indexed thanks to red-black trees in both time and price
- a processing pipeline based on gaussian splatting allowing for grids independent of book levels and quantities
- an adaptive UI that charts data as it comes in
- a microservice like architecture with a central dispatch that can accommodate more functionalities when needed
How it works
bookedblocks is an asynchronous application where separation of concerns is hopefully enforced through the separation of threads:
- A main dispatcher thread serves to orchestrate different parts of the application together. This is the first thread that gets launched in the entrypoint.
- A data thread takes care of keeping the websocket connection alive and appending to an internal cache.
- Pipeline threads process the cached data and prepares it for updating the UI.
- A UI thread renders the data and runs the screen update loop.
The entire application is written in rust and integrates with cargo. To run it from the origin of the project simply run `cargo run -- Ticker/Pair` with the ticker to visualize.
Demo & Documentation
GitHub repo: https://github.com/julienfausty/bookedblocks
Demo: https://youtu.be/2s7JDBGHi18?si=IH47iTb58EPFlFb8
Future Enhancements
- Make the UI more interactive and informative: create a Ticker search page and tabs for possibly opening up multiple books in the same session. The logs generated by the inform and warn actions are not yet setup and would be great to show to the user.
- Explore: Pan and zoom over time and price through interactive options
- Customize: Create a menu for customizing the application parameters and theme
- Move out of the terminal: the ratatui library is experimenting with web suport https://ratatui.rs/ecosystem/ratzilla/ and bookedblocks could too be bringing speed and robustness to the web
- Parallelize pipeline: current data processing pipeline is written in serial and could be much more efficient if parallelized using something like rayon ( https://docs.rs/rayon/latest/rayon/ )
- Integrate REST API: On application startup the application could query for historical orderbook data to fill up the interface immediately