Files
energy-trade/backend/app/ml/features/rolling_features.py
kbt-devops fe76bc7629 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.
2026-02-12 00:59:26 +07:00

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"]