feat: saxo price

This commit is contained in:
OpenSquared
2026-07-23 10:33:18 +02:00
parent 1ac2270271
commit a136d6ae11
5 changed files with 118 additions and 40 deletions

View File

@@ -49,8 +49,8 @@ def watchlist_quotes():
items = []
for row in get_instruments_watchlist():
q = None
if row.get("saxo_symbol"):
q = _saxo_quote(row["saxo_symbol"])
if row.get("saxo_quote_symbol"):
q = _saxo_quote(row["saxo_quote_symbol"])
if q is None:
q = get_quote_with_volatility(row["ticker"]) or {}
items.append({
@@ -110,13 +110,27 @@ class SaxoLinkBody(BaseModel):
saxo_symbol: str | None = None
@router.put("/{ticker}/saxo-link")
def set_saxo_link(ticker: str, body: SaxoLinkBody):
"""Link this tracked instrument to a Saxo watchlist symbol (or pass null to unlink)
so Options Lab's Saxo section shows broker data for it. Adds the symbol to
services.saxo_scheduler's watchlist automatically if it wasn't already there."""
from services.database import set_instrument_watchlist_saxo_symbol
ok = set_instrument_watchlist_saxo_symbol(ticker, body.saxo_symbol)
@router.put("/{ticker}/saxo-option-link")
def set_saxo_option_link(ticker: str, body: SaxoLinkBody):
"""Link this tracked instrument to the Saxo symbol whose OPTIONS CHAIN Options Lab
should analyze for it (or pass null to unlink) — e.g. CL=F -> MCL:XCME. Adds the
symbol to services.saxo_scheduler's watchlist automatically if it wasn't already
there, so that chain starts getting snapshotted."""
from services.database import set_instrument_watchlist_saxo_option_symbol
ok = set_instrument_watchlist_saxo_option_symbol(ticker, body.saxo_symbol)
if not ok:
raise HTTPException(404, f"'{ticker}' is not in the instruments watchlist")
return {"ticker": ticker.strip().upper(), "saxo_symbol": (body.saxo_symbol or "").strip().upper() or None}
return {"ticker": ticker.strip().upper(), "saxo_option_symbol": (body.saxo_symbol or "").strip().upper() or None}
@router.put("/{ticker}/saxo-quote-link")
def set_saxo_quote_link(ticker: str, body: SaxoLinkBody):
"""Link this tracked instrument to the Saxo symbol used to price it in the Cockpit
(or pass null to unlink) — an accurate broker spot/futures feed instead of
yfinance's unadjusted continuous-futures tickers. Independent of the options link
above; often a different Saxo instrument."""
from services.database import set_instrument_watchlist_saxo_quote_symbol
ok = set_instrument_watchlist_saxo_quote_symbol(ticker, body.saxo_symbol)
if not ok:
raise HTTPException(404, f"'{ticker}' is not in the instruments watchlist")
return {"ticker": ticker.strip().upper(), "saxo_quote_symbol": (body.saxo_symbol or "").strip().upper() or None}