Historical protocol (Issue #324). The forward-test code (
src/trading/forward_test_manager.pyand its runner scripts) was deleted in #435, so the imports and commands below no longer work. Nothing opens trades automatically; the 30-day paper signal run (#574 stage C) is deferred. See the live-rules baseline.
Issue #324: 30-Day Forward Testing Validation Before Live Deployment
The forward testing framework validates system performance before live trading deployment. This is a standalone testing infrastructure, not an interactive CLI feature.
Key Distinction:
- ✅ This framework: Background validation tool for maintainers
- ❌ NOT included: Interactive "backtest AAPL" CLI commands (separate feature)
Validate that the trading system can:
- Generate profitable signals consistently
- Execute trades reliably
- Meet minimum performance criteria
- Operate stably for 30 consecutive days
File: src/trading/forward_test_manager.py
Tracks all forward testing operations:
- Signal generation and recording
- Trade entry and exit tracking
- Daily P&L calculation
- Test state persistence
File: src/trading/performance_validator.py
Calculates performance metrics:
- Sharpe Ratio
- Win Rate
- Max Drawdown
- Cumulative Return
- Profit Factor
- Risk-adjusted returns
File: src/trading/test_reporter.py
Generates formatted reports:
- Daily summaries
- Weekly progress reports
- Final validation report with go/no-go recommendation
File: scripts/forward_test_runner.py
Main execution script for running tests and generating reports.
# Initialize new 30-day forward test
python scripts/forward_test_runner.py \\
--test-name production_validation_2025 \\
--capital 10000# Generate daily summary
python scripts/forward_test_runner.py \\
--test-name production_validation_2025 \\
--report-type daily# Generate week 1 report (after 7 days)
python scripts/forward_test_runner.py \\
--test-name production_validation_2025 \\
--report-type weekly \\
--week 1# Generate final report after 30 days
python scripts/forward_test_runner.py \\
--test-name production_validation_2025 \\
--report-type final \\
--benchmark-return 500.00In your trading code (for example, where VotingSignal is called):
from src.trading.forward_test_manager import ForwardTestManager, SignalType
# Initialize test manager
test_manager = ForwardTestManager("my_test")
# Record signal when generated
signal = test_manager.record_signal(
symbol="AAPL",
signal_type=SignalType.BUY,
confidence=0.75,
price=175.50,
indicators={
"macd": 1.2,
"rsi": 45.0,
"signal_line": 0.8
}
)When a trade is executed:
from datetime import datetime
# Record trade entry
trade = test_manager.record_trade(
trade_id="TR_001",
symbol="AAPL",
entry_time=datetime.now(),
entry_price=175.50,
quantity=10,
side="buy",
stop_price=167.00,
target_price=189.00
)
# Later, when trade exits...
test_manager.close_trade(
trade_id="TR_001",
exit_time=datetime.now(),
exit_price=189.00,
outcome=TradeOutcome.CLOSED_WIN
)- Configure paper trading environment
- Validate API connections
- Test order placement without real money
- Verify position tracking accuracy
- Run daily signal generation
- Compare signals to manual analysis
- Track signal timing and accuracy
- Document edge cases and failures
- Full pipeline paper trading
- Monitor order fills and slippage
- Test trailing stop functionality
- Validate risk management rules
- Statistical performance validation
- Compare to benchmark (SPY buy-and-hold)
- Stress test with volatile market conditions
- Final go/no-go decision
| Metric | Minimum | Target |
|---|---|---|
| Trade Count | 20+ | 30+ |
| Win Rate | ≥50% | 51.4% (match backtest) |
| Cumulative Return | Positive | Beat SPY |
| Max Drawdown | <15% | <10.1% (match backtest) |
| Sharpe Ratio | >0.5 | 0.856 (match backtest) |
Superseded (Oct 2026, #574): the "match backtest" targets above come from experiment 293, which doesn't describe the live rules. The live-rules baseline expects about 35 trades in 30 trading days and a win rate near 43%. Over 30 days a Sharpe ratio has a standard error of about 2.9, so the paper run is judged on fidelity to a replay of the same rules (#574 stage C), not on performance.
| Metric | Minimum |
|---|---|
| System Uptime | 99%+ during market hours |
| Signal Latency | <30 seconds from trigger |
| Order Execution | 95% fills within 1 minute |
| Error Rate | <1% failed operations |
ALL of the following must be true:
- ✅ All technical requirements met
- ✅ All performance gates achieved
- ✅ 30 consecutive days successful operation
- ✅ Final validation report approved
- ✅ Risk management protocols validated
================================================================================
FINAL VALIDATION REPORT - 30-DAY FORWARD TEST
================================================================================
Test: production_validation_2025
Period: 2025-01-15 to 2025-02-14
Duration: 30 days
--------------------------------------------------------------------------------
FINAL PERFORMANCE METRICS
--------------------------------------------------------------------------------
Trade Statistics:
Total Trades: 28
Winning Trades: 15
Losing Trades: 13
Win Rate: 53.57%
Return Metrics:
Initial Capital: $10,000.00
Total Return: +$1,245.00
Return %: +12.45%
Average Win: $142.50
Average Loss: $95.30
Profit Factor: 1.95
Risk Metrics:
Sharpe Ratio: 0.892
Max Drawdown: $847.00 (8.47%)
Avg Trade Duration: 2.3 days
Benchmark Comparison:
Strategy Return: +$1,245.00
Benchmark Return: +$425.00
Excess Return: +$820.00
--------------------------------------------------------------------------------
ACCEPTANCE CRITERIA VALIDATION
--------------------------------------------------------------------------------
✓ PASS - 20+ Trades Generated: 28
✓ PASS - Win Rate ≥50%: 53.6%
✓ PASS - Positive Return: +$1,245.00
✓ PASS - Max Drawdown <15%: 8.47%
✓ PASS - Sharpe Ratio >0.5: 0.892
--------------------------------------------------------------------------------
GO-LIVE RECOMMENDATION
--------------------------------------------------------------------------------
✅ **APPROVED FOR LIVE TRADING**
All acceptance criteria have been met.
System has demonstrated reliable performance over 30-day test period.
Recommendation: Proceed to live trading deployment.
================================================================================
Testing will automatically halt if:
- Drawdown > 20%
- Daily error rate > 5%
- System unavailable > 1 hour during market hours
For:
- Unusual trading patterns
- Unexpected API errors
- Performance degradation
- Risk limit violations
state/forward_tests/{test_name}_state.json
- Daily:
reports/forward_tests/daily_summary_{date}.txt - Weekly:
reports/forward_tests/week_{n}_report.txt - Final:
reports/forward_tests/final_validation_report_{date}.txt
- ✅ Run tests in paper trading mode first
- ✅ Generate daily reports to track progress
- ✅ Compare to benchmark (SPY) regularly
- ✅ Document all unusual observations
- ✅ Review test results weekly
- ❌ Skip to live trading without 30-day validation
- ❌ Ignore failing acceptance criteria
- ❌ Modify strategy during testing
- ❌ Cherry-pick favorable test periods
- ❌ Proceed if system shows instability
Potential improvements (separate issues):
- Interactive CLI backtesting commands
- Real-time performance dashboard
- Automated email/SMS alerts
- Multi-strategy comparison testing
- Walk-forward optimization integration
Related Issues:
- #324 - Forward Testing Protocol (this document)
- TBD - Interactive CLI Backtesting (future enhancement)