Implements FastAPI backend with ML model support for energy trading, including price prediction models and RL-based battery trading policy. Features dashboard, trading, backtest, and settings API routes with WebSocket support for real-time updates.
28 lines
825 B
Python
28 lines
825 B
Python
from typing import List
|
|
from fastapi import APIRouter, HTTPException
|
|
from app.models.enums import StrategyEnum
|
|
from app.models.schemas import StrategyStatus
|
|
from app.services import StrategyService
|
|
|
|
router = APIRouter()
|
|
strategy_service = StrategyService()
|
|
|
|
|
|
@router.get("/strategies", response_model=List[StrategyStatus])
|
|
async def get_strategies():
|
|
return await strategy_service.get_all_strategies()
|
|
|
|
|
|
@router.post("/strategies")
|
|
async def toggle_strategy(strategy: StrategyEnum, action: str):
|
|
if action not in ["start", "stop"]:
|
|
raise HTTPException(status_code=400, detail="Action must be 'start' or 'stop'")
|
|
|
|
status = await strategy_service.toggle_strategy(strategy, action)
|
|
return {"status": status}
|
|
|
|
|
|
@router.get("/positions")
|
|
async def get_positions():
|
|
return {"positions": [], "total": 0}
|