Commit 27b1ee6
fix(orderbook): comprehensive fixes for Level 2 orderbook functionality
Fixed critical issues with orderbook data processing and examples:
## Core Fixes
- Fixed DataFrame update issue in realtime.py where new DataFrames weren't properly reassigned
- Fixed contract ID matching by using instrument.id instead of symbol in TradingSuite
- Added volume tracking to memory stats in trade processing
- Added parameter acknowledgment for API compatibility
## Analytics Enhancements
- Enhanced get_orderbook_depth to return total bid/ask volumes
- Completely rewrote get_statistics method with comprehensive metrics:
- Added proper volume calculations for bid/ask sides
- Added trade statistics (buy/sell trades, avg trade size)
- Added VWAP calculation from tracked numerator/denominator
- Added session high/low tracking from trade history
- Fixed mid price calculation fallback
- Added market_depth_score calculation
## Example Fixes
- Fixed examples to only use methods that actually exist
- Corrected parameter names (time_window_minutes vs window_minutes)
- Removed calls to non-existent methods:
- get_order_flow_imbalance (replaced with get_cumulative_delta)
- estimate_market_impact (replaced with get_orderbook_depth)
- Fixed detect_order_clusters parameters
- Added new comprehensive example (06_advanced_orderbook.py)
## Results
All orderbook methods now work correctly with proper data:
- Market imbalance and depth analysis
- Volume profile with Point of Control
- Iceberg and cluster detection
- Trade flow and cumulative delta
- Support/resistance levels
- Comprehensive statistics with VWAP
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent e980229 commit 27b1ee6
File tree
5 files changed
+622
-54
lines changed- examples
- src/project_x_py
- orderbook
5 files changed
+622
-54
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
196 | 200 | | |
197 | 201 | | |
198 | 202 | | |
199 | 203 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
214 | 228 | | |
215 | 229 | | |
216 | 230 | | |
| |||
295 | 309 | | |
296 | 310 | | |
297 | 311 | | |
298 | | - | |
299 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
300 | 315 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
310 | 330 | | |
311 | 331 | | |
312 | 332 | | |
| |||
412 | 432 | | |
413 | 433 | | |
414 | 434 | | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | 435 | | |
429 | 436 | | |
430 | 437 | | |
| |||
492 | 499 | | |
493 | 500 | | |
494 | 501 | | |
495 | | - | |
496 | | - | |
497 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
498 | 508 | | |
499 | | - | |
| 509 | + | |
500 | 510 | | |
501 | 511 | | |
502 | 512 | | |
| |||
0 commit comments