feat: strategy builder
This commit is contained in:
@@ -404,7 +404,7 @@ def get_full_iv_snapshot(ticker: str) -> Dict[str, Any]:
|
||||
Full IV snapshot for a ticker: current IV, rank/percentile, term structure, skew, flow.
|
||||
Calls DB for historical rank/percentile.
|
||||
"""
|
||||
from services.database import get_iv_rank_percentile, save_iv_snapshot
|
||||
from services.database import get_iv_rank_percentile, save_iv_snapshot, get_iv_change_1d
|
||||
|
||||
proxy = _resolve_ticker(ticker)
|
||||
today = date.today().isoformat()
|
||||
@@ -423,16 +423,19 @@ def get_full_iv_snapshot(ticker: str) -> Dict[str, Any]:
|
||||
iv_current = recent[0]["iv_current"]
|
||||
|
||||
rank_data: Dict[str, Any] = {}
|
||||
iv_change_1d = None
|
||||
if iv_current:
|
||||
if live_iv and date.today().weekday() < 5:
|
||||
# Only persist weekday IV — weekend premium inflates IV and corrupts history
|
||||
save_iv_snapshot(proxy, today, iv_current, term.get("iv_30d"), term.get("iv_60d"), term.get("iv_90d"))
|
||||
rank_data = get_iv_rank_percentile(proxy, iv_current)
|
||||
iv_change_1d = get_iv_change_1d(proxy, iv_current)
|
||||
|
||||
return {
|
||||
"ticker": ticker,
|
||||
"proxy": proxy,
|
||||
"iv_current_pct": round(iv_current * 100, 1) if iv_current else None,
|
||||
"iv_change_1d_pct": round(iv_change_1d * 100, 1) if iv_change_1d is not None else None,
|
||||
"iv_rank": rank_data.get("iv_rank"),
|
||||
"iv_percentile": rank_data.get("iv_percentile"),
|
||||
"history_days": rank_data.get("history_days", 0),
|
||||
|
||||
Reference in New Issue
Block a user