Files
foxhunt/AGENT_WIRE14_INTEGRATION_GAPS.txt
jgrusewski 261bbef86e feat(wire-02): Document Wave D adaptive position sizer integration gap
CRITICAL FINDING: RegimeAdaptiveFeatures (Features 221-224) are fully
implemented but NOT integrated into trading decision flow.

Analysis Results:
-  RegimeAdaptiveFeatures: 644 lines, 12/12 tests passing
-  Database schema: regime_states, regime_transitions, adaptive_strategy_metrics
-  gRPC endpoints: GetRegimeState, GetRegimeTransitions defined
-  Trading Agent Service: NO regime integration in allocation.rs
-  Order Generation: NO stop-loss multiplier application

Impact:
- ML models train with regime features
- Production trading IGNORES regime state
- Position sizes remain STATIC (no 0.2x-1.5x adjustment)
- Expected Sharpe improvement: 0% (instead of +25-50%)

Integration Plan (11 hours):
1. Phase 1: Database query layer (2h) - regime.rs
2. Phase 2: Allocation integration (3h) - RegimeAdaptive method
3. Phase 3: Service wiring (2h) - RegimeDetector in service
4. Phase 4: Order generation (1h) - stop-loss multipliers
5. Phase 5: Testing (3h) - regime allocation tests

Code Changes:
- New files: regime.rs (200 lines), tests (300 lines)
- Modified: allocation.rs (+100), service.rs (+50), orders.rs (+30)
- Total: ~500 new lines, ~180 modified lines

Performance: +3ms latency (acceptable for +25-50% Sharpe)
Risk: Low (feature flag + 3-level rollback plan)

Recommendation: PROCEED before 225-feature ML retraining

Files:
- AGENT_WIRE02_ADAPTIVE_SIZER_INTEGRATION.md (full analysis)
- AGENT_WIRE02_QUICK_SUMMARY.md (executive summary)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 09:45:54 +02:00

130 lines
9.0 KiB
Plaintext

╔══════════════════════════════════════════════════════════════════════════════╗
║ AGENT WIRE-14: PAPER TRADING WAVE D INTEGRATION GAPS ║
╚══════════════════════════════════════════════════════════════════════════════╝
CURRENT STATE (Paper Trading Executor):
┌──────────────────────────────────────────────────────────────────────────┐
│ Component │ Status │ Wave C Baseline │ Wave D Required │
├────────────────────────┼─────────┼──────────────────┼───────────────────┤
│ ML Strategy │ ✅ YES │ SharedMLStrategy │ SharedMLStrategy │
│ Feature Config │ ❌ NO │ Hardcoded (20) │ FeatureConfig:: │
│ │ │ │ wave_d() │
│ Feature Count │ ❌ NO │ 201 features │ 225 features │
│ Regime Queries │ ❌ NO │ None │ get_latest_regime │
│ Position Sizing │ ❌ NO │ Fixed 1.0 │ Adaptive 0.2-1.5x │
│ Kelly Criterion │ ❌ NO │ Comment only │ Implemented │
└────────────────────────┴─────────┴──────────────────┴───────────────────┘
CRITICAL GAPS:
1. FEATURE EXTRACTION (Line 154-157)
┌─────────────────────────────────────────────────────────────────────┐
│ Current: SharedMLStrategy::new(20, 0.6) │
│ ^^^^ Hardcoded - NO feature config │
│ │
│ Required: SharedMLStrategy::new_with_config( │
│ 20, 0.6, │
│ FeatureConfig::wave_d() // ✅ 225 features │
│ ) │
└─────────────────────────────────────────────────────────────────────┘
2. REGIME STATE QUERIES (Missing)
┌─────────────────────────────────────────────────────────────────────┐
│ Current: No database queries for regime_states │
│ │
│ Required: let regime = sqlx::query!( │
│ "SELECT regime FROM get_latest_regime($1)", │
│ symbol │
│ ).fetch_one(&self.db_pool).await?; │
└─────────────────────────────────────────────────────────────────────┘
3. ADAPTIVE POSITION SIZING (Line 567-575)
┌─────────────────────────────────────────────────────────────────────┐
│ Current: let position_size = 1.0; // Fixed │
│ │
│ Required: let regime_mult = match regime { │
│ "Trending" => 1.5, │
│ "Ranging" => 0.8, │
│ "Volatile" => 0.5, │
│ "Transition" => 0.2, │
│ }; │
│ let size = base * regime_mult * confidence; │
└─────────────────────────────────────────────────────────────────────┘
ARCHITECTURE MISMATCH:
common::ml_strategy::MLFeatureExtractor
├─ Expected feature count: hardcoded comment (26/36/65)
├─ NO FeatureConfig integration
└─ NO Wave D support (225 features)
ml::features::config::FeatureConfig
├─ wave_d() method exists ✅
├─ enable_wave_d_regime: true ✅
└─ 225 feature support ✅
⚠️ PROBLEM: These two systems are NOT connected!
TESTING RISK:
Paper Trading Current:
┌─────────────────────────────────────────────────────────────────────┐
│ Features: 201 (Wave C baseline) │
│ Sizing: Fixed 1.0 contracts │
│ Regime: Not aware │
│ │
│ Result: Tests Wave C, NOT Wave D ❌ │
└─────────────────────────────────────────────────────────────────────┘
Paper Trading Required:
┌─────────────────────────────────────────────────────────────────────┐
│ Features: 225 (Wave D regime detection) │
│ Sizing: Adaptive 0.2x-1.5x based on regime │
│ Regime: Queries regime_states before each trade │
│ │
│ Result: Validates Wave D before production ✅ │
└─────────────────────────────────────────────────────────────────────┘
ACTION PLAN (6 hours):
[P1] Modify SharedMLStrategy constructor (2h)
└─ Accept FeatureConfig parameter
└─ Update paper_trading_executor.rs
└─ Verify 225-feature extraction
[P2] Add regime state queries (1h)
└─ Implement get_regime_for_symbol()
└─ Query get_latest_regime() before trades
└─ Log regime transitions
[P3] Adaptive position sizing (2h)
└─ Replace calculate_position_size()
└─ Implement regime multipliers (0.2x-1.5x)
└─ Add confidence-based Kelly factor
[P4] Testing & validation (1h)
└─ Run 24-hour paper trading test
└─ Monitor regime vs. sizing correlation
└─ Document Wave C vs. Wave D performance
RECOMMENDATION:
⛔ BLOCK production deployment until paper trading validates Wave D
Why? Paper trading is the ONLY pre-production validation step.
If it tests Wave C config, we have ZERO evidence that:
- 225-feature extraction works
- Regime detection improves performance
- Adaptive sizing reduces drawdowns
Next Steps:
1. Implement action items (6 hours)
2. Run 24-hour paper trading validation
3. Compare Wave C baseline vs. Wave D adaptive results
4. Document findings in PAPER_TRADING_WAVE_D_VALIDATION.md
═══════════════════════════════════════════════════════════════════════════════
Agent WIRE-14 Status: ⚠️ PARTIAL INTEGRATION - CRITICAL GAPS IDENTIFIED
Next Agent: WIRE-15 (Adaptive Position Sizing Implementation)
═══════════════════════════════════════════════════════════════════════════════