Skip to content

Conversation

@TexasCoding
Copy link
Owner

  • Add optional ProjectX client parameter to OrderBook constructor
  • Implement _fetch_instrument_tick_size() method for cached instrument metadata
  • Enhance _calculate_price_tolerance() to use cached tick size (3x multiplier)
  • Update create_orderbook() factory function to accept project_x parameter
  • Eliminate repeated get_instrument() API calls during cluster detection
  • Maintain backward compatibility with fallback to hardcoded tick sizes

Performance improvements:

  • Single API call during initialization vs repeated calls per method
  • Cached tick size ensures consistent analysis throughout lifecycle
  • Accurate price tolerance based on real instrument metadata

Updated documentation:

  • README.md: Enhanced OrderBook section with client integration example
  • CHANGELOG.md: Added v1.1.2 release notes
  • docs/api/orderbook.rst: Updated Quick Start with proper initialization

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

TexasCoding and others added 3 commits July 27, 2025 17:56
…mprovements

## 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 <noreply@anthropic.com>
…reporting

- Fix portfolio report error by adding missing P&L keys to get_portfolio_pnl()
- Add position opening functionality to demonstrate complete lifecycle
- Implement enhanced cleanup to automatically close positions on script exit
- Add real-time position monitoring with live P&L tracking
- Include comprehensive safety measures with 1-contract test positions
- Improve error handling and fallback mechanisms

Key improvements:
- Portfolio reports now generate successfully with total_pnl, unrealized_pnl, etc.
- Example opens test position, monitors in real-time, then safely closes on exit
- Enhanced cleanup closes all positions with market orders and cancels open orders
- Proper order type handling (2=Market) and side mapping (0=Bid, 1=Ask)
- Production-ready position management with full lifecycle demonstration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…tegration

- Add optional ProjectX client parameter to OrderBook constructor
- Implement _fetch_instrument_tick_size() method for cached instrument metadata
- Enhance _calculate_price_tolerance() to use cached tick size (3x multiplier)
- Update create_orderbook() factory function to accept project_x parameter
- Eliminate repeated get_instrument() API calls during cluster detection
- Maintain backward compatibility with fallback to hardcoded tick sizes

Performance improvements:
- Single API call during initialization vs repeated calls per method
- Cached tick size ensures consistent analysis throughout lifecycle
- Accurate price tolerance based on real instrument metadata

Updated documentation:
- README.md: Enhanced OrderBook section with client integration example
- CHANGELOG.md: Added v1.1.2 release notes
- docs/api/orderbook.rst: Updated Quick Start with proper initialization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@TexasCoding TexasCoding merged commit a8af4e9 into main Jul 28, 2025
1 check passed
@TexasCoding TexasCoding deleted the test_kilo branch July 28, 2025 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants