feat: instrument analysis
This commit is contained in:
@@ -15,11 +15,16 @@ from services.instrument_service import (
|
||||
get_snapshot,
|
||||
get_narrative,
|
||||
update_instrument_drivers,
|
||||
update_instrument_saxo_link,
|
||||
)
|
||||
|
||||
class DriverUpdate(BaseModel):
|
||||
drivers: List[Dict[str, Any]]
|
||||
|
||||
|
||||
class SaxoLinkBody(BaseModel):
|
||||
saxo_symbol: Optional[str] = None
|
||||
|
||||
router = APIRouter(prefix="/api/instruments", tags=["instruments"])
|
||||
|
||||
|
||||
@@ -90,6 +95,25 @@ def update_drivers(instrument_id: str, body: DriverUpdate) -> Dict[str, Any]:
|
||||
return {"ok": True, "instrument_id": instrument_id.upper(), "drivers_count": len(body.drivers)}
|
||||
|
||||
|
||||
@router.put("/{instrument_id}/saxo-link")
|
||||
def set_saxo_link(instrument_id: str, body: SaxoLinkBody) -> Dict[str, Any]:
|
||||
"""Link this instrument to the Saxo symbol used to price it (chart, indicators, regime,
|
||||
wavelets) instead of yfinance — or pass null to unlink. Mirrors
|
||||
routers/instruments_watchlist.py's /{ticker}/saxo-quote-link, but persisted in
|
||||
instruments.json (this catalog's own store) rather than the instruments_watchlist table."""
|
||||
config = get_instrument(instrument_id)
|
||||
if not config:
|
||||
raise HTTPException(status_code=404, detail=f"Instrument '{instrument_id}' not found")
|
||||
|
||||
saxo_symbol = (body.saxo_symbol or "").strip().upper() or None
|
||||
try:
|
||||
update_instrument_saxo_link(instrument_id, saxo_symbol)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
return {"instrument_id": instrument_id.upper(), "saxo_quote_symbol": saxo_symbol}
|
||||
|
||||
|
||||
# ── Instrument mult (pips → price conversion) ─────────────────────────────────
|
||||
|
||||
_INST_MULT: Dict[str, int] = {"EURUSD": 10000, "GBPUSD": 10000, "USDJPY": 100, "AUDUSD": 10000}
|
||||
|
||||
Reference in New Issue
Block a user