feat: risk

This commit is contained in:
OpenSquared
2026-07-26 14:10:49 +02:00
parent ad7ab35d1d
commit 3704724b0b
8 changed files with 719 additions and 57 deletions

View File

@@ -3342,6 +3342,23 @@ def get_instruments_watchlist() -> List[Dict]:
return [dict(r) for r in rows]
def get_saxo_option_symbol_for_ticker(ticker: str) -> Optional[str]:
"""Cockpit Watchlist's saxo_option_symbol link for this yfinance-style ticker
(e.g. '^NDX' -> 'NQ:XCME') — Portfolio positions store `underlying` in the same raw
format the Watchlist's own `ticker` column uses, so this is a direct case-insensitive
match, no suffix-stripping or alias table needed (see services.instrument_service.
resolve_watchlist_ticker for the OTHER case, where a catalog id and a Watchlist ticker
genuinely differ — that doesn't apply here). Used by services.portfolio_pricing to
decide whether a position's legs can be priced off the real Saxo option chain instead
of a yfinance-historical-vol Black-Scholes simulation."""
conn = get_conn()
row = conn.execute(
"SELECT saxo_option_symbol FROM instruments_watchlist WHERE ticker = ? COLLATE NOCASE", (ticker,)
).fetchone()
conn.close()
return row["saxo_option_symbol"] if row and row["saxo_option_symbol"] else None
def set_instrument_watchlist_saxo_option_symbol(ticker: str, saxo_symbol: Optional[str]) -> bool:
"""Link (or unlink, if saxo_symbol is None/empty) a tracked instrument to the Saxo
symbol whose OPTIONS CHAIN Options Lab should analyze for it — e.g. CL=F -> MCL:XCME