just a checkpoint
This commit is contained in:
@@ -1,59 +1,63 @@
|
||||
# Quant-Rust-Strategist Memory
|
||||
|
||||
## Architecture Overview
|
||||
- ~100-symbol universe across 14 sectors (expanded from original 50)
|
||||
- Hybrid momentum + mean-reversion via regime-adaptive dual signal in `generate_signal()`
|
||||
- ~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
|
||||
|
||||
## Bugs Fixed (2026-02-13)
|
||||
### 1. calculate_results used self.cash instead of equity curve final value
|
||||
- backtester.rs line ~686: `let final_value = self.cash` missed open positions
|
||||
- Fixed: use `self.equity_history.last().portfolio_value`
|
||||
## 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
|
||||
|
||||
### 2. Drawdown circuit breaker cascading re-triggers
|
||||
- peak_portfolio_value was never reset after halt, causing immediate re-trigger
|
||||
- 7+ triggers in 3yr = ~140 bars (19% of backtest) sitting in cash
|
||||
- Fixed: reset peak to current value on halt resume
|
||||
## 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)
|
||||
|
||||
### 3. PDT blocking sells in backtester (disabled)
|
||||
- PDT sell-blocking removed from backtester; it measures strategy alpha not compliance
|
||||
- Late-day entry prevention in execute_buy remains for hourly PDT defense
|
||||
- would_be_day_trade was called AFTER position removal = always false (logic bug)
|
||||
## Equity Curve SMA Stop: REMOVED from backtester
|
||||
- Created pathological feedback loop with drawdown breaker
|
||||
|
||||
## PDT Implementation (2026-02-12)
|
||||
- Tracks day trades in rolling 5-business-day window, max 3 allowed
|
||||
- CRITICAL: Stop-loss exits must NEVER be blocked by PDT (risk mgmt > compliance)
|
||||
- Late-day entry prevention: On hourly, block buys after 19:00 UTC (~last 2 hours)
|
||||
- PDT blocking DISABLED in backtester (kept in bot.rs for live trading)
|
||||
## 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.0x distance, 2.0x activation
|
||||
- Risk: 1.2%/trade, max 25% position, 5% cash reserve, 5% max loss
|
||||
- Max 7 positions, 2/sector | Drawdown halt: 15% (10 bars) | Time exit: 40
|
||||
- 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
|
||||
- Buy threshold: 4.0 (lowered from 4.5) | Momentum pool: top 20 (widened from 10)
|
||||
- Daily: momentum=63, ema_trend=50 | Hourly: momentum=63, ema_trend=200
|
||||
- ADX: range<20, trend>25, strong>40
|
||||
- Momentum pool: top 10 (decile)
|
||||
|
||||
## Hourly Timeframe: DO NOT CHANGE FROM BASELINE
|
||||
- Hourly IndicatorParams: momentum=63, ema_trend=200 (long lookbacks filter IEX noise)
|
||||
- Shorter periods (momentum=21, ema_trend=50): CATASTROPHIC -8% loss
|
||||
## 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 (but 4.0 is fine)
|
||||
3. Blocking stop-loss exits for PDT: traps capital in losers, dangerous
|
||||
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 in multi-year tests
|
||||
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
|
||||
- Backtests have significant run-to-run variation from IEX data timing
|
||||
- Do NOT panic about minor performance swings between runs
|
||||
- Always run 2-3 times and compare ranges before concluding a change helped/hurt
|
||||
- Run 2-3 times and compare ranges before concluding a change helped/hurt
|
||||
|
||||
## Build Notes
|
||||
- `cargo build --release` compiles clean (only dead_code warnings for types.rs fields)
|
||||
- `cargo build --release` compiles clean (only dead_code warnings)
|
||||
- No tests exist
|
||||
|
||||
Reference in New Issue
Block a user