feat: saxo price

This commit is contained in:
OpenSquared
2026-07-30 18:02:30 +02:00
parent b8e2a5169c
commit bef0092ca8
4 changed files with 71 additions and 131 deletions

View File

@@ -227,34 +227,6 @@ def quick_add_instrument_from_watchlist(ticker: str) -> Dict[str, Any]:
return {"id": uid, "created": True}
def add_manual_instrument(
instrument_id: str, name: str, category: str,
yf_ticker: Optional[str] = None, saxo_quote_symbol: Optional[str] = None,
) -> Dict[str, Any]:
"""Create a standalone Instrument Analysis entry directly (Config page's "Ajouter un
ticker" zone) — same instrument_overrides row shape as quick_add_instrument_from_watchlist
above, but without requiring a pre-existing Cockpit Watchlist row, since the whole point
here is to add a ticker that isn't tracked anywhere yet (e.g. EURCHF, resolved live
against Saxo just before this call). Rejects an id that already resolves — use the
existing drivers/saxo-link editors to modify it instead of silently overwriting."""
global _configs
if _configs is None:
_load_configs()
uid = instrument_id.strip().upper()
if uid in _configs:
raise ValueError(f"'{uid}' existe déjà dans Instrument Analysis")
from services.database import set_instrument_override_quick_add
set_instrument_override_quick_add(
uid, name=name.strip() or uid, yf_ticker=(yf_ticker or uid).strip().upper(),
category=category, saxo_quote_symbol=saxo_quote_symbol,
)
_load_configs()
logger.info(f"[instrument_service] Manually added {uid} (category={category}, saxo={saxo_quote_symbol})")
return {"id": uid, "created": True}
# ── DataFrame helpers ──────────────────────────────────────────────────────────
def _ohlcv_to_df(records: List[Dict]) -> pd.DataFrame: