feat: saxo history

This commit is contained in:
OpenSquared
2026-07-19 08:49:57 +02:00
parent d4fb15ca9a
commit e7247d4c4c
5 changed files with 131 additions and 33 deletions

View File

@@ -6,7 +6,8 @@ from pydantic import BaseModel
from services import saxo_auth
from services.saxo_scheduler import get_watchlist, set_watchlist, get_snapshot_minutes, set_snapshot_minutes, run_snapshot_pass
from services.database import (
get_saxo_snapshots, get_saxo_snapshot_symbols, dedupe_saxo_snapshots,
get_saxo_snapshot_symbols, dedupe_saxo_snapshots,
get_snapshot_rows_asof, delete_saxo_snapshots,
get_saxo_catalog, get_saxo_catalog_summary, upsert_saxo_catalog_rows,
)
@@ -171,10 +172,18 @@ def quote(symbol: str, asset_type: str = Query("FxSpot")):
@router.get("/history")
def history(
symbol: Optional[str] = Query(None),
date_from: Optional[str] = Query(None),
date_to: Optional[str] = Query(None),
as_of: Optional[str] = Query(None, description="ISO datetime — replay the chain as it stood at/before this moment. Omit for the latest capture."),
):
return get_saxo_snapshots(symbol, date_from, date_to)
"""One row per (symbol, expiry, strike, type) — the latest capture, or the latest at/
before `as_of` to replay a past moment. The full 5-min history is retained underneath
for future backtest use; this endpoint only ever surfaces one row per contract."""
return get_snapshot_rows_asof(symbol, as_of)
@router.delete("/history/{symbol}")
def delete_history(symbol: str):
"""Wipes the full accumulated snapshot history for one symbol."""
return {"symbol": symbol.upper(), "rows_deleted": delete_saxo_snapshots(symbol.upper())}
class CatalogRefreshRequest(BaseModel):