feat: cockpit

This commit is contained in:
OpenSquared
2026-07-26 17:22:59 +02:00
parent 67793608e4
commit a08e8e1b11
2 changed files with 47 additions and 5 deletions

View File

@@ -48,13 +48,23 @@ def _saxo_quote(saxo_symbol: str) -> Optional[dict]:
def watchlist_quotes():
from services.database import get_instruments_watchlist
from services.data_fetcher import get_quote_with_volatility
from services.wavelet_signals import _FRIENDLY_TO_YFINANCE
items = []
for row in get_instruments_watchlist():
q = None
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 {}
# row["ticker"] is the Cockpit's own label for some rows (BRENT, GOLD...), not a
# real yfinance symbol — without this translation yfinance returns nothing and
# the card shows "—" instead of falling back to the last available close, same
# gap already fixed once for the wavelet cache (see _FRIENDLY_TO_YFINANCE there).
yf_ticker = row["ticker"]
if yf_ticker in _FRIENDLY_TO_YFINANCE:
yf_ticker = _FRIENDLY_TO_YFINANCE[yf_ticker]
elif len(yf_ticker) == 6 and yf_ticker.isalpha():
yf_ticker += "=X"
q = get_quote_with_volatility(yf_ticker) or {}
items.append({
**row,
"price": q.get("price"),