Пример #1
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
Пример #2
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
Пример #3
0
def heff(stock):
    ''' 效果不平衡
        0501-0909
        评估:总盈亏值=35014,交易次数=178        期望值=2684
                总盈亏率(1/1000)=35014,平均盈亏率(1/1000)=196,盈利交易率(1/1000)=612
                平均持仓时间=32,持仓效率(1/1000000)=6125
                赢利次数=109,赢利总值=40100
                亏损次数=69,亏损总值=5086
                平盘次数=0
        0711-0909
        评估:总盈亏值=17918,交易次数=63 期望值=4437
                总盈亏率(1/1000)=17918,平均盈亏率(1/1000)=284,盈利交易率(1/1000)=809
                平均持仓时间=43,持仓效率(1/1000000)=6604
                赢利次数=51,赢利总值=18686
                亏损次数=12,亏损总值=768
                平盘次数=0

    '''
    linelog(stock.code)
    t = stock.transaction
    ef = efficient_rate(stock.hour)
    zx = cached_zeros(len(stock.hour))
    efz = hour2day(gand(cross(zx, ef) > 0, strend(ef) > 0))
    vma = ma(t[VOLUME], 30)
    svma = ma(t[VOLUME], 3)
    vfilter = gand(svma < vma * 3 / 4, t[VOLUME] < vma)
    cf = (t[OPEN] - t[LOW] + t[HIGH] - t[CLOSE]) * 1000 / (t[HIGH] - t[LOW]
                                                           )  #向下的动力
    mcf = ma(cf, 7)

    refn = gand(stock.ref.ma0 < stock.ref.ma1, stock.ref.ma1 < stock.ref.ma2,
                bnot(stock.ref.t0), bnot(stock.ref.t1), bnot(stock.ref.t2))
    sup = gand(stock.ma0 > stock.ma1, stock.ma1 > stock.ma2, stock.t1,
               stock.t2)

    s1 = gand(efz, bor(bnot(refn), sup))
    s2 = sfollow(efz, bnot(refn), 10)
    ss = bor(s1, s2)
    s = stock
    magic = gand(s.g20 >= s.g60, s.g60 >= s.g120, s.g120 >= s.g250,
                 s.g5 > s.g20, s.g20 <= 8000)
    xatr = stock.atr * BASE / t[CLOSE]

    #signal = gand(ss,stock.above,stock.t5,stock.t4,magic,vfilter,mcf<1000)
    signal = gand(ss, stock.above, stock.t5, stock.t4, magic, vfilter,
                  mcf < 1000, xatr > 40, stock.ma1 > stock.ma3,
                  stock.diff < stock.dea)
    return signal
Пример #4
0
 def trade_maker(self,
                 tmaker,
                 dates,
                 stock,
                 sbuy,
                 ssell,
                 begin=0):  #kwargs目的是吸收无用参数,便于cruiser
     ''' trade_strategy是对sbuy和ssell进行预处理,如买卖都是次日交易则为B1S1 
     '''
     t = stock.transaction
     #logger.debug('%s old ssell:%s' % (stock.code,ssell.tolist()))
     #for t,sb,ss in zip(dates,sbuy,ssell):print t,sb,ss
     sbuy, ssell = self.trade_strategy(t, sbuy, ssell)
     sbuy = band(sbuy,
                 bnot(sresume(stock.transaction[VOLUME], 10,
                              covered=3)))  #对停牌10日以上的的股票,消除其紧随3天的sbuy信号
     #logger.debug(u'sbuy,after strategy:%s',sbuy.tolist())
     #logger.debug(u'ssell,after strategy:%s',ssell.tolist())
     ssignal = self.trade_signal_maker(sbuy, ssell)
     #print stock.code,ssignal
     #logger.debug('%s signals:%s' % (stock.code,ssignal.tolist()))
     #logger.debug('%s seller:%s' % (stock.code,ssell.tolist()))
     #for t,sb,ss,ssig in zip(dates,sbuy,ssell,ssignal):print t,sb,ss,ssig
     return tmaker(stock,
                   ssignal,
                   dates,
                   self.buy_pricer(stock),
                   self.sell_pricer(stock),
                   begin=begin)
Пример #5
0
def fup60b(stock):
    '''
        60分钟从负数上来的有失败上叉先导的第一次成功上叉
    '''
    t = stock.transaction
    linelog('%s:%s' % (fup60.__name__,stock.code))

    hzero =  cached_zeros(len(stock.hour))
    
    pdiff,pdea = cmacd(stock.hour)
    
    cross0 = cross(hzero,pdiff)

    udcross = cross(pdea,pdiff)

    #失败上叉:最近5个周期内被下叉信号抵消,或者最近5个周期内出现第二个上叉信号(导致msum仍然>0)
    fcross = gand(udcross>0,gor(rollx(msum(udcross,5),-5)==0,rollx(msum(udcross>0,5),-5)>1))

    ucross = gand(udcross>0,pdiff>0,bnot(fcross))

    xsum1 = rsum(ucross,cross0)  #此时,第一个cross>0和第二个之间的位置被填满1
    xsum = rsum(xsum1,cross0)   #此时,只有第一个发生位为1

    signal = gand(equals(xsum,1),pdiff>0)

    return hour2day(signal)
Пример #6
0
def fup60b(stock):
    '''
        60分钟从负数上来的有失败上叉先导的第一次成功上叉
    '''
    t = stock.transaction
    linelog('%s:%s' % (fup60.__name__, stock.code))

    hzero = cached_zeros(len(stock.hour))

    pdiff, pdea = cmacd(stock.hour)

    cross0 = cross(hzero, pdiff)

    udcross = cross(pdea, pdiff)

    #失败上叉:最近5个周期内被下叉信号抵消,或者最近5个周期内出现第二个上叉信号(导致msum仍然>0)
    fcross = gand(
        udcross > 0,
        gor(
            rollx(msum(udcross, 5), -5) == 0,
            rollx(msum(udcross > 0, 5), -5) > 1))

    ucross = gand(udcross > 0, pdiff > 0, bnot(fcross))

    xsum1 = rsum(ucross, cross0)  #此时,第一个cross>0和第二个之间的位置被填满1
    xsum = rsum(xsum1, cross0)  #此时,只有第一个发生位为1

    signal = gand(equals(xsum, 1), pdiff > 0)

    return hour2day(signal)
Пример #7
0
def hmxru(stock):
    ''' 成交量分配后的macd,采用supdown
        vfilter = svma < vma * 2/3    
        评估:总盈亏值=4813,交易次数=14  期望值=5444
                总盈亏率(1/1000)=4813,平均盈亏率(1/1000)=343,盈利交易率(1/1000)=928
                平均持仓时间=50,持仓效率(1/1000000)=6860
                赢利次数=13,赢利总值=4876
                亏损次数=1,亏损总值=63
                平盘次数=0
        vfilter = gand(svma<vma*2/3,t[VOLUME]<=vma*2/3)
        评估:总盈亏值=3810,交易次数=8   期望值=1000
                总盈亏率(1/1000)=3810,平均盈亏率(1/1000)=476,盈利交易率(1/1000)=1000
                平均持仓时间=65,持仓效率(1/1000000)=7323
                赢利次数=8,赢利总值=3810
                亏损次数=0,亏损总值=0
                平盘次数=0

    '''
    t = stock.transaction
    mxc = stock.xru
    vma = ma(t[VOLUME],30)
    svma = ma(t[VOLUME],3)
    vfilter = gand(svma<vma*2/3,t[VOLUME]<=vma*2/3)
    #vfilter = gand(svma<vma*2/3)
    xatr = stock.atr * BASE / t[CLOSE]     
    ma0 = ma(t[CLOSE],3)
    ndown = bnot(gand(t[CLOSE]<ma0,ma0<stock.ma1,stock.ma1<stock.ma2))
    s = stock
    sv = greater(msum(t[VOLUME] > 0,120),100)   #确保新股上市前100天无信号    
    signal = gand(mxc,stock.above,vfilter,strend(stock.ma4)>0,stock.t5,xatr>=60,stock.magic,stock.ma1<stock.ma2,stock.ma1>stock.ma3,ndown)


    linelog(stock.code)
    return signal
Пример #8
0
def tsvama2sbv(stock,fast,slow,follow=7):
    ''' svama慢线下叉快线,follow日后再上叉回来
        添加vfilter
    '''
    t = stock.transaction
    svap,v2i = stock.svap_ma_67_2

    ma_svapfast = ma(svap,fast)
    ma_svapslow = ma(svap,slow)
    trend_ma_svapfast = strend(ma_svapfast)
    trend_ma_svapslow = strend(ma_svapslow)

    cross_down = band(cross(ma_svapslow,ma_svapfast)<0,trend_ma_svapfast<0)    
    cross_up = band(cross(ma_svapslow,ma_svapfast)>0,trend_ma_svapfast>0)        
    
    sdown = transform(cross_down,v2i,len(t[VOLUME]))
    sup = transform(cross_up,v2i,len(t[VOLUME]))    
    
    sync_down_up = sfollow(sdown,sup,follow)
    
    linelog('%s:%s' % (tsvama2sbv.__name__,stock.code))

    vma_s = ma(t[VOLUME],13)
    vma_l = ma(t[VOLUME],30)

    vfilter = vma_s < vma_l

    ss = gand(bnot(sfollow(sync_down_up,stock.hup,10)),sfollow(sync_down_up,stock.hup,20))
    return gand(ss,stock.above,stock.t5,stock.magic,vfilter)
Пример #9
0
def heff(stock):
    ''' 效果不平衡
        0501-0909
        评估:总盈亏值=35014,交易次数=178        期望值=2684
                总盈亏率(1/1000)=35014,平均盈亏率(1/1000)=196,盈利交易率(1/1000)=612
                平均持仓时间=32,持仓效率(1/1000000)=6125
                赢利次数=109,赢利总值=40100
                亏损次数=69,亏损总值=5086
                平盘次数=0
        0711-0909
        评估:总盈亏值=17918,交易次数=63 期望值=4437
                总盈亏率(1/1000)=17918,平均盈亏率(1/1000)=284,盈利交易率(1/1000)=809
                平均持仓时间=43,持仓效率(1/1000000)=6604
                赢利次数=51,赢利总值=18686
                亏损次数=12,亏损总值=768
                平盘次数=0

    '''
    linelog(stock.code)
    t = stock.transaction    
    ef = efficient_rate(stock.hour)
    zx = cached_zeros(len(stock.hour))
    efz = hour2day(gand(cross(zx,ef)>0,strend(ef)>0))
    vma = ma(t[VOLUME],30)
    svma = ma(t[VOLUME],3)
    vfilter = gand(svma<vma*3/4,t[VOLUME]<vma)
    cf = (t[OPEN]-t[LOW] + t[HIGH]-t[CLOSE])*1000 / (t[HIGH]-t[LOW])   #向下的动力  
    mcf = ma(cf,7) 

    refn = gand(stock.ref.ma0<stock.ref.ma1,stock.ref.ma1<stock.ref.ma2,bnot(stock.ref.t0),bnot(stock.ref.t1),bnot(stock.ref.t2))
    sup = gand(stock.ma0>stock.ma1,stock.ma1>stock.ma2,stock.t1,stock.t2)

    s1 = gand(efz,bor(bnot(refn),sup))
    s2 = sfollow(efz,bnot(refn),10)
    ss = bor(s1,s2)
    s = stock
    magic = gand(s.g20 >= s.g60,s.g60 >= s.g120,s.g120 >= s.g250,s.g5>s.g20,s.g20<=8000)
    xatr = stock.atr * BASE / t[CLOSE]     

    #signal = gand(ss,stock.above,stock.t5,stock.t4,magic,vfilter,mcf<1000)
    signal = gand(ss,stock.above,stock.t5,stock.t4,magic,vfilter,mcf<1000,xatr>40,stock.ma1>stock.ma3,stock.diff<stock.dea)
    return signal
Пример #10
0
 def trade_maker(self,tmaker,dates,stock,sbuy,ssell,begin=0):  #kwargs目的是吸收无用参数,便于cruiser
     ''' trade_strategy是对sbuy和ssell进行预处理,如买卖都是次日交易则为B1S1 
     '''
     t = stock.transaction
     #logger.debug('%s old ssell:%s' % (stock.code,ssell.tolist()))
     #for t,sb,ss in zip(dates,sbuy,ssell):print t,sb,ss
     sbuy,ssell = self.trade_strategy(t,sbuy,ssell)
     sbuy = band(sbuy,bnot(sresume(stock.transaction[VOLUME],10,covered=3))) #对停牌10日以上的的股票,消除其紧随3天的sbuy信号
     #logger.debug(u'sbuy,after strategy:%s',sbuy.tolist())
     #logger.debug(u'ssell,after strategy:%s',ssell.tolist())
     ssignal = self.trade_signal_maker(sbuy,ssell)
     #print stock.code,ssignal
     #logger.debug('%s signals:%s' % (stock.code,ssignal.tolist()))
     #logger.debug('%s seller:%s' % (stock.code,ssell.tolist()))
     #for t,sb,ss,ssig in zip(dates,sbuy,ssell,ssignal):print t,sb,ss,ssig
     return tmaker(stock,ssignal,dates,self.buy_pricer(stock),self.sell_pricer(stock),begin=begin)
Пример #11
0
def up_in_hour4(stock,xup=200):#xup为涨停次日的开盘涨幅,万分位表示
    '''第4小时涨停'''
    linelog('%s:%s' % (up_in_hour4.__name__,stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]),t[VOLUME])
    y123 = gor(stock.slup1,stock.slup2,stock.slup3)
    yup = rollx(gand(stock.slup4,climit,bnot(y123)),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
Пример #12
0
def up_in_hour4(stock, xup=200):  #xup为涨停次日的开盘涨幅,万分位表示
    '''第4小时涨停'''
    linelog('%s:%s' % (up_in_hour4.__name__, stock.code))
    t = stock.transaction
    climit = xfollow(limitup1(t[CLOSE]), t[VOLUME])
    y123 = gor(stock.slup1, stock.slup2, stock.slup3)
    yup = rollx(gand(stock.slup4, climit, bnot(y123)), 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
Пример #13
0
def attack2b(stock):  #
    ''' 盘中第二小时追跳高不变者
        使用fseller(信号次日卖出)
        bo_pricer = (lambda s : s.buyprice,lambda s : s.transaction[OPEN])
        myMediator=nmediator_factory(trade_strategy=B0S1,pricer = bo_pricer)    
        使用fseller_t(信号当日卖出)
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    
        使用follow_seller(信号当日卖出)
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    

    '''
    linelog('%s:%s' % (attack2.__name__, stock.code))
    t = stock.transaction

    #第一个涨停 #确保没有稍长的下影线

    cup = gand(stock.up1,
               bnot(gand(stock.stoped2, stock.stoped3, stock.stoped4)))

    #三线理顺
    #tt = rollx(gand(stock.t4,stock.t5),1)
    fm = rollx(gand(stock.diff < stock.dea))

    g = rollx(gand(stock.g20 > stock.g60, stock.g60 > stock.g120))

    tref = rollx(gand(stock.ref.t3))

    signal = gand(cup, t[VOLUME] > 0, stock.ref.up1, tref,
                  strend(stock.ref.diff) > 0, fm,
                  g)  #smarket)#,rama) #,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
Пример #14
0
def fupf(stock):
    '''
        本次上叉比上次上叉的位置高,同时价格也高
    '''

    t = stock.transaction
    linelog('%s:%s' % (fupf.__name__,stock.code))

    pdiff,pdea = cmacd(stock.hour)

    upcross2 = gand(cross(pdea,pdiff)>0,strend(pdiff)>0)

    dsub = rsub(pdea,upcross2)
    #csub = rsub(stock.hour,upcross2)
    #ssub = rsub(rollx(strend(pdea)),upcross2)   #上叉前一天的strend(pdea)

    vz = tmax(np.abs(pdiff),60) / 5 #pdiff不能超过0线太高

    hsignal = gand(dsub>0,pdiff<vz)


    xatr = stock.atr * BASE / t[CLOSE]
    mxatr = ma(xatr,13)
    xr = gand(xatr<50,xatr<mxatr)#,strend(xatr-mxatr)<0)

    nd = bnot(gand(stock.ma1<stock.ma2,stock.ma2<stock.ma3))

    rt = gand(stock.ref.t3)

    vma_s = ma(t[VOLUME],13)
    vma_l = ma(t[VOLUME],30)

    vfilter = vma_s < vma_l * 3/4

    gr = gand(stock.g20<3000,stock.g20>stock.g60,stock.g60>stock.g120)

    signal = gand(hour2day(hsignal),strend(stock.diff)>0,xr,rt,nd,vfilter,gr)

    return signal
Пример #15
0
def fupf(stock):
    '''
        本次上叉比上次上叉的位置高,同时价格也高
    '''

    t = stock.transaction
    linelog('%s:%s' % (fupf.__name__, stock.code))

    pdiff, pdea = cmacd(stock.hour)

    upcross2 = gand(cross(pdea, pdiff) > 0, strend(pdiff) > 0)

    dsub = rsub(pdea, upcross2)
    #csub = rsub(stock.hour,upcross2)
    #ssub = rsub(rollx(strend(pdea)),upcross2)   #上叉前一天的strend(pdea)

    vz = tmax(np.abs(pdiff), 60) / 5  #pdiff不能超过0线太高

    hsignal = gand(dsub > 0, pdiff < vz)

    xatr = stock.atr * BASE / t[CLOSE]
    mxatr = ma(xatr, 13)
    xr = gand(xatr < 50, xatr < mxatr)  #,strend(xatr-mxatr)<0)

    nd = bnot(gand(stock.ma1 < stock.ma2, stock.ma2 < stock.ma3))

    rt = gand(stock.ref.t3)

    vma_s = ma(t[VOLUME], 13)
    vma_l = ma(t[VOLUME], 30)

    vfilter = vma_s < vma_l * 3 / 4

    gr = gand(stock.g20 < 3000, stock.g20 > stock.g60, stock.g60 > stock.g120)

    signal = gand(hour2day(hsignal),
                  strend(stock.diff) > 0, xr, rt, nd, vfilter, gr)

    return signal
Пример #16
0
def attack2b(stock):#
    ''' 盘中第二小时追跳高不变者
        使用fseller(信号次日卖出)
        bo_pricer = (lambda s : s.buyprice,lambda s : s.transaction[OPEN])
        myMediator=nmediator_factory(trade_strategy=B0S1,pricer = bo_pricer)    
        使用fseller_t(信号当日卖出)
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    
        使用follow_seller(信号当日卖出)
        my_pricer = (lambda s : s.buyprice,lambda s : s.sellprice)
        myMediator=nmediator_factory(trade_strategy=B0S0_N,pricer = my_pricer)    

    '''
    linelog('%s:%s' % (attack2.__name__,stock.code))
    t = stock.transaction
    
    #第一个涨停 #确保没有稍长的下影线

    cup = gand(stock.up1,bnot(gand(stock.stoped2,stock.stoped3,stock.stoped4)))


    #三线理顺
    #tt = rollx(gand(stock.t4,stock.t5),1)
    fm = rollx(gand(stock.diff < stock.dea))

    g = rollx(gand(stock.g20>stock.g60,stock.g60>stock.g120))

    tref = rollx(gand(stock.ref.t3))

    signal = gand(cup,t[VOLUME]>0,stock.ref.up1,tref,strend(stock.ref.diff)>0,fm,g)#smarket)#,rama) #,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
Пример #17
0
def follow_up2(stock):
    '''第n小时涨停,且涨停板在后两个小时打开过
       第1/2/3小时涨停,后面打开过
       第二小时最好,但仍然只有1/3的概率
        1
        评估:总盈亏值=-5945,交易次数=370        期望值=-396
                总盈亏率(1/1000)=-5945,平均盈亏率(1/1000)=-17,盈利交易率(1/1000)=283
                平均持仓时间=1,持仓效率(1/1000000)=-17000
                赢利次数=105,赢利总值=5427
                亏损次数=262,亏损总值=11372
                平盘次数=3

        2
        评估:总盈亏值=-1925,交易次数=278        期望值=-185
                总盈亏率(1/1000)=-1925,平均盈亏率(1/1000)=-7,盈利交易率(1/1000)=345
                平均持仓时间=1,持仓效率(1/1000000)=-7000
                赢利次数=96,赢利总值=5064
                亏损次数=180,亏损总值=6989
                平盘次数=2

        3
        评估:总盈亏值=-4560,交易次数=413        期望值=-325
                总盈亏率(1/1000)=-4560,平均盈亏率(1/1000)=-12,盈利交易率(1/1000)=288
                平均持仓时间=1,持仓效率(1/1000000)=-12000
                赢利次数=119,赢利总值=6388
                亏损次数=294,亏损总值=10948
                平盘次数=0
       
    '''
    linelog('%s:%s' % (follow_up2.__name__, stock.code))
    t = stock.transaction
    #yup = gand(stock.slup2,bnot(stock.slup1),bnot(gand(stock.stoped3,stock.stoped4)))  #开盘第二小时涨停,并且在第三四小时打开过
    #yup = gand(stock.slup1,bnot(gand(stock.stoped2,stock.stoped3,stock.stoped4)))  #开盘第1小时涨停,并且在第2三四小时打开过
    #yup = gand(stock.slup3,bnot(gor(stock.slup1,stock.slup2)),bnot(stock.stoped4))  #第3小时涨停,并且在第四小时打开过

    #开盘涨停
    oup = t[OPEN] * 10000 / rollx(t[CLOSE], 1) >= 10990
    cup = t[CLOSE] * 10000 / rollx(t[CLOSE], 1) >= 10990
    hup = t[HIGH] * 10000 / rollx(t[CLOSE], 1) >= 10990
    lup = t[LOW] * 10000 / rollx(t[CLOSE], 1) >= 10990
    yup = gand(bnot(oup), cup)

    #无法判断第四小时涨停的个股涨停后是否打开过
    tt = gand(stock.t5, stock.t4,
              strend(ma(t[CLOSE], 250)) > 0)  #不采用跳点法,可能这是一个敏感位置

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

    ama = fama(stock.ref.transaction[CLOSE])
    #rama = stock.ref.transaction[CLOSE]*1000/rollx(ama)>=1000   #-284, p=342

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

    signal = gand(yup, t[VOLUME] > 0, smarket,
                  rollx(cs))  #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal, 3)

    stock.buyprice = select([dsignal > 0], [t[HIGH]])  #涨停价

    #print signal

    return dsignal
Пример #18
0
def follow_up2(stock):
    '''第n小时涨停,且涨停板在后两个小时打开过
       第1/2/3小时涨停,后面打开过
       第二小时最好,但仍然只有1/3的概率
        1
        评估:总盈亏值=-5945,交易次数=370        期望值=-396
                总盈亏率(1/1000)=-5945,平均盈亏率(1/1000)=-17,盈利交易率(1/1000)=283
                平均持仓时间=1,持仓效率(1/1000000)=-17000
                赢利次数=105,赢利总值=5427
                亏损次数=262,亏损总值=11372
                平盘次数=3

        2
        评估:总盈亏值=-1925,交易次数=278        期望值=-185
                总盈亏率(1/1000)=-1925,平均盈亏率(1/1000)=-7,盈利交易率(1/1000)=345
                平均持仓时间=1,持仓效率(1/1000000)=-7000
                赢利次数=96,赢利总值=5064
                亏损次数=180,亏损总值=6989
                平盘次数=2

        3
        评估:总盈亏值=-4560,交易次数=413        期望值=-325
                总盈亏率(1/1000)=-4560,平均盈亏率(1/1000)=-12,盈利交易率(1/1000)=288
                平均持仓时间=1,持仓效率(1/1000000)=-12000
                赢利次数=119,赢利总值=6388
                亏损次数=294,亏损总值=10948
                平盘次数=0
       
    '''
    linelog('%s:%s' % (follow_up2.__name__,stock.code))
    t = stock.transaction
    #yup = gand(stock.slup2,bnot(stock.slup1),bnot(gand(stock.stoped3,stock.stoped4)))  #开盘第二小时涨停,并且在第三四小时打开过
    #yup = gand(stock.slup1,bnot(gand(stock.stoped2,stock.stoped3,stock.stoped4)))  #开盘第1小时涨停,并且在第2三四小时打开过
    #yup = gand(stock.slup3,bnot(gor(stock.slup1,stock.slup2)),bnot(stock.stoped4))  #第3小时涨停,并且在第四小时打开过
    
    #开盘涨停
    oup = t[OPEN]*10000 / rollx(t[CLOSE],1) >= 10990
    cup = t[CLOSE]*10000 / rollx(t[CLOSE],1) >= 10990
    hup = t[HIGH]*10000 / rollx(t[CLOSE],1) >= 10990
    lup = t[LOW]*10000 / rollx(t[CLOSE],1) >= 10990
    yup = gand(bnot(oup),cup)


    #无法判断第四小时涨停的个股涨停后是否打开过
    tt = gand(stock.t5,stock.t4,strend(ma(t[CLOSE],250))>0)    #不采用跳点法,可能这是一个敏感位置

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

    ama = fama(stock.ref.transaction[CLOSE])
    #rama = stock.ref.transaction[CLOSE]*1000/rollx(ama)>=1000   #-284, p=342

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

    signal = gand(yup,t[VOLUME]>0,smarket,rollx(cs))   #,tt,peak)#,fmacd,xmacd)  #rama

    dsignal = decover(signal,3)

    stock.buyprice = select([dsignal>0],[t[HIGH]])     #涨停价
    
    #print signal

    return dsignal