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:
18
backend/app/ml/features/regional_features.py
Normal file
18
backend/app/ml/features/regional_features.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from typing import List
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def add_regional_features(df: pd.DataFrame, regions: List[str]) -> pd.DataFrame:
|
||||
result = df.copy()
|
||||
|
||||
if "region" in result.columns and "real_time_price" in result.columns:
|
||||
avg_price_by_region = result.groupby("region")["real_time_price"].mean()
|
||||
|
||||
for region in regions:
|
||||
region_avg = avg_price_by_region.get(region, 0)
|
||||
result[f"price_diff_{region}"] = result["real_time_price"] - region_avg
|
||||
|
||||
return result
|
||||
|
||||
|
||||
__all__ = ["add_regional_features"]
|
||||
Reference in New Issue
Block a user