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.
18 lines
601 B
Python
18 lines
601 B
Python
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"]
|