Commit aa05ca1
feat(order-management): comprehensive order tracking and management improvements
## Key Improvements
### Real-time Order Tracking
- Fix WebSocket payload parsing to handle ProjectX Gateway format {'action': X, 'data': {...}}
- Add automatic connection and subscription to user updates in OrderManager.initialize()
- Implement intelligent cache lookup with retry logic for real-time updates
- Fix string/integer type conversion issue in cache lookups
### Custom Tag Management
- Fix bracket order custom tag duplicate errors by generating unique timestamp-based tags
- Only include customTag in API payload when provided (not null/empty)
- Prevent "already in use" errors with automatic unique tag generation
### Enhanced Cleanup & Safety
- Implement comprehensive cleanup that cancels ALL open orders (not just demo orders)
- Add automatic position closing with market orders during cleanup
- Improve error handling and logging throughout cleanup process
- Provide detailed status reporting of cleanup operations
### Improved User Experience
- Add intelligent fallback from real-time cache to API for order status
- Enhance monitoring with detailed order and position status display
- Improve status messages to show data source (cache vs API)
- Add comprehensive order statistics and tracking information
### Performance Optimizations
- Real-time WebSocket order tracking instead of polling APIs
- Built-in retry logic for cache population timing
- Efficient payload extraction and processing
- Reduced API calls through intelligent caching
## Technical Details
- All orders now properly tracked in real-time cache with status updates
- WebSocket connection automatically established and maintained
- Bracket orders work reliably without custom tag conflicts
- Enhanced cleanup ensures no orphaned orders or positions
- Comprehensive error handling with graceful fallbacks
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 9babaf2 commit aa05ca1
File tree
2 files changed
+162
-35
lines changed- examples
- src/project_x_py
2 files changed
+162
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
61 | | - | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
74 | 88 | | |
75 | 89 | | |
76 | 90 | | |
| |||
327 | 341 | | |
328 | 342 | | |
329 | 343 | | |
| 344 | + | |
330 | 345 | | |
331 | 346 | | |
332 | 347 | | |
| |||
341 | 356 | | |
342 | 357 | | |
343 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
344 | 369 | | |
345 | 370 | | |
346 | 371 | | |
347 | 372 | | |
348 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
349 | 391 | | |
350 | 392 | | |
351 | | - | |
| 393 | + | |
352 | 394 | | |
353 | 395 | | |
354 | 396 | | |
| |||
365 | 407 | | |
366 | 408 | | |
367 | 409 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
373 | 414 | | |
374 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
375 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
376 | 435 | | |
377 | | - | |
| 436 | + | |
| 437 | + | |
378 | 438 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
387 | 453 | | |
388 | | - | |
| 454 | + | |
389 | 455 | | |
390 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
391 | 461 | | |
392 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
393 | 465 | | |
394 | 466 | | |
395 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
161 | 177 | | |
162 | 178 | | |
163 | 179 | | |
| |||
187 | 203 | | |
188 | 204 | | |
189 | 205 | | |
190 | | - | |
191 | | - | |
| 206 | + | |
192 | 207 | | |
193 | | - | |
194 | | - | |
| 208 | + | |
| 209 | + | |
195 | 210 | | |
196 | | - | |
| 211 | + | |
197 | 212 | | |
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
201 | 216 | | |
202 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
203 | 232 | | |
204 | 233 | | |
205 | 234 | | |
| |||
372 | 401 | | |
373 | 402 | | |
374 | 403 | | |
375 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
376 | 407 | | |
377 | 408 | | |
378 | 409 | | |
| |||
381 | 412 | | |
382 | 413 | | |
383 | 414 | | |
| 415 | + | |
384 | 416 | | |
385 | 417 | | |
386 | 418 | | |
| |||
398 | 430 | | |
399 | 431 | | |
400 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
401 | 444 | | |
402 | 445 | | |
403 | 446 | | |
| |||
424 | 467 | | |
425 | 468 | | |
426 | 469 | | |
427 | | - | |
| 470 | + | |
428 | 471 | | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
433 | 480 | | |
434 | 481 | | |
435 | 482 | | |
| |||
641 | 688 | | |
642 | 689 | | |
643 | 690 | | |
644 | | - | |
645 | 691 | | |
646 | 692 | | |
647 | 693 | | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
648 | 698 | | |
649 | 699 | | |
650 | 700 | | |
| |||
822 | 872 | | |
823 | 873 | | |
824 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
825 | 880 | | |
826 | 881 | | |
827 | 882 | | |
| |||
0 commit comments