"""Strategy endpoints.""" import logging import sys from pathlib import Path from fastapi import APIRouter, HTTPException # Add strategy-engine to path for plugin loading _STRATEGY_DIR = Path(__file__).resolve().parents[5] / "strategy-engine" if str(_STRATEGY_DIR) not in sys.path: sys.path.insert(0, str(_STRATEGY_DIR)) logger = logging.getLogger(__name__) router = APIRouter() @router.get("/") async def list_strategies(): """List available strategies.""" try: from strategy_engine.plugin_loader import load_strategies strategies_dir = _STRATEGY_DIR / "strategies" strategies = load_strategies(strategies_dir) return [ { "name": s.name, "warmup_period": s.warmup_period, "class": type(s).__name__, } for s in strategies ] except Exception as exc: logger.error("Failed to list strategies: %s", exc) raise HTTPException(status_code=500, detail="Failed to list strategies")