# Quant-Rust-Strategist Memory ## Architecture Overview - ~100-symbol universe across 14 sectors - strategy.rs: shared logic between bot.rs and backtester.rs - Backtester restricts buys to top momentum stocks (TOP_MOMENTUM_COUNT) - SPY regime filter (EMA-50/200) gates new longs: Bull/Caution/Bear - Signal thresholds: StrongBuy>=7.0, Buy>=4.0, Sell<=-4.0, StrongSell<=-7.0 ## Signal Generation (2026-02-13 REWRITE) - **OLD**: Additive "indicator soup" -- 8 indicators netted, PF 0.91, no edge - **NEW**: Hierarchical momentum-with-trend filter: - Gate 1: trend_bullish AND ema_bullish -- MUST pass for any buy - Gate 2: positive momentum (ROC > 0) -- time-series momentum - Timing: RSI-14 pullback (30-50) in confirmed uptrends - Conviction: ADX direction, MACD histogram, volume - Sell: trend break (price < EMA-trend) is primary exit signal - Key insight: hierarchical gating >> additive scoring ## Stop/Exit Logic (2026-02-13 FIX) - Time exit ONLY sells losers (pnl_pct < 0). Old code force-sold winners. - Trail activation: 1.5x ATR (was 2.0x), trail distance: 2.5x ATR (was 2.0x) - Max loss: 8% (was 5%), TIME_EXIT_BARS: 60 (was 40) ## Equity Curve SMA Stop: REMOVED from backtester - Created pathological feedback loop with drawdown breaker ## Position Sizing (2026-02-13 FIX) - Confidence scaling: 0.4 + 0.6*conf (was 0.7 + 0.3*conf) - RISK_PER_TRADE: 1.0%, MAX_POSITIONS: 10, TOP_MOMENTUM: 10 ## Current Parameters (config.rs, updated 2026-02-13) - ATR Stop: 3.0x | Trail: 2.5x distance, 1.5x activation - Risk: 1.0%/trade, max 25% position, 5% cash reserve, 8% max loss - Max 10 positions, 2/sector | Time exit: 60 bars (losers only) - Cooldown: 5 bars | Ramp-up: 15 bars | Slippage: 10bps - Momentum pool: top 10 (decile) ## Bugs Fixed (2026-02-13) 1. calculate_results used self.cash instead of equity curve final value 2. Drawdown circuit breaker cascading re-triggers (peak not reset) 3. PDT blocking sells in backtester (disabled) ## Failed Experiments (avoid repeating) 1. Tighter ATR stop (<3.0x): too many stop-outs on hourly 2. Lower buy threshold (3.5): too many weak entries (4.0 is fine) 3. Blocking stop-loss exits for PDT: traps capital in losers 4. Lower volume threshold (0.7): bad trades on IEX. Keep 0.8 5. Shorter hourly lookbacks: catastrophic losses 6. Drawdown halt 12% with non-resetting peak: cascading re-triggers 7. Additive indicator soup: fundamentally has no edge (PF < 1.0) 8. Time exit that dumps winners: destroys win/loss asymmetry 9. Equity curve SMA stop: correlated with drawdown breaker, blocks recovery ## Hourly Timeframe: DO NOT CHANGE FROM BASELINE - momentum=63, ema_trend=200 (long lookbacks filter IEX noise) ## IEX Data Stochasticity - Run 2-3 times and compare ranges before concluding a change helped/hurt ## Build Notes - `cargo build --release` compiles clean (only dead_code warnings) - No tests exist