feat: IV gate — block ALERT trades before logging + configurable thresholds

- auto_cycle.py: pre-fetch IV snapshots at step 1.9; _apply_iv_gate() runs
  before log_trade_entries, removes ALERT-verdict trades (not just reports)
- options_technical_agent.py: _IVR_HIGH/_IVR_EXTREME/_SKEW_THRESH as
  module-level vars; straddle/strangle penalty -60 (vs -56 naked) at extreme IVR
  so Long Straddle at IVR ≥ 80% → ALERT; thresholds respected in rule engine
- database.py: seed 4 iv_gate config keys (iv_gate_enabled, iv_gate_ivr_high=60,
  iv_gate_ivr_extreme=80, iv_gate_skew_threshold=8) — editable from Config page
- Blocked trades logged as skipped_trades with [IV_GATE] detail + optimal strategy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-20 10:15:45 +02:00
parent 3ee39d5f08
commit c7ccf237d7
3 changed files with 189 additions and 14 deletions

View File

@@ -499,6 +499,11 @@ def init_db():
for _key, _val in [
("journal_retention_days", "90"),
("maturity_threshold_pct", "35"),
# IV Gate — blocks ALERT trades before they are logged
("iv_gate_enabled", "true"), # enable/disable the IV gate entirely
("iv_gate_ivr_high", "60"), # IVR above this = "high vol" (no naked long)
("iv_gate_ivr_extreme", "80"), # IVR above this = "extreme vol" (sell vol only)
("iv_gate_skew_threshold", "8"), # put skew above this = protect is expensive
]:
existing = c.execute("SELECT value FROM config WHERE key=?", (_key,)).fetchone()
if not existing: