コード例 #1
0
ファイル: hedge_ratio_test.py プロジェクト: davidells/mypy
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)
コード例 #2
0
ファイル: mean_reversion.py プロジェクト: davidells/mypy
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)
コード例 #3
0
ファイル: hedge_ratio_test.py プロジェクト: davidells/mypy
def test_hedge_ratio_bad_arg():
    hedge_ratio(EWA, EWC, method="unknown")
コード例 #4
0
ファイル: hedge_ratio_test.py プロジェクト: davidells/mypy
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)