-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: implement ETH vs RTH trading sessions feature #59
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 major feature adds comprehensive session-aware trading capabilities: ## New Session Management System - SessionConfig and SessionType for ETH/RTH trading hours - Session filtering for all market data and indicators - Product-specific session configurations (ES, NQ, CL, GC, etc.) ## Enhanced Components - Session-aware RealtimeDataManager with memory management - Session-specific statistics and analytics - Session transition events and callbacks - Indicator calculations respect session boundaries ## Testing Infrastructure - 30 comprehensive tests for session functionality - Mock fixtures for async testing patterns - Integration tests with TradingSuite - Backward compatibility validation ## API Enhancements - Client session API methods (get_session_bars, get_session_trades) - TradingSuite session methods (set_session_type, get_session_data) - Session-filtered data retrieval across all timeframes Closes #XX - Adds ETH vs RTH session filtering support Implements user-requested trading hours functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
## Code Quality Improvements ### 🔧 Fixed Session Time Validation - Removed restrictive RTH validation that prevented overnight sessions - Added validation for ETH start/end consistency - Now supports global markets with midnight-crossing sessions ### 🚀 Implemented Complete ETH Filtering - Added proper maintenance break exclusion for ETH sessions - Product-specific maintenance schedules (equity, energy, metals, treasuries) - Comprehensive filtering logic with timezone handling ### ⚡ Enhanced Error Handling - Replaced generic Exception with specific Polars exceptions - Updated imports to use polars.exceptions module - Better error messages for timestamp parsing issues ### 📈 Added Performance Optimizations - Session boundary caching for repeated filtering operations - Lazy evaluation support for large datasets (>100k rows) - Memory-efficient processing strategies - Pre-calculated boundary lookups ## Implementation Details ### ETH Maintenance Break Schedule - **Equity futures** (ES, NQ, etc.): 5:00-6:00 PM ET daily - **Energy futures** (CL, NG, etc.): 5:00-6:00 PM ET daily - **Metal futures** (GC, SI, etc.): 5:00-6:00 PM ET daily - **Treasury futures** (ZN, ZB, etc.): 4:00-6:00 PM ET daily ### Performance Features - Automatic lazy evaluation for datasets >100k rows - Session boundary caching with configurable cache size - Optimized DataFrame filtering strategies - Memory-efficient processing chains ## Testing Results - ✅ **72/72 session tests passing** (100% success rate) - ✅ **All validation logic updated** to match new requirements - ✅ **No performance regressions** detected - ✅ **Polars deprecation warnings** resolved ## Backward Compatibility - All existing APIs continue to work unchanged - New features are additive and opt-in - Default behavior maintained for compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
## IDE Issues Resolved ### 🔧 Exception Handling Compatibility - Simplified exception handling to use standard ValueError and Exception - Removed Polars-specific exceptions for broader IDE compatibility - Maintains same functionality while eliminating IDE import errors ### 🚀 Code Structure Improvements - Fixed unreachable code by improving session type handling logic - Removed unused parameter from method - Updated method signatures and call sites consistently ### 📝 Import Organization - Fixed import sorting and formatting issues - Reorganized imports according to style guidelines - Moved comments to appropriate locations ## Technical Details ### Exception Strategy - Uses catch pattern for broad compatibility - Maintains specific error messages for debugging - Works consistently across different Polars versions ### Method Signature Updates - - removed unused - Cleaner interface focused on actual parameter usage - Maintains backward compatibility for all public methods ## IDE Validation Results - ✅ **Import errors resolved** - No more unknown symbol warnings - ✅ **Unused parameter warnings fixed** - Clean method signatures - ✅ **Import formatting compliance** - Proper sorting and organization -⚠️ **One unreachable code hint remains** - Safe guard code for enum exhaustiveness The remaining 'unreachable code' hint is intentional defensive programming to handle unexpected enum values, providing better error messages. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job Claude Code finished reviewing this pull request PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
Added examples/16_eth_vs_rth_sessions_demo.py with complete feature demonstration: - Basic session configuration and usage patterns - Historical data analysis with RTH/ETH comparison - Session-aware indicator calculations (SMA, EMA, RSI, VWAP) - Session-specific statistics and performance metrics - Real-time session filtering with live data streams - Direct SessionFilterMixin usage for custom implementations - Multi-product session configurations and maintenance schedules - Performance optimization demonstrations for large datasets Demonstrates 366% more data in ETH vs RTH sessions for futures trading. Includes error handling, connection management, and practical usage examples. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
…xample - Added logging configuration to suppress SignalR WebSocket errors - Added small delays between suite disconnections to prevent cleanup races - Improved error handling in session statistics section - Makes example output much cleaner and more readable The WebSocket errors were harmless but made the output noisy and confusing. They occurred when background threads tried to read from already-closed connections after successful data retrieval and disconnection. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
- Created NullHandler to completely suppress error messages - Applied to SignalRCoreClient, websocket, and signalrcore loggers - Set propagate=False to prevent error propagation - Fixes remaining error messages in session-aware indicators section The errors were appearing because SignalR's error handling was still logging errors even at CRITICAL level. The NullHandler ensures complete suppression of these harmless connection cleanup messages. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
- Updated version to v3.4.0 in all relevant files - Added comprehensive CHANGELOG entries with experimental warnings - Created new docs/guide/sessions.md with complete usage guide - Updated README with session filtering examples and warnings - Enhanced docs/api/trading-suite.md with session configuration - Added experimental feature warnings throughout documentation - Reorganized examples into ETH_RTH_Examples directory - Emphasized that feature is not thoroughly tested with live data Related to PR #59
|
Claude finished @TexasCoding's task —— View job PR Review: ETH vs RTH Trading Sessions Feature ✅Review Tasks:
Overall Assessment: EXCELLENT ⭐⭐⭐⭐⭐This is a well-architected, comprehensive implementation that follows TDD principles and maintains backward compatibility. The feature adds significant value while adhering to project standards. ✅ Strengths🏗️ Excellent Architecture
📊 Comprehensive Product CoverageThe implementation covers 40+ futures products across all major markets:
🧪 Outstanding Test Coverage
🔄 Perfect Backward Compatibility
🛡️ Security Best Practices
|
Summary
This major release implements comprehensive session-aware trading capabilities, adding ETH (Electronic Trading Hours) vs RTH (Regular Trading Hours) support throughout the SDK.
Key Features
🕐 Session Management System
SessionConfigandSessionTypefor ETH/RTH trading hours📊 Enhanced Components
🧪 Comprehensive Testing
🔧 API Enhancements
get_session_bars(),get_session_trades(),get_session_statistics()set_session_type(),get_session_data(),get_session_statistics()Usage Examples
Basic Session Configuration
Dynamic Session Switching
Session-Aware Indicators
Backward Compatibility
Testing Results
Files Changed
src/project_x_py/sessions/(4 files)Session Configurations
Built-in configurations for major products:
Custom session times supported for any product.
🤖 Generated with Claude Code