feat: saxo price

This commit is contained in:
OpenSquared
2026-07-23 10:46:24 +02:00
parent a136d6ae11
commit 7267443d5b
4 changed files with 31 additions and 7 deletions

View File

@@ -187,7 +187,7 @@ def delete_history(symbol: str):
class CatalogRefreshRequest(BaseModel):
asset_types: Optional[List[str]] = None # default: CATALOG_ASSET_TYPES (FuturesOption, FxVanillaOption)
asset_types: Optional[List[str]] = None # default: CATALOG_ASSET_TYPES (FuturesOption, FxVanillaOption, ContractFutures, FxSpot)
@router.post("/catalog/refresh")

View File

@@ -6387,12 +6387,15 @@ def upsert_saxo_catalog_rows(rows: List[Dict[str, Any]]):
def get_saxo_catalog(asset_type: Optional[str] = None, q: Optional[str] = None, limit: int = 200) -> List[Dict[str, Any]]:
"""asset_type accepts a single value or a comma-separated list (e.g. the Instruments
Watchlist "Option" picker passes all 4 option AssetTypes at once)."""
conn = get_conn()
query = "SELECT * FROM saxo_instrument_catalog WHERE 1=1"
params: List[Any] = []
if asset_type:
query += " AND asset_type=?"
params.append(asset_type)
types = [t.strip() for t in asset_type.split(",") if t.strip()]
query += f" AND asset_type IN ({','.join('?' * len(types))})"
params.extend(types)
if q:
query += " AND (symbol LIKE ? OR description LIKE ?)"
params.extend([f"%{q}%", f"%{q}%"])

View File

@@ -60,7 +60,17 @@ def _synthesize_quote(
# Bounded, stable catalogs worth fully caching in our own DB (StockOption/StockIndexOption
# are far too large to bulk-fetch — those stay resolved on demand via Keywords search).
CATALOG_ASSET_TYPES = ["FuturesOption", "FxVanillaOption"]
# ContractFutures (outright futures — Brent, WTI, Gold, Copper, index e-minis) and FxSpot
# (FX pairs) are the underlying-side equivalents of the option types above — added so the
# Instruments Watchlist "Quote" link (services.database.set_instrument_watchlist_saxo_quote_symbol)
# has a real catalog to search instead of only ever finding option instruments.
CATALOG_ASSET_TYPES = ["FuturesOption", "FxVanillaOption", "ContractFutures", "FxSpot"]
# Which of CATALOG_ASSET_TYPES are options (Instruments Watchlist "Option" picker) vs.
# underlyings (the "Quote" picker) — see routers/instruments_watchlist.py's saxo-*-link
# endpoints and frontend/src/pages/Config.tsx's SaxoLinkPicker.
OPTION_ASSET_TYPES = ["FuturesOption", "FxVanillaOption", "StockOption", "StockIndexOption"]
UNDERLYING_ASSET_TYPES = ["ContractFutures", "FxSpot", "StockIndex"]
# symbol -> resolved instrument details, cheap in-process cache (roots don't change within a session)
_root_uic_cache: Dict[str, Dict[str, Any]] = {}