feat: saxo history

This commit is contained in:
OpenSquared
2026-07-18 18:59:27 +02:00
parent 212bdf6678
commit 2fea64a967

View File

@@ -24,7 +24,7 @@ from services.saxo_auth import SAXO_API_BASE_URL, get_valid_access_token
logger = logging.getLogger(__name__)
_OPTION_ASSET_TYPES = "StockOption,StockIndexOption,FuturesOption,ContractFutures"
_OPTION_ASSET_TYPES = "StockOption,StockIndexOption,FuturesOption,ContractFutures,FxOption"
# symbol -> resolved instrument details, cheap in-process cache (roots don't change within a session)
_root_uic_cache: Dict[str, Dict[str, Any]] = {}
@@ -191,11 +191,12 @@ def snapshot_options_chain(symbol: str, target_days: int = 30) -> List[Dict[str,
{symbol, snapshot_date, spot, expiry_date, strike, option_type, bid, ask, mid,
volatility_pct, delta, gamma, theta, vega}
"""
root_uic = resolve_option_root_uic(symbol)
instrument = resolve_instrument(symbol)
root_uic = instrument["uic"]
space = get_option_space(root_uic)
legs = _extract_option_legs(space)
snapshot = _snapshot_via_subscription(root_uic)
snapshot = _snapshot_via_subscription(root_uic, asset_type=instrument["asset_type"] or "StockOption")
spot = _first(snapshot, "UnderlyingSpotPrice", "Spot", "UnderlyingPrice")
snapshot_date = date.today().isoformat()