feat: curve regime

This commit is contained in:
OpenSquared
2026-07-25 08:53:07 +02:00
parent 27678e6b8d
commit 3addea6850
3 changed files with 548 additions and 2 deletions

View File

@@ -100,6 +100,29 @@ def wavelet_cache(instrument_id: str) -> Dict[str, Any]:
}
@router.get("/{instrument_id}/curve-regime")
async def curve_regime(
instrument_id: str,
period: str = Query(default="1y"),
interval: str = Query(default="1d"),
) -> Dict[str, Any]:
"""Instrument-level regime classification (Direction/Dynamique/Volatilité/Structure IV,
matched against the 15-regime reference table) — distinct from the global macro regime
already shown elsewhere. See services.curve_regime module docstring for the full
methodology and its data-availability caveats (no cross-asset correlation source,
structure_iv only available when this instrument's options chain is Saxo-linked)."""
config = get_instrument(instrument_id)
if not config:
raise HTTPException(status_code=404, detail=f"Instrument '{instrument_id}' not found")
snapshot = await get_snapshot(instrument_id, period=period, interval=interval)
if "error" in snapshot:
raise HTTPException(status_code=500, detail=snapshot["error"])
from services.curve_regime import classify_instrument_regime
return classify_instrument_regime(instrument_id, snapshot)
@router.post("/{instrument_id}/narrative")
async def generate_narrative(
instrument_id: str,