-Assume the change is larger when the ratio is further from the constant as $$\Delta P_1/P_2 = k(\text{constant} - P_1/P_2)$$ for a constant $k>0$.
where $a=k \times \text{constant}$, $b=-k$.
data.ratio.plot(label="CVX/COP")
plt.hlines(
y=-a/b,
xmin = data.index[0],
xmax=data.index[-1],
color="red",
label="constant"
)
plt.legend(loc="lower right")
plt.show()
print(f"mean return of pairs strategy = {252*data.ret.mean():.2%} annualized")
print(f"correlation of pairs strategy with market = {data.ret.corr(data.mkt):.2%}")
mean return of pairs strategy = 5.19% annualized correlation of pairs strategy with market = 4.94%
print(f"mean return of pairs strategy = {252*future.ret.mean():.2%} annualized")
print(f"correlation of pairs strategy with market = {future.ret.corr(future.mkt):.2%}")
mean return of pairs strategy = 5.48% annualized correlation of pairs strategy with market = 10.74%
beta = future.ret.corr(future.mkt) * future.ret.std() / future.mkt.std()
alpha = future.ret.mean() - beta * future.mkt.mean()
print(f"beta is {beta:.4f}")
print(f"annualized alpha is {252*alpha:.2%}")
beta is 0.0011 annualized alpha is 4.19%
import statsmodels.formula.api as smf
smf.ols("ret~mkt", future).fit().summary()
Dep. Variable: | ret | R-squared: | 0.012 |
---|---|---|---|
Model: | OLS | Adj. R-squared: | 0.011 |
Method: | Least Squares | F-statistic: | 25.15 |
Date: | Sat, 28 Oct 2023 | Prob (F-statistic): | 5.75e-07 |
Time: | 11:42:18 | Log-Likelihood: | 6431.3 |
No. Observations: | 2157 | AIC: | -1.286e+04 |
Df Residuals: | 2155 | BIC: | -1.285e+04 |
Df Model: | 1 | ||
Covariance Type: | nonrobust |
coef | std err | t | P>|t| | [0.025 | 0.975] | |
---|---|---|---|---|---|---|
Intercept | 0.0002 | 0.000 | 0.758 | 0.448 | -0.000 | 0.001 |
mkt | 0.0011 | 0.000 | 5.015 | 0.000 | 0.001 | 0.002 |
Omnibus: | 438.977 | Durbin-Watson: | 1.951 |
---|---|---|---|
Prob(Omnibus): | 0.000 | Jarque-Bera (JB): | 11512.640 |
Skew: | 0.267 | Prob(JB): | 0.00 |
Kurtosis: | 14.305 | Cond. No. | 1.20 |