feat: strategy builder
This commit is contained in:
@@ -3159,6 +3159,22 @@ def get_iv_history(ticker: str, days: int = 90) -> List[Dict]:
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
|
||||
def get_iv_change_1d(ticker: str, current_iv: float) -> Optional[float]:
|
||||
"""Day-over-day IV delta (decimal, e.g. 0.012 = +1.2 vol points) — current_iv minus
|
||||
the most recent prior trading day's recorded iv_current. None if no prior day exists."""
|
||||
conn = get_conn()
|
||||
row = conn.execute(
|
||||
"""SELECT iv_current FROM iv_history
|
||||
WHERE ticker=? AND iv_current IS NOT NULL AND recorded_date < date('now')
|
||||
ORDER BY recorded_date DESC LIMIT 1""",
|
||||
(ticker.upper(),),
|
||||
).fetchone()
|
||||
conn.close()
|
||||
if not row or row["iv_current"] is None:
|
||||
return None
|
||||
return current_iv - row["iv_current"]
|
||||
|
||||
|
||||
# ── IV Watchlist ──────────────────────────────────────────────────────────────
|
||||
|
||||
def get_watchlist_tickers() -> List[str]:
|
||||
|
||||
Reference in New Issue
Block a user