Normalize one-point regression residual volatility

This commit is contained in:
2026-04-07 17:02:00 +08:00
parent 18174a9e11
commit f6670d9e6d
2 changed files with 22 additions and 1 deletions

View File

@@ -309,7 +309,10 @@ def run_factor_regression(
fitted = x @ coefficients
residuals = y.to_numpy() - fitted
residual_series = pd.Series(residuals, index=regression_frame.index)
residual_vol_ann = float(residual_series.std(ddof=1) * np.sqrt(TRADING_DAYS_PER_YEAR))
if len(residual_series) == 1:
residual_vol_ann = 0.0
else:
residual_vol_ann = float(residual_series.std(ddof=1) * np.sqrt(TRADING_DAYS_PER_YEAR))
dof = n_obs - param_count
if dof > 0: