Add FastAPI backend for energy trading system
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.
This commit is contained in:
26
backend/app/api/routes/settings.py
Normal file
26
backend/app/api/routes/settings.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from fastapi import APIRouter
|
||||
from app.config import settings
|
||||
from app.models.schemas import AppSettings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("", response_model=AppSettings)
|
||||
async def get_settings():
|
||||
return AppSettings(
|
||||
battery_min_reserve=settings.BATTERY_MIN_RESERVE,
|
||||
battery_max_charge=settings.BATTERY_MAX_CHARGE,
|
||||
arbitrage_min_spread=settings.ARBITRAGE_MIN_SPREAD,
|
||||
mining_margin_threshold=settings.MINING_MARGIN_THRESHOLD,
|
||||
)
|
||||
|
||||
|
||||
@router.post("")
|
||||
async def update_settings(settings_update: dict):
|
||||
updated_fields = []
|
||||
for key, value in settings_update.items():
|
||||
if hasattr(settings, key.upper()):
|
||||
setattr(settings, key.upper(), value)
|
||||
updated_fields.append(key)
|
||||
|
||||
return {"message": "Settings updated", "updated_fields": updated_fields}
|
||||
Reference in New Issue
Block a user