Commit 2bf4266
fix(events): Fix order event data structure mismatches across event handlers
Fixed critical issues where event handlers were expecting different data structures
than what was being emitted, causing order fill detection to fail:
OrderManager tracking.py:
- Added order_id directly to event payload for backward compatibility
- Modified fill_handler and terminal_handler to check both event_data.get("order_id")
and event_data.get("order").id to handle different event structures
- Ensures bracket orders and other wait_for_fill patterns work correctly
RiskManager managed_trade.py:
- Changed from listening to ORDER_MODIFIED to ORDER_FILLED/CANCELLED/REJECTED
- ORDER_MODIFIED is for parameter changes (stop loss, limit price modifications)
- ORDER_FILLED/terminal events are for status changes (fills, cancellations)
- Updated handlers to use same pattern as OrderManager for consistency
This fixes the bracket order fill detection timeout issue where orders were
actually filling but the event wasn't being properly detected.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 732e8e9 commit 2bf4266
File tree
2 files changed
+55
-19
lines changed- src/project_x_py
- order_manager
- risk_manager
2 files changed
+55
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
401 | | - | |
402 | | - | |
403 | | - | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
404 | 412 | | |
405 | 413 | | |
406 | 414 | | |
407 | 415 | | |
408 | 416 | | |
409 | | - | |
410 | | - | |
411 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
412 | 427 | | |
413 | 428 | | |
414 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
| 636 | + | |
637 | 637 | | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
642 | 648 | | |
643 | 649 | | |
644 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
645 | 663 | | |
646 | 664 | | |
647 | 665 | | |
648 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
649 | 669 | | |
650 | 670 | | |
651 | 671 | | |
652 | 672 | | |
653 | 673 | | |
654 | 674 | | |
655 | 675 | | |
656 | | - | |
657 | | - | |
| 676 | + | |
658 | 677 | | |
659 | 678 | | |
660 | | - | |
| 679 | + | |
661 | 680 | | |
662 | | - | |
663 | | - | |
664 | | - | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
665 | 686 | | |
666 | 687 | | |
667 | 688 | | |
| |||
0 commit comments