예제 #1
0
def up_in_day(stock, xup=200):  #xup为涨停次日的开盘涨幅,万分位表示
    ''' 次日开盘小于x%则不追,追进次日开盘小于2%则卖出,收盘未涨停也卖出
        需要屏蔽一字涨停的情况
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    

        200/-25,-50
        评估:总盈亏值=-10690,交易次数=1194      期望值=-237
                总盈亏率(1/1000)=-10690,平均盈亏率(1/1000)=-9,盈利交易率(1/1000)=268
                平均持仓时间=1,持仓效率(1/1000000)=-9000
                赢利次数=321,赢利总值=22580
                亏损次数=862,亏损总值=33270
                平盘次数=11


        最后发现,第一小时涨停的,第二天追击的风险最大,第二小时涨停的最好,但也都是负的
        
    '''
    linelog('%s:%s' % (up_in_day.__name__, stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]), t[VOLUME])
    #yup = rollx(gand(stock.slup1,climit),1)  #昨日开盘前两小时涨停并且收盘封住
    yup = rollx(climit, 1)
    pre = rollx(t[CLOSE], 1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)  #今日开盘大于xup
    tx = np.sign(t[LOW] * 10000 / pre <= 10990)  #非一字涨停,追
    #tv = xfollow(t[VOLUME].copy(),t[VOLUME])    #不能更改t[VOLUME]本身

    #xmacd = rollx((stock.diff-stock.dea) * 1000 / stock.ma3 > 10,1)
    #fmacd = rollx(stock.diff > stock.dea,1)
    #tdea = strend(stock.dea) < 30

    #u30 = rollx(t[CLOSE]>stock.ma3,1)
    #fma = rollx(gand(stock.ma1 > stock.ma2),1)#,stock.ma2>stock.ma4,stock.ma3>stock.ma4),1)

    #lol = rollx( t[OPEN] * 97 < t[LOW]*100,1) #昨日涨停,但反向震荡不超过3%

    #tlimit = tv / 6 < rollx(tv,1)       #量不能超过前日6倍,越等于开盘量小于前日1/3?
    #tt = rollx(gand(stock.t5,stock.t4,stock.t3,strend(ma(t[CLOSE],250))>0),1) #以昨日趋势为准
    tt = gand(stock.t5, stock.t4,
              strend(ma(t[CLOSE], 250)) > 0)  #不采用跳点法,可能这是一个敏感位置
    #mg5 = ma(stock.g5,5)
    #xcross = gand(cross(mg5,stock.g5)>0,strend(stock.g5)>0)
    #g = rollx(gand(stock.g60>9000,stock.g20>9000,xcross),1)

    #涨停需要领袖群雄10天
    #hh10 = tmax(t[HIGH],10)
    #peak = pre > rollx(hh10,2)

    ama = fama(t[CLOSE])
    rama = rollx(ama * 1000 / rollx(ama) > 995)  #-284, p=342

    signal = gand(yup, tup, tx, t[VOLUME] > 0,
                  tt)  #,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal, 3)
    stock.buyprice = select([dsignal > 0], [t[OPEN]])
    #print signal

    return dsignal
예제 #2
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def up_in_day(stock,xup=200):#xup为涨停次日的开盘涨幅,万分位表示
    ''' 次日开盘小于x%则不追,追进次日开盘小于2%则卖出,收盘未涨停也卖出
        需要屏蔽一字涨停的情况
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    

        200/-25,-50
        评估:总盈亏值=-10690,交易次数=1194      期望值=-237
                总盈亏率(1/1000)=-10690,平均盈亏率(1/1000)=-9,盈利交易率(1/1000)=268
                平均持仓时间=1,持仓效率(1/1000000)=-9000
                赢利次数=321,赢利总值=22580
                亏损次数=862,亏损总值=33270
                平盘次数=11


        最后发现,第一小时涨停的,第二天追击的风险最大,第二小时涨停的最好,但也都是负的
        
    '''
    linelog('%s:%s' % (up_in_day.__name__,stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]),t[VOLUME])
    #yup = rollx(gand(stock.slup1,climit),1)  #昨日开盘前两小时涨停并且收盘封住
    yup = rollx(climit,1)
    pre = rollx(t[CLOSE],1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)    #今日开盘大于xup
    tx = np.sign(t[LOW] * 10000 / pre <= 10990)    #非一字涨停,追
    #tv = xfollow(t[VOLUME].copy(),t[VOLUME])    #不能更改t[VOLUME]本身

    #xmacd = rollx((stock.diff-stock.dea) * 1000 / stock.ma3 > 10,1)
    #fmacd = rollx(stock.diff > stock.dea,1)
    #tdea = strend(stock.dea) < 30

    #u30 = rollx(t[CLOSE]>stock.ma3,1)
    #fma = rollx(gand(stock.ma1 > stock.ma2),1)#,stock.ma2>stock.ma4,stock.ma3>stock.ma4),1)

    #lol = rollx( t[OPEN] * 97 < t[LOW]*100,1) #昨日涨停,但反向震荡不超过3%

    #tlimit = tv / 6 < rollx(tv,1)       #量不能超过前日6倍,越等于开盘量小于前日1/3?
    #tt = rollx(gand(stock.t5,stock.t4,stock.t3,strend(ma(t[CLOSE],250))>0),1) #以昨日趋势为准
    tt = gand(stock.t5,stock.t4,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置
    #mg5 = ma(stock.g5,5)
    #xcross = gand(cross(mg5,stock.g5)>0,strend(stock.g5)>0)
    #g = rollx(gand(stock.g60>9000,stock.g20>9000,xcross),1)
    
    #涨停需要领袖群雄10天
    #hh10 = tmax(t[HIGH],10)
    #peak = pre > rollx(hh10,2)
    
    ama = fama(t[CLOSE])
    rama = rollx(ama*1000/rollx(ama)>995)   #-284, p=342

    signal = gand(yup,tup,tx,t[VOLUME]>0,tt)#,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal,3)
    stock.buyprice = select([dsignal>0],[t[OPEN]])
    #print signal

    return dsignal
예제 #3
0
파일: hfuncs.py 프로젝트: pophoo/foxengine
def prepare_up1(stock):
    #linelog('prepare up1:%s' % stock.code)
    #up = stock.hour * 10000 / rollx(stock.hour,1) >= 10200
    down =stock.hour_high - stock.hour < (stock.hour-stock.hour_open)*2/3
    ol = stock.hour > stock.hour_open
    tk = stock.hour_low > rollx(stock.hour_high)
    up = stock.hour * 10000 / gmin(rollx(stock.hour,1),stock.hour_open) > 10200
    stock.up1 =  xfollow(hour2day1(gand(up,down,ol,tk)),stock.transaction[VOLUME])
    stock.open2 = hour2day2(stock.hour_open)
예제 #4
0
def attack2(stock, xup=200):  #
    ''' 盘中追第二个涨停
    '''
    linelog('%s:%s' % (attack2.__name__, stock.code))
    t = stock.transaction

    ama = fama(t[CLOSE])
    rama = rollx(t[CLOSE] * 1000 / rollx(ama) >= 1030)  #-284, p=342

    lup1 = gand((limitup1(t[CLOSE])), t[OPEN] * 10000 / t[LOW] < 10050)

    climit = xfollow(lup1, t[VOLUME])
    #climit = xfollow(limitup2(t[HIGH],t[LOW]),t[VOLUME])   #一字板
    #yup = rollx(gand(stock.slup2,climit,bnot(stock.slup1)),1)  #昨日第二小时涨停并且收盘封住
    yup = rollx(gand(stock.slup2, stock.stoped3, climit, bnot(stock.slup1)),
                1)  #昨日第二小时涨停并且至收盘都没打开过,含第一小时

    #大盘因素
    #smarket = rollx(gand(stock.ref.t2,stock.ref.t1,stock.ref.t0),1)
    smarket = gand(stock.ref.t2, stock.ref.t1, stock.ref.t0)
    #smarket = gand(strend(stock.ref.diff)>0,strend(stock.ref.diff-stock.ref.dea)>0)

    #yup = gand(stock.slup3,bnot(stock.stoped4))  #前3小时涨停,并且在第四小时打开过
    #yup2 = gand(stock.slup2,bnot(gand(stock.stoped3,stock.stoped4)),bnot(stock.slup1))  #第2小时开始涨停,并且在第3-4小时打开过,否则买不到
    #yup3 = gand(stock.slup3,bnot(stock.stoped4),bnot(gand(stock.slup1,stock.slup2)))
    #yup2 = gand(stock.touch2,bnot(stock.slup1))  #第2小时开始触及涨停
    #yup3 = gand(stock.touch3,bnot(gand(stock.slup1,stock.slup2)))
    #yup=gor(yup2,yup3)
    cup = gand(stock.up1, yup,
               bnot(gand(stock.stoped3, stock.stoped4, stock.stoped2)))

    #因为此时追击点在下午开盘,所以可以观察大盘

    #yup = gand(stock.slup1,bnot(gand(stock.stoped2,stock.stoped3,stock.stoped4)))  #前1小时涨停,并且在第四小时打开过
    #无法判断第四小时涨停的个股涨停后是否打开过

    #必须是跳空且缺口不补

    pre = rollx(t[CLOSE], 1)
    tup = np.sign(t[OPEN] * 10000 / pre <= xup + 10000)  #今日开盘大于xup,这个条件是反作用

    #c_ex = lambda c,s:gand(c.g60>3000,s>3000)
    #cs = catalog_signal_cs(stock.c60,c_ex)

    signal = gand(cup, t[VOLUME] > 0, stock.ref.up1
                  )  #smarket)#,rama) #,rama  #,tt,peak)#,fmacd,xmacd)  #rama
    #signal = gand(cup,t[VOLUME]>0,rama,r1,smarket,tup)#,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal, 3)
    #stock.buyprice = select([dsignal>0],[t[HIGH]])     #涨停价
    stock.buyprice = select([dsignal > 0], [stock.open2])  #第二小时开盘
    #print signal

    return dsignal
예제 #5
0
def prepare_up1(stock):
    linelog('prepare hour:%s' % stock.code)
    #up = stock.hour * 10000 / rollx(stock.hour,1) >= 10200
    down = stock.hour_high - stock.hour < (stock.hour -
                                           stock.hour_open) * 2 / 3
    ol = stock.hour > stock.hour_open
    tk = stock.hour_low > rollx(stock.hour_high)
    up = stock.hour * 10000 / gmin(rollx(stock.hour, 1),
                                   stock.hour_open) > 10200
    stock.up1 = xfollow(hour2day1(gand(up, down, ol, tk)),
                        stock.transaction[VOLUME])
    stock.open2 = hour2day2(stock.hour_open)
예제 #6
0
파일: hfuncs.py 프로젝트: pophoo/foxengine
def prepare_index(stock,begin,end):
    linelog('prepare hour:%s' % stock.code)
    t = get_hour(stock.code,begin,end)
    stock.hour = t[CLOSE].copy()
    stock.hour_open = t[OPEN].copy()
    stock.hour_low = t[LOW].copy()
    stock.hour_high = t[HIGH].copy()
    stock.hour_v = t[VOLUME].copy()
    stock.hour[range4(len(stock.hour))] = np.cast['int32'](stock.transaction[CLOSE])   #消除第4小时数据收盘与当日收盘价的差异,日收盘价为最后均价
    down =stock.hour_high - stock.hour < (stock.hour-stock.hour_open)*2/3
    ol = stock.hour > stock.hour_open
    stock.up1 =  xfollow(hour2day1(gand(down,ol)),stock.transaction[VOLUME])
    stock.open2 = hour2day2(stock.hour_open)
예제 #7
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def attack2(stock,xup=200):#
    ''' 盘中追第二个涨停
    '''
    linelog('%s:%s' % (attack2.__name__,stock.code))
    t = stock.transaction
    
    ama = fama(t[CLOSE])
    rama = rollx(t[CLOSE]*1000/rollx(ama)>=1030)   #-284, p=342

    lup1 = gand((limitup1(t[CLOSE])),t[OPEN]*10000/t[LOW]<10050)

    climit = xfollow(lup1,t[VOLUME])
    #climit = xfollow(limitup2(t[HIGH],t[LOW]),t[VOLUME])   #一字板
    #yup = rollx(gand(stock.slup2,climit,bnot(stock.slup1)),1)  #昨日第二小时涨停并且收盘封住
    yup = rollx(gand(stock.slup2,stock.stoped3,climit,bnot(stock.slup1)),1)  #昨日第二小时涨停并且至收盘都没打开过,含第一小时

    #大盘因素
    #smarket = rollx(gand(stock.ref.t2,stock.ref.t1,stock.ref.t0),1)
    smarket = gand(stock.ref.t2,stock.ref.t1,stock.ref.t0)
    #smarket = gand(strend(stock.ref.diff)>0,strend(stock.ref.diff-stock.ref.dea)>0)

    #yup = gand(stock.slup3,bnot(stock.stoped4))  #前3小时涨停,并且在第四小时打开过
    #yup2 = gand(stock.slup2,bnot(gand(stock.stoped3,stock.stoped4)),bnot(stock.slup1))  #第2小时开始涨停,并且在第3-4小时打开过,否则买不到
    #yup3 = gand(stock.slup3,bnot(stock.stoped4),bnot(gand(stock.slup1,stock.slup2))) 
    #yup2 = gand(stock.touch2,bnot(stock.slup1))  #第2小时开始触及涨停
    #yup3 = gand(stock.touch3,bnot(gand(stock.slup1,stock.slup2))) 
    #yup=gor(yup2,yup3)
    cup = gand(stock.up1,yup,bnot(gand(stock.stoped3,stock.stoped4,stock.stoped2)))

    #因为此时追击点在下午开盘,所以可以观察大盘

    #yup = gand(stock.slup1,bnot(gand(stock.stoped2,stock.stoped3,stock.stoped4)))  #前1小时涨停,并且在第四小时打开过
    #无法判断第四小时涨停的个股涨停后是否打开过

    #必须是跳空且缺口不补

    pre=rollx(t[CLOSE],1)
    tup = np.sign(t[OPEN] * 10000 / pre <= xup + 10000)    #今日开盘大于xup,这个条件是反作用

    #c_ex = lambda c,s:gand(c.g60>3000,s>3000)
    #cs = catalog_signal_cs(stock.c60,c_ex)    

    signal = gand(cup,t[VOLUME]>0,stock.ref.up1)#smarket)#,rama) #,rama  #,tt,peak)#,fmacd,xmacd)  #rama
    #signal = gand(cup,t[VOLUME]>0,rama,r1,smarket,tup)#,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal,3)
    #stock.buyprice = select([dsignal>0],[t[HIGH]])     #涨停价
    stock.buyprice = select([dsignal>0],[stock.open2])     #第二小时开盘
    #print signal

    return dsignal
예제 #8
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def up_in_hour1(stock,xup=200):#xup为涨停次日的开盘涨幅,万分位表示
    '''第1小时涨停'''
    linelog('%s:%s' % (up_in_hour1.__name__,stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]),t[VOLUME])
    yup = rollx(gand(stock.slup1,climit),1)  #昨日开盘第一小时涨停并且收盘封住
    pre = rollx(t[CLOSE],1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)    #今日开盘大于xup
    tx = np.sign(t[LOW] * 10000 / pre <= 10990)    #非一字涨停,追
    tt = gand(stock.t5,stock.t4,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置

    signal = gand(yup,tup,tx,t[VOLUME]>0,tt)#,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal,3)
    stock.buyprice = select([dsignal>0],[t[OPEN]])
    #print signal

    return dsignal
예제 #9
0
def up_in_hour1(stock, xup=200):  #xup为涨停次日的开盘涨幅,万分位表示
    '''第1小时涨停'''
    linelog('%s:%s' % (up_in_hour1.__name__, stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]), t[VOLUME])
    yup = rollx(gand(stock.slup1, climit), 1)  #昨日开盘第一小时涨停并且收盘封住
    pre = rollx(t[CLOSE], 1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)  #今日开盘大于xup
    tx = np.sign(t[LOW] * 10000 / pre <= 10990)  #非一字涨停,追
    tt = gand(stock.t5, stock.t4,
              strend(ma(t[CLOSE], 250)) > 0)  #不采用跳点法,可能这是一个敏感位置

    signal = gand(yup, tup, tx, t[VOLUME] > 0,
                  tt)  #,rama)   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal, 3)
    stock.buyprice = select([dsignal > 0], [t[OPEN]])
    #print signal

    return dsignal
예제 #10
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def prepare_touch4(stock):
    linelog('prepare hour:%s' % stock.code)
    touch4 = np.sign(stock.hour_high * 10000 / rollx(stock.hour,4) >= 10990)  
    stock.touch4 = xfollow(hour2day4(touch4),stock.transaction[VOLUME])   #第1小时涨停. 确保第二天停盘也能够使信号延递
예제 #11
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def up_in_hour2(stock,xup=200):#xup为涨停次日的开盘涨幅,万分位表示
    '''第2小时涨停,接近有利可图
        评估:总盈亏值=-172,交易次数=268 期望值=-27
                总盈亏率(1/1000)=-172,平均盈亏率(1/1000)=-1,盈利交易率(1/1000)=309
                平均持仓时间=1,持仓效率(1/1000000)=-1000
                赢利次数=83,赢利总值=6739
                亏损次数=180,亏损总值=6911
                平盘次数=5

    12.
        评估:总盈亏值=-8219,交易次数=700        期望值=-286
                总盈亏率(1/1000)=-8219,平均盈亏率(1/1000)=-12,盈利交易率(1/1000)=255
                平均持仓时间=1,持仓效率(1/1000000)=-12000
                赢利次数=179,赢利总值=13627
                亏损次数=515,亏损总值=21846
                平盘次数=6
    
    前面如果是一字涨停,则可忽略大盘
    '''
    linelog('%s:%s' % (up_in_hour2.__name__,stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]),t[VOLUME])
    #climit = xfollow(limitup2(t[HIGH],t[LOW]),t[VOLUME])   #一字板
    #yup = rollx(gand(stock.slup2,climit,bnot(stock.slup1)),1)  #昨日第二小时涨停并且收盘封住
    yup = rollx(gand(stock.slup2,climit),1)  #昨日第二小时涨停并且至收盘都没打开过,含第一小时
    #yup = rollx(climit,1)
    pre = rollx(t[CLOSE],1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)    #今日开盘大于xup
    
    tx = np.sign(t[LOW] * 10000 / pre < 10990)    #非一字涨停,追
    #tt = gand(stock.t5,stock.t4,stock.t3,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置
    tt = gand(stock.t5,stock.t4,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置

    ama = fama(t[CLOSE])
    rama = rollx(ama*1000/rollx(ama)<=1000)   #-284, p=342

    #cswing = t[CLOSE] * 1000 / pre - 1000  #涨幅
    #cup = select([cswing>0],[cswing])
    #mcup1 = ma(cup,13)
    #mcup2 = ma(cup,30)
    #sm = rollx(gand(mcup1<mcup2),1)

    
    rlimit = limitup1(t[CLOSE])
    times = msum2(rlimit,5)
    r1 = rollx(gand(times==2),1)  #第n个涨停

    #大盘因素
    #smarket = rollx(gand(stock.ref.t2,stock.ref.t1,stock.ref.t0),1)
    #smarket = gand(stock.ref.t2,stock.ref.t1,stock.ref.t0)  #使用当日的大盘情况,差别巨大
    smarket = rollx(gand(stock.ref.t2,stock.ref.t1,stock.ref.t0),1)  #使用当日的大盘情况,差别巨大

    #smart优于tt,这两类条件貌似重合,叠加无效果
    #signal = gand(yup,tup,tx,t[VOLUME]>0,smarket,tt)#,r1)   #,tt,peak)#,fmacd,xmacd)  #rama
    signal = gand(yup,tup,tx,t[VOLUME]>0,smarket,r1,rama)   #,tt,peak)#,fmacd,xmacd)  #rama


    #一字涨停,忽略大盘
    pup = rollx(t[LOW]*10000/pre >=10990,1)
    psignal =  gand(yup,tup,tx,t[VOLUME]>0,r1,rama,pup)

    signal = gor(signal,psignal)

    dsignal = decover(signal,3)
    stock.buyprice = select([dsignal>0],[t[OPEN]])
    #print signal

    return dsignal
예제 #12
0
파일: thfuncs.py 프로젝트: pophoo/foxengine
def prepare_slup4(stock):
    linelog('prepare hour:%s' % stock.code)
    slup4 = np.sign(stock.hour * 10000 / rollx(stock.hour,4) >= 10990)  
    stock.slup4 = xfollow(hour2day4(slup4),stock.transaction[VOLUME])   #第1小时涨停. 确保第二天停盘也能够使信号延递
예제 #13
0
def prepare_touch4(stock):
    linelog('prepare hour:%s' % stock.code)
    touch4 = np.sign(stock.hour_high * 10000 / rollx(stock.hour, 4) >= 10990)
    stock.touch4 = xfollow(hour2day4(touch4),
                           stock.transaction[VOLUME])  #第1小时涨停. 确保第二天停盘也能够使信号延递
예제 #14
0
def up_in_hour2(stock, xup=200):  #xup为涨停次日的开盘涨幅,万分位表示
    '''第2小时涨停,接近有利可图
        评估:总盈亏值=-172,交易次数=268 期望值=-27
                总盈亏率(1/1000)=-172,平均盈亏率(1/1000)=-1,盈利交易率(1/1000)=309
                平均持仓时间=1,持仓效率(1/1000000)=-1000
                赢利次数=83,赢利总值=6739
                亏损次数=180,亏损总值=6911
                平盘次数=5

    12.
        评估:总盈亏值=-8219,交易次数=700        期望值=-286
                总盈亏率(1/1000)=-8219,平均盈亏率(1/1000)=-12,盈利交易率(1/1000)=255
                平均持仓时间=1,持仓效率(1/1000000)=-12000
                赢利次数=179,赢利总值=13627
                亏损次数=515,亏损总值=21846
                平盘次数=6
    
    前面如果是一字涨停,则可忽略大盘
    '''
    linelog('%s:%s' % (up_in_hour2.__name__, stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]), t[VOLUME])
    #climit = xfollow(limitup2(t[HIGH],t[LOW]),t[VOLUME])   #一字板
    #yup = rollx(gand(stock.slup2,climit,bnot(stock.slup1)),1)  #昨日第二小时涨停并且收盘封住
    yup = rollx(gand(stock.slup2, climit), 1)  #昨日第二小时涨停并且至收盘都没打开过,含第一小时
    #yup = rollx(climit,1)
    pre = rollx(t[CLOSE], 1)
    tup = np.sign(t[OPEN] * 10000 / pre >= xup + 10000)  #今日开盘大于xup

    tx = np.sign(t[LOW] * 10000 / pre < 10990)  #非一字涨停,追
    #tt = gand(stock.t5,stock.t4,stock.t3,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置
    tt = gand(stock.t5, stock.t4,
              strend(ma(t[CLOSE], 250)) > 0)  #不采用跳点法,可能这是一个敏感位置

    ama = fama(t[CLOSE])
    rama = rollx(ama * 1000 / rollx(ama) <= 1000)  #-284, p=342

    #cswing = t[CLOSE] * 1000 / pre - 1000  #涨幅
    #cup = select([cswing>0],[cswing])
    #mcup1 = ma(cup,13)
    #mcup2 = ma(cup,30)
    #sm = rollx(gand(mcup1<mcup2),1)

    rlimit = limitup1(t[CLOSE])
    times = msum2(rlimit, 5)
    r1 = rollx(gand(times == 2), 1)  #第n个涨停

    #大盘因素
    #smarket = rollx(gand(stock.ref.t2,stock.ref.t1,stock.ref.t0),1)
    #smarket = gand(stock.ref.t2,stock.ref.t1,stock.ref.t0)  #使用当日的大盘情况,差别巨大
    smarket = rollx(gand(stock.ref.t2, stock.ref.t1, stock.ref.t0),
                    1)  #使用当日的大盘情况,差别巨大

    #smart优于tt,这两类条件貌似重合,叠加无效果
    #signal = gand(yup,tup,tx,t[VOLUME]>0,smarket,tt)#,r1)   #,tt,peak)#,fmacd,xmacd)  #rama
    signal = gand(yup, tup, tx, t[VOLUME] > 0, smarket, r1,
                  rama)  #,tt,peak)#,fmacd,xmacd)  #rama

    #一字涨停,忽略大盘
    pup = rollx(t[LOW] * 10000 / pre >= 10990, 1)
    psignal = gand(yup, tup, tx, t[VOLUME] > 0, r1, rama, pup)

    signal = gor(signal, psignal)

    dsignal = decover(signal, 3)
    stock.buyprice = select([dsignal > 0], [t[OPEN]])
    #print signal

    return dsignal
예제 #15
0
def prepare_slup4(stock):
    linelog('prepare hour:%s' % stock.code)
    slup4 = np.sign(stock.hour * 10000 / rollx(stock.hour, 4) >= 10990)
    stock.slup4 = xfollow(hour2day4(slup4),
                          stock.transaction[VOLUME])  #第1小时涨停. 确保第二天停盘也能够使信号延递