Skip to content

v3.4.0 - ETH vs RTH Trading Sessions (Experimental)

Pre-release
Pre-release

Choose a tag to compare

@TexasCoding TexasCoding released this 28 Aug 11:08
· 74 commits to main since this release
6cf8032

🚀 New Feature: ETH vs RTH Trading Sessions (Experimental)

⚠️ IMPORTANT: This is an experimental feature that has not been thoroughly tested with live market data. Use with caution in production environments.

This release introduces comprehensive trading session filtering, allowing you to separate Electronic Trading Hours (ETH) from Regular Trading Hours (RTH) for more precise market analysis and strategy execution.

✨ What's New

Trading Sessions Module

The new sessions module provides complete session-aware trading capabilities:

  • SessionConfig: Configure session type (ETH/RTH/BOTH) with product-specific schedules
  • SessionFilterMixin: High-performance data filtering with caching and lazy evaluation
  • Session-Aware Indicators: Calculate technical indicators on session-specific data
  • Session Statistics: Separate performance metrics for ETH vs RTH periods
  • Maintenance Break Exclusion: Automatically filters out daily maintenance periods (5-6 PM ET)

TradingSuite Integration

Seamless integration with existing components:

# RTH-only trading (9:30 AM - 4:00 PM ET)
rth_suite = await TradingSuite.create(
    "MNQ",
    timeframes=["1min", "5min"],
    session_config=SessionConfig(session_type=SessionType.RTH)
)

# ETH-only analysis (excludes RTH and maintenance breaks)
eth_suite = await TradingSuite.create(
    "ES",
    session_config=SessionConfig(session_type=SessionType.ETH)
)

📊 Key Benefits

  • Accurate Backtesting: Test strategies with proper session boundaries
  • Volume Profile Analysis: Compare ETH vs RTH volume distribution
  • Session Transition Trading: Detect and trade overnight gaps
  • Reduced Noise: Filter out low-liquidity overnight periods
  • 366% More Data: ETH sessions provide ~1,410 bars/day vs ~390 for RTH

📚 Documentation & Examples

New Documentation

  • User Guide: docs/guide/sessions.md - Complete usage guide
  • API Reference: Updated docs/api/trading-suite.md with session parameters
  • Comprehensive Example: examples/sessions/00_eth_vs_rth_sessions_demo.py

Example Usage

The example script demonstrates:

  • Basic session filtering
  • Session-aware indicators
  • Volume analysis by session
  • Performance comparison ETH vs RTH
  • Session transition detection
  • Backtesting with sessions
  • Custom session boundaries

⚠️ Known Limitations

This is an experimental feature with the following limitations:

  • Session boundaries may need adjustment based on contract specifications
  • Overnight session handling requires further testing
  • Performance impact with large datasets not fully optimized
  • Some futures products may have non-standard session times

🔧 Technical Implementation

  • Implemented with Polars DataFrame filtering for performance
  • Caching of session boundaries reduces computation overhead
  • Lazy evaluation prevents unnecessary filtering operations
  • Fully async implementation maintains SDK consistency
  • Compatible with all existing indicators and analysis tools

📈 Performance Metrics

Testing shows:

  • ETH sessions: ~1,410 bars/day (23.5 hours trading)
  • RTH sessions: ~390 bars/day (6.5 hours trading)
  • Data increase: 366% more bars in ETH
  • Filtering overhead: < 5ms for typical operations
  • Memory efficient with lazy evaluation

🧪 Testing Coverage

Added comprehensive test coverage:

  • 30 integration tests for session filtering
  • Unit tests for all session components
  • Mock data testing for backtesting scenarios
  • Performance benchmarks included

🔄 Backward Compatibility

This release maintains full backward compatibility:

  • Session filtering is opt-in via session_config parameter
  • Default behavior unchanged (BOTH sessions)
  • No breaking changes to existing APIs
  • All existing code continues to work without modification

📝 Migration Guide

To add session filtering to existing code:

# Before (v3.3.x)
suite = await TradingSuite.create("MNQ", timeframes=["1min"])

# After (v3.4.0) - with session filtering
from project_x_py.sessions import SessionConfig, SessionType

suite = await TradingSuite.create(
    "MNQ",
    timeframes=["1min"],
    session_config=SessionConfig(session_type=SessionType.RTH)
)

🙏 Acknowledgments

Special thanks to all contributors and testers who helped develop this feature.

📦 Installation

pip install --upgrade project-x-py==3.4.0

or with uv:

uv add project-x-py==3.4.0

🐛 Reporting Issues

Please report any issues with the session filtering feature on our GitHub Issues page. Include:

  • Your session configuration
  • The futures product you're trading
  • Any error messages
  • Expected vs actual behavior

📋 Full Changelog

See CHANGELOG.md for complete release notes.


Note: This feature is experimental. We recommend thorough testing in paper trading environments before using in production.