def test_hedge_ratio_tls(): model = odr.ODR( odr.Data(EWA, EWC), odr.Model(lambda B,x: B[0]*x + B[1]), beta0=[0,0]).run() assert_almost_equals( model.beta[0], hedge_ratio(EWA, EWC, method="tls"), places=10)
def cadf(x, y, method="ols", maxlag=1, regression="c"): beta = hr.hedge_ratio(x, y, method=method) return sms.adfuller( y - beta * x, maxlag=maxlag, regression=regression)
def test_hedge_ratio_bad_arg(): hedge_ratio(EWA, EWC, method="unknown")
def test_hedge_ratio_ols(): model = LinearRegression().fit(EWA[:,None], EWC) assert_almost_equals( model.coef_[0], hedge_ratio(EWA, EWC, method="ols"), places=10)