feat: builder strategy

This commit is contained in:
OpenSquared
2026-07-19 11:08:17 +02:00
parent 67952e01fa
commit 8eb9cc1c05
2 changed files with 119 additions and 18 deletions

View File

@@ -167,6 +167,21 @@ def _compute_indicators(df: pd.DataFrame, config: Dict) -> Dict[str, Any]:
result["bb_lower"] = []
result["bb_mid"] = []
# Realized volatility (annualized %, rolling 20d stddev of log returns) — a "how
# turbulent has price action actually been" overlay, distinct from the market-implied
# vol computed elsewhere (vol_surface.py) for the options Strategy Builder.
vol_window = chart_cfg.get("volatility_window", 20)
if len(close) >= vol_window + 1:
log_ret = np.log(close / close.shift(1))
realized_vol = log_ret.rolling(vol_window).std() * np.sqrt(252) * 100
valid_vol = realized_vol.dropna()
result["volatility"] = [
{"time": idx.strftime("%Y-%m-%d"), "value": _round(val, 2)}
for idx, val in valid_vol.items()
]
else:
result["volatility"] = []
# RSI 14
if len(close) >= 15:
delta = close.diff()