def config_varfunc(): if cm.getConfig('TEST_MODE'): PRE_DAY = cm.getConfig('PRE_DAY') else: PRE_DAY = 0 varname = cm.getConfig('varname') varfunc = [lambda dl, sfid: sfid, \ lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 5, PRE_DAY), \ lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 10,PRE_DAY), \ lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 15,PRE_DAY), \ lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 1,PRE_DAY), \ lambda dl, sfid: float('%.2f'%watterson_lib.average(dl, 20, PRE_DAY)), \ lambda dl, sfid: dl[-1-PRE_DAY].cl, \ lambda dl, sfid: 'LV2 ratio', \ lambda dl, sfid: get_rd1(dl, sfid), \ lambda dl, sfid: watterson_lib.get_last_dline_ftime(dl,PRE_DAY), \ lambda dl, sfid: watterson_lib.get_stname(sfid), \ lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 30, PRE_DAY), \ lambda dl, sfid: watterson_lib.variance(dl, 30, PRE_DAY), \ #lambda dl, sfid: watterson_lib.delta_ratio_reverse(dl, 180, PRE_DAY), \ lambda dl, sfid: 0, \ lambda dl, sfid: watterson_lib.fast_grow(dl, 30, PRE_DAY), \ lambda dl, sfid: watterson_lib.fast_fall(dl, 30, PRE_DAY), \ lambda dl, sfid: watterson_lib.tdx_delta(sfid, PRE_DAY),\ lambda dl, sfid: watterson_lib.delta_d1(dl,4,PRE_DAY)] cm.setConfig('varname', varname) cm.setConfig('varfunc', varfunc)
def get_rd1(dl ,sfid): if cm.getConfig('TEST_MODE'): PD = cm.getConfig('PRE_DAY') PRD = cm.getConfig('PRE_DAY_CHECK_DAY') return watterson_lib.delta_ratio_reverse(dl,PRD,PD-PRD) else: return '_'
def get_rd1(dl, sfid): if cm.getConfig('TEST_MODE'): PD = cm.getConfig('PRE_DAY') PRD = cm.getConfig('PRE_DAY_CHECK_DAY') return watterson_lib.delta_ratio_reverse(dl, PRD, PD - PRD) else: return '_'
import watterson_lib import tdx2 dline = tdx2.get_dayline_by_fid('sh000001', 5) a = 1 for k in dline: a = a + 1 k.cl=a for k in dline: print k.ftime,k.cl pd = 3 prd = 2 d1 = watterson_lib.delta_ratio_reverse(dline, 1, 1) d2 = watterson_lib.delta_ratio_reverse(dline, 1, 0) d3 = watterson_lib.average(dline, 2, 0) d4 = watterson_lib.variance(dline, 2, 0) print d1, d2, d3, d4
import watterson_lib import tdx2 dline = tdx2.get_dayline_by_fid('sh000001', 5) a = 1 for k in dline: a = a + 1 k.cl = a for k in dline: print k.ftime, k.cl pd = 3 prd = 2 d1 = watterson_lib.delta_ratio_reverse(dline, 1, 1) d2 = watterson_lib.delta_ratio_reverse(dline, 1, 0) d3 = watterson_lib.average(dline, 2, 0) d4 = watterson_lib.variance(dline, 2, 0) print d1, d2, d3, d4