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:
17
backend/app/ml/features/rolling_features.py
Normal file
17
backend/app/ml/features/rolling_features.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from typing import List
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def add_rolling_features(df: pd.DataFrame, col: str, windows: List[int]) -> pd.DataFrame:
|
||||
result = df.copy()
|
||||
|
||||
for window in windows:
|
||||
result[f"{col}_rolling_mean_{window}"] = result[col].rolling(window=window).mean()
|
||||
result[f"{col}_rolling_std_{window}"] = result[col].rolling(window=window).std()
|
||||
result[f"{col}_rolling_min_{window}"] = result[col].rolling(window=window).min()
|
||||
result[f"{col}_rolling_max_{window}"] = result[col].rolling(window=window).max()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
__all__ = ["add_rolling_features"]
|
||||
Reference in New Issue
Block a user