feat: cockpit

This commit is contained in:
OpenSquared
2026-07-24 11:46:37 +02:00
parent ae732c5822
commit 35a00f43c3
6 changed files with 201 additions and 13 deletions

View File

@@ -16,6 +16,7 @@ from services.instrument_service import (
get_narrative,
update_instrument_drivers,
update_instrument_saxo_link,
quick_add_instrument_from_watchlist,
)
class DriverUpdate(BaseModel):
@@ -25,6 +26,10 @@ class DriverUpdate(BaseModel):
class SaxoLinkBody(BaseModel):
saxo_symbol: Optional[str] = None
class QuickAddBody(BaseModel):
ticker: str
router = APIRouter(prefix="/api/instruments", tags=["instruments"])
@@ -36,6 +41,16 @@ def list_instruments() -> List[Dict[str, Any]]:
return get_all_instruments()
@router.post("/quick-add")
def quick_add(body: QuickAddBody) -> Dict[str, Any]:
"""Bring a Cockpit Watchlist ticker into Instrument Analysis on the fly, copying over
its saxo_quote_symbol link automatically — see instrument_service.quick_add_instrument_from_watchlist."""
try:
return quick_add_instrument_from_watchlist(body.ticker)
except ValueError as e:
raise HTTPException(status_code=404, detail=str(e))
@router.get("/{instrument_id}/snapshot")
async def instrument_snapshot(
instrument_id: str,