feat: cockpit
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user