summaryrefslogtreecommitdiff
path: root/services/api/src/trading_api/routers/strategies.py
blob: 2861eec3e92fe7c4d2f1809940dfdd326b0bc7cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Strategy endpoints."""

import sys
from pathlib import Path

from fastapi import APIRouter

# 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))

router = APIRouter()


@router.get("/")
async def list_strategies():
    """List available strategies."""
    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
    ]