-
-
Notifications
You must be signed in to change notification settings - Fork 11
Release v3.1.13 - Critical Event System Fixes #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces a series of critical fixes and feature enhancements to the RealtimeDataManager and RiskManager modules. RealtimeDataManager: - fix: Prevents crashes when no EventBus is provided by using a dummy fallback. - fix: Completes resource cleanup in `stop_realtime_feed` by unsubscribing from market data and removing callbacks. - fix: Uses the configured timezone in `get_bars_since` instead of a hardcoded value. - refactor: Consolidates and simplifies memory pruning into a proper sliding window. - refactor: Eliminates duplicated event mapping in the CallbackMixin. RiskManager: - fix(critical): Corrects trailing stop logic to use live market price instead of the static entry price. - fix: Prevents hazardous operations by raising an exception if no account is found, instead of using a default. - feat: Implements ATR-based stop-loss calculation using the existing indicator library. - refactor: Replaces inefficient polling for order fills with a robust, event-driven approach in ManagedTrade.
This commit resolves several architectural issues and bugs in the PositionManager to improve its robustness, correctness, and maintainability. - refactor: Removes duplicated risk logic by delegating all risk calculations to the main RiskManager module. - fix: Implements realized P&L tracking upon position closure and initializes the necessary stats counters. This fixes a bug where historical performance metrics were not calculated. - refactor: Removes misleading historical metrics (win_rate, profit_factor) from the analytics of open positions. - feat: Implements P&L-based position alerts by giving the manager access to a data feed to check P&L against thresholds. - fix: Corrects a data integrity bug where partial real-time updates could create incomplete Position objects. Updates are now merged with existing cached data.
- Fix OrderManager initialization in TradingSuite to enable WebSocket tracking - Add OCO (One-Cancels-Other) groups tracking to OrderManagerProtocol - Fix Event object handling in _wait_for_order_fill handlers - Resolve circular dependency between PositionManager and RiskManager - Make risk_manager parameter optional in PositionManager - Make position_manager parameter optional in RiskManager - Add proper initialization sequence in TradingSuite - Fix bracket order flow to wait for entry fill before placing protective orders This ensures bracket orders work correctly with: - Real-time order tracking via WebSocket - Proper fill detection for entry orders - Automatic OCO cancellation when one order fills - Clean separation of concerns between managers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Fixed OrderManagerProtocol to include all required methods - Fixed return type annotations in tracking.py and managed_trade.py - Added type: ignore comments for mixin-internal method calls - Fixed RealtimeDataManagerProtocol compatibility - Updated bracket order tests to properly mock dependencies - Ensured all async methods have proper return type annotations All mypy errors resolved - codebase now passes strict type checking
… on RiskManager The RiskManager expects both self.positions and self.position_manager to be set. Fixed TradingSuite to set both attributes when initializing RiskManager with PositionManager reference.
- Added risk_manager feature to position management example - Added type: ignore comment for data_manager parameter compatibility - Fixed method parameter names in data_processing.py type hints - Removed obsolete example files (README_instrument_demo.md, verify_orderblock_fvg_indicators.py) All tests passing, mypy type checking successful, and bracket order functionality working correctly.
- Added comprehensive Features section to README with available feature flags - Documented RiskManager integration requirements and position_manager attribute fix - Updated CLAUDE.md with v3.1.13 development changes and Features enum - Added patching_v4 changes to CHANGELOG with all fixes and improvements - Clarified that OrderManager and PositionManager are always included by default
…dule This commit introduces a series of refactorings and fixes to the async client module to improve its robustness, maintainability, and type safety. Key changes include: - Replaced brittle msgpack DataFrame serialization with the robust Arrow IPC format in the caching layer. - Simplified cache eviction logic by removing redundant manual TTL management and relying on cachetools built-in functionality. - Consolidated the API for fetching open positions by deprecating `get_positions` in favor of the more consistent `search_open_positions`. - Removed misleading placeholder values from the `get_health_status` method to ensure it returns only accurately tracked metrics. - Hardened the parsing of instrument contract IDs with a more resilient regex-based approach. - Resolved all mypy type-checking errors across the client module, including issues with untyped libraries and mixin protocols.
- Fixed cache expiration tests by adding cache_ttl property setter that recreates TTL caches when TTL value changes - Updated optimized cache tests to match Arrow IPC serialization - Fixed trading workflow test to handle both list and dict API responses - Added is_closed attribute to mock httpx client for health status test - Fixed timezone handling in market data tests (use America/Chicago) - Removed obsolete phase4 comprehensive test example - All 76 client tests now passing successfully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add comprehensive test suite for auth.py (83% coverage) - 11 test cases covering authentication, token refresh, and account selection - Tests for error handling and edge cases - Add comprehensive test suite for market_data.py (90% coverage) - 18 test cases covering instrument search, bar data retrieval, and caching - Tests for contract selection logic and API error handling - Add comprehensive test suite for http.py (99% coverage) - 21 test cases covering HTTP client, request handling, and error scenarios - Tests for rate limiting, authentication refresh, and connection errors - Add comprehensive test suite for cache.py (95% coverage) - 21 test cases covering instrument and market data caching - Tests for serialization, compression, TTL expiration, and cache stats - Fix bug in market_data.py _select_best_contract method - Method was incorrectly looking for 'symbol' field instead of 'name' - Fixed to use correct field names from API response - Add pyjwt dependency for authentication testing Overall client module coverage improved from 30% to 82% 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Created test_client_base.py with 14 tests for ProjectXBase class - Tests initialization, context managers, authentication methods - Tests factory methods (from_env, from_config_file) - Achieved 100% coverage for base.py - Created test_client_trading.py with 21 tests for TradingMixin - Tests search_open_positions with various scenarios - Tests search_trades with date ranges and filters - Tests deprecated get_positions method - Achieved 98% coverage for trading.py - Overall client module coverage improved from 82% to 93% - auth.py: 83% coverage - base.py: 100% coverage (up from 61%) - cache.py: 95% coverage - http.py: 99% coverage - market_data.py: 90% coverage - trading.py: 98% coverage (up from 31%) All tests pass successfully with proper mocking of async operations.
Refactors the `mmap_storage` module to improve reliability, thread-safety, and performance. - Fixes a critical bug in `TimeSeriesStorage` that caused data to be overwritten on initialization. - Implements a binary search for `read_window` to significantly improve performance on large datasets. - Adds `RLock` to ensure thread-safe operations on storage classes. - Replaces `print` statements with `logging` for better error handling. - Fixes a file corruption bug in `_resize_file`. - Improves metadata handling to be more robust. In `event_bus`, updates `asyncio.get_event_loop()` to the modern `asyncio.get_running_loop().
- Created HubConnection type alias in types.base for BaseHubConnection - Updated ProjectXRealtimeClient to use HubConnection instead of Any - Updated ProjectXRealtimeClientProtocol to match implementation types - Improved subscription handling with proper event waiting - Added circuit breaker pattern to BatchedWebSocketHandler - Fixed asyncio deprecation warnings (get_event_loop -> get_running_loop) This ensures IDEs properly recognize connection object methods (send, on, start, stop) and provides better type safety for real-time connection management. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…andlers
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]>
- Updated CHANGELOG.md with comprehensive v3.1.13 release notes - Updated CLAUDE.md project status to v3.1.13 - Updated README.md version to v3.1.13 - Documented all fixes: event system, type annotations, stability improvements - Highlighted critical bracket order fill detection fix - Added test coverage improvements (30% to 93%) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Updated version in __init__.py - Updated version in pyproject.toml - Updated version in docs/conf.py - Updated version in indicators/__init__.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review - Release v3.1.13This is a substantial and well-executed release with critical fixes and improvements. The PR addresses significant issues while maintaining backward compatibility and dramatically improving test coverage. Review Tasks
🎯 Overall Assessment: EXCELLENT ⭐This release represents a mature, production-ready improvement with exceptional attention to detail. The changes are well-architected, thoroughly tested, and maintain backward compatibility. ✅ StrengthsEvent System Fixes (
|
🚀 Release v3.1.13
This release includes critical fixes for the event system, improved type safety, enhanced stability, and major test coverage improvements.
🎯 Key Highlights
🔧 Critical Fixes
Event System Data Structure Mismatches
order_idand nestedorderobject structuresType Annotations for SignalR Connections
Real-time Connection Improvements
📊 Improvements
Data Storage Robustness
Test Coverage
Order and Position Management
📚 Documentation
🧪 Testing
All tests pass successfully. The bracket order fill detection issue is now resolved.
🤖 Generated with Claude Code