|
1 | 1 | # BINANCE PERP L3 Order Book Estimator |
2 | 2 |
|
3 | | - |
| 3 | + |
4 | 4 |
|
5 | | -This project is a real-time visualization tool for the Binance perpetual swap order book. The tool uses L2 data's change in time to naively estimate a L3 order book microstructure. we can change to more complex model to estimate the L3 book later. |
| 5 | +This project is a high-performance real-time visualization tool for the Binance perpetual swap order book. It leverages **Execution-Aware Queue Dynamics (EAQD)** to estimate a Level 3 (L3) order book microstructure from Level 2 (L2) events and real-time trade streams, providing deep insights into order queue seniority and market participant behavior. |
6 | 6 |
|
7 | | -## Features |
| 7 | +## Key Features |
8 | 8 |
|
9 | | -* **Real-time Data**: Streams order book data using Binance's WebSocket API. |
10 | | -* **Bid/Ask Visualization**: Displays the current bids and asks for the binance perpetual swap. |
11 | | -* **Order Queue Estimation**: Estimates the order queue at each price level using L2 data. |
12 | | -* **Dynamic Bar Coloring**: Bid and ask bars are dynamically colored based on the age of the order. |
13 | | -* **K-Means Cluster**: Auto classification for different market participants |
| 9 | +* **Real-time Data Architecture**: Low-latency streaming of order book depth and trade events via Binance WebSocket API. |
| 10 | +* **Advanced L3 Estimation**: Moves beyond naive estimation to account for execution priority, cancellation behavior, and market regime. |
| 11 | +* **Microstructure Metrics Panel**: Dedicated real-time dashboard for high-resolution microstructure health indicators. |
| 12 | + * **Order-to-Trade Ratio (OTR)**: Tracks liquidity provision intensity at Top-1 and Top-20 levels. |
| 13 | + * **Cancellation-to-Trade Ratio (CTR)**: Monitors cancellation/spoofing velocity across sides. |
| 14 | +* **Dynamic Heatmap Visualization**: Standardized depth heatmap using Z-score normalization with interactive controls. |
| 15 | +* **Interactive Analytics**: Sweep/Liquidity-Cost windows with right-click drag-to-zoom and multi-axis rendering. |
| 16 | +* **K-Means Clustering**: Real-time classification of market participants based on order size and arrival patterns. |
14 | 17 |
|
15 | | -## Usage |
16 | | - |
17 | | -#### From Source |
| 18 | +## Technical Core |
18 | 19 |
|
19 | | -To try out the project, ensure you have Rust installed. You can install it from [https://www.rust-lang.org](https://www.rust-lang.org). |
| 20 | +The estimator utilizes several proprietary techniques to maintain a ground-truth-aligned L3 view: |
20 | 21 |
|
21 | | -1. Clone the repository: |
| 22 | +### 1. Execution-Aware Queue Dynamics (EAQD) |
| 23 | +Refined logic for inflow and outflow handling. Unlike static models, EAQD understands the difference between fills (FIFO consumption) and cancellations (LIFO/Priority-based reduction). |
22 | 24 |
|
23 | | -```bash |
24 | | -git clone https://github.com/OctopusTakopi/binance_l3_est.git |
25 | | -cd binance_l3_est |
26 | | -``` |
| 25 | +### 2. Deep Depth Fragmentation (DWF) |
| 26 | +Also known as Statistical Order Flow Profiling (SOFP). This system fragments large L2 liquidity additions into multiple virtual orders based on a rolling distribution of market trade sizes, preventing the "giant single order" bias in naive estimators. |
27 | 27 |
|
28 | | -2. Run the project with a trading pair of your choice: |
| 28 | +### 3. Marker-Triggered Queue Refining (MTQR) |
| 29 | +Integrates the `@trade` stream as a synchronization pulse. When a trade occurs at a specific price, MTQR validates the maker's size against our estimated queue. If a trade exceeds our front-of-queue estimate, the model "snaps" to the ground truth and adjusts seniority accordingly. |
29 | 30 |
|
30 | | -```bash |
31 | | -cargo run -r |
32 | | -``` |
| 31 | +### 4. Seniority Decay & Priority Reset |
| 32 | +Handles partial fills and order modifications. Partial fills retain their queue position, while modifications that increase size or change price trigger a priority reset, accurately reflecting exchange matching engine logic. |
33 | 33 |
|
34 | | -#### From Release Binary |
| 34 | +## Usage |
35 | 35 |
|
36 | | -Visit the [Releases page](https://github.com/OctopusTakopi/binance_l3_est/releases) and download the latest binary release. |
| 36 | +#### From Source |
37 | 37 |
|
38 | | -The chart dynamically updates as new WebSocket messages are received, and the bars for bids and asks are color-coded based on the order age, in K-means mode it based on the order size. |
| 38 | +Ensure you have Rust installed ([rust-lang.org](https://www.rust-lang.org)). |
39 | 39 |
|
40 | | -> **Note:** Allow enough time for the estimator to start working as it processes the historical L2 data. |
| 40 | +1. Clone the repository: |
| 41 | + ```bash |
| 42 | + git clone https://github.com/OctopusTakopi/binance_l3_est.git |
| 43 | + cd binance_l3_est |
| 44 | + ``` |
| 45 | + |
| 46 | +2. Run the project: |
| 47 | + ```bash |
| 48 | + cargo run -r |
| 49 | + ``` |
| 50 | + |
| 51 | +#### UI Controls |
| 52 | +* **Microstructure Toggle**: Use the UI panel to enable/disable the OTR/CTR dashboard. |
| 53 | +* **Heatmap Z-Score**: Adjust the standardization slider to highlight liquidity outliers. |
| 54 | +* **Zoom**: Right-click and drag on the liquidity charts to inspect specific price ranges. |
41 | 55 |
|
42 | 56 | ## License |
43 | 57 |
|
|
0 commit comments