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.
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
from pathlib import Path
|
|
from typing import List, Union
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
APP_NAME: str = "Energy Trading API"
|
|
APP_VERSION: str = "1.0.0"
|
|
DEBUG: bool = True
|
|
|
|
HOST: str = "0.0.0.0"
|
|
PORT: int = 8000
|
|
|
|
DATA_PATH: str = "~/energy-test-data/data/processed"
|
|
DATA_PATH_RESOLVED: Path = Path(DATA_PATH).expanduser()
|
|
|
|
CORS_ORIGINS: Union[str, List[str]] = [
|
|
"http://localhost:3000",
|
|
"http://localhost:5173",
|
|
]
|
|
|
|
WS_HEARTBEAT_INTERVAL: int = 30
|
|
|
|
CELERY_BROKER_URL: str = "redis://localhost:6379/0"
|
|
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/0"
|
|
|
|
MODELS_PATH: str = "models"
|
|
RESULTS_PATH: str = "results"
|
|
|
|
BATTERY_MIN_RESERVE: float = 0.10
|
|
BATTERY_MAX_CHARGE: float = 0.90
|
|
|
|
ARBITRAGE_MIN_SPREAD: float = 5.0
|
|
MINING_MARGIN_THRESHOLD: float = 5.0
|
|
|
|
ML_PREDICTION_HORIZONS: List[int] = [1, 5, 15, 60]
|
|
ML_FEATURE_LAGS: List[int] = [1, 5, 10, 15, 30, 60]
|
|
|
|
model_config = SettingsConfigDict(env_file=".env", case_sensitive=True, env_ignore_empty=True)
|
|
|
|
@property
|
|
def cors_origins_list(self) -> List[str]:
|
|
if isinstance(self.CORS_ORIGINS, str):
|
|
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
|
|
return self.CORS_ORIGINS if isinstance(self.CORS_ORIGINS, list) else []
|
|
|
|
|
|
settings = Settings()
|