Example #1
0
def _refresh_stats(x):
    _d_comb = x
    comb_prices_c = _d_comb.retrieve('Close')
    comb_prices_o = _d_comb.retrieve('Open')
    comb_prices_h = _d_comb.retrieve('High')
    comb_prices_l = _d_comb.retrieve('Low')

    # store the leverage
    for j in range(0, 4):
        jj = 30*(2**j)
        jjstr = str(jj)
        comb_vol = comb_prices_c.copy()
        for i in comb_vol.tick_cols():
            comb_vol[i] = crtf.vol_pb(comb_prices_o[i].values, comb_prices_h[i].values, comb_prices_l[i].values,
                                      comb_prices_c[i].values, jj)
            # comb_vol[i] = crtf.vol_cc(comb_prices[i].values, jj)   # changed it back
        comb_lev = comb_vol.copy()
        for i in comb_lev.tick_cols():
            comb_lev[i] = crtf.lrma(0.01/comb_vol[i].values, 30, lg=True)  # replace this by qrma_multi(3, 5)
        _d_comb.store('Lev_CC_'+jjstr+'D', comb_lev)
        for i in comb_vol.tick_cols():
            comb_vol[i] = crtf.lrma(comb_vol[i].values, 30, lg=True)  # replace this by qrma_multi(3, 5)
        _d_comb.store('Vol_CC_'+jjstr+'D', comb_vol)

    return None
Example #2
0
    # prod_ = 1
    prod_ = 1.33456825

    for i in test_.tick_cols():
        # i = test_.tick_cols()[0]
        test = test_[i].values
        testo = testo_[i].values
        testh = testh_[i].values
        testl = testl_[i].values
        testr = crtf.ret(test)

        test1cc = crtf.vol_cc(test, n, zl=True)
        test1tr = crtf.vol_ewma(test, n)
        test1p = crtf.vol_p(testo, testh, testl, test, n, zl=True)
        test1gk3 = crtf.vol_gk3(testo, test, n, zl=True)
        test1pb = crtf.vol_pb(testo, testh, testl, test, n, zl=True)
        test1rs = crtf.vol_rs(testo, testh, testl, test, n, zl=True)
        test1gk = crtf.vol_gk(testo, testh, testl, test, n, zl=True)
        test1yz = crtf.vol_yz(testo, testh, testl, test, n, zl=True)
        tmp = chk_vol(testr, test1cc*prod_)
        if ~np.isnan(tmp):
            res1cc += tmp
            cnt1cc += 1
        tmp = chk_vol(testr, test1tr)
        if ~np.isnan(tmp):
            res1tr += tmp
            cnt1tr += 1
        tmp = chk_vol(testr, test1p*prod_)
        if ~np.isnan(tmp):
            res1p += tmp
            cnt1p += 1