Python으로 시작하는 포트폴리오 리스크 관리
Dakota Wixom
Quantitative Analyst | QuantCourse.com
$$ R_{P} = $$
$$ RF + \beta_{M}(R_{M}-RF)+b_{SMB} \cdot SMB + b_{HML} \cdot HML + \alpha $$

Data 객체에 초과 포트폴리오 수익률과 시장 수익률이 있다고 가정합니다:
import statsmodels.formula.api as smf
model = smf.ols(formula='Port_Excess ~ Mkt_Excess + SMB + HML',
data=Data)
fit = model.fit()
adjusted_r_squared = fit.rsquared_adj
adjusted_r_squared
0.90
fit 객체에 적합된 회귀 모델이 있다고 가정할 때, HML p-값 추출:
fit.pvalues["HML"]
0.0063
통계적 유의성 검정: 값이 일반적으로 0.05인 임계값보다 작은지 확인합니다:
fit.pvalues["HML"] < 0.05
True
fit 객체에 적합된 회귀 모델이 있다고 가정할 때, HML 계수 추출:
fit.params["HML"]
0.502
fit.params["SMB"]
-0.243
fit 객체에 이미 적합된 회귀 분석이 있다고 가정합니다:
portfolio_alpha = fit.params["Intercept"]
portfolio_alpha_annualized = ((1 + portfolio_alpha) ** 252) - 1
portfolio_alpha_annualized
0.045
Python으로 시작하는 포트폴리오 리스크 관리