Пример #1
0
    def inform(self, name, sms_actions, sms_begin):
        ''' 屏蔽掉20分钟内连续的同类算法信号, 但不屏蔽最后一个
            返回发送的条数
        '''
        if len(sms_actions) == 0:
            return 0
        mq = sms_actions[::-1]  #变回顺序
        #print sms_actions[0].date,sms_actions[0].time,sms_actions[0].price,sms_actions[-1].date,sms_actions[-1].time,sms_actions[-1].price
        successed = 0
        mnum = 0
        #msged = False
        for action in mq:
            atime = cal.timegm(
                (action.date / 10000, (action.date % 10000) / 100,
                 action.date % 100, action.time / 100, action.time % 100, 0, 0,
                 0, 0))  #转化为纪元后秒数
            #print '\ntest:',action.fname,self.pre_fname,atime,self.pre_time
            if action.fname == self.pre_fname and atime - self.pre_time <= 1200:  #1800秒,20分钟
                print u'\n忽略20分钟之内的同类信号 : %s:%s' % (action.fname, action.time)
                #win32api.MessageBox(0,u'请注意眼睛休息',u'提示',0x00001000L)
                continue
            self.pre_fname = action.fname
            self.pre_time = atime

            direction = u'买入' if action.position == LONG else u'卖出'
            #trend = u'顺势' if action.functor.strategy in (XFOLLOW,XBREAK,XORB) else u'逆势'
            trend = u'顺势' if action.xfollow > 0 else u'逆势' if action.xfollow < 0 else u'不明'
            trend = u'%s:%s' % (trend, iftrade.fpriority(action.functor))
            #msg = u'%s|%s:%s%s开仓%s,算法:%s,优先级:%s,止损:%s,条件单:%s' % (name,action.date,action.time,direction,action.price,action.fname,action.functor.priority,action.stop,action.mstop)
            #msg = u'%s|%s%s开仓%s,算法:%s,优先级:%s,止损:%s,条件单:%s,%s' % (name,action.time,direction,action.price,action.fname,action.functor.priority,action.stop,action.mstop,trend)
            msg = u'%s|%s:%s%s开仓%s,平仓%s:%s,条件单:%s%s,%s' % (
                name, action.date % 10000, action.time, direction,
                action.price, action.close, action.stop, action.condition,
                action.mstop, trend)
            if action.time < sms_begin:
                print u'\n忽略%s之前的信号:%s,%s,%s' % (sms_begin, action.time, msg,
                                                 action.fname)
                #print action.time,sms_begin,type(action.time),int(action.time)>int(sms_begin)
                continue
            print '---------------------------------------------------------------------------'
            print action.fname, msg
            #if not msged :
            #    win32api.MessageBox(0,u'请注意眼睛休息',u'提示',0x00001000L)
            #    msged = True
            successed += DynamicScheduler.send_sms1(msg, action.fname)
            #successed += DynamicScheduler.sms_stub(msg,action.fname)
            mnum += 1
            #break  #测试短信用
        print u'\n计划发送 %s 条,成功发送 %s 条' % (mnum, successed)
        if mnum > 0:
            pass
            win32api.MessageBox(0, u'请注意眼睛休息', u'提示', 0x00001000L)
        return successed
Пример #2
0
 def inform(self,name,sms_actions,sms_begin):
     ''' 屏蔽掉20分钟内连续的同类算法信号, 但不屏蔽最后一个
         返回发送的条数
     '''
     if len(sms_actions) == 0:
         return 0
     mq = sms_actions[::-1]  #变回顺序
     #print sms_actions[0].date,sms_actions[0].time,sms_actions[0].price,sms_actions[-1].date,sms_actions[-1].time,sms_actions[-1].price
     successed = 0
     mnum = 0
     #msged = False
     for action in mq:
         atime = cal.timegm((action.date/10000,(action.date%10000)/100,action.date%100
             ,action.time/100,action.time%100,0,0,0,0))  #转化为纪元后秒数
         #print '\ntest:',action.fname,self.pre_fname,atime,self.pre_time
         if action.fname == self.pre_fname and atime - self.pre_time <= 1200:   #1800秒,20分钟
             print u'\n忽略20分钟之内的同类信号 : %s:%s' % (action.fname,action.time)
             #win32api.MessageBox(0,u'请注意眼睛休息',u'提示',0x00001000L)
             continue
         self.pre_fname = action.fname
         self.pre_time = atime
         
         direction = u'买入' if action.position == LONG else u'卖出'
         #trend = u'顺势' if action.functor.strategy in (XFOLLOW,XBREAK,XORB) else u'逆势'
         trend = u'顺势' if action.xfollow>0 else u'逆势' if action.xfollow < 0 else u'不明'
         trend = u'%s:%s' % (trend,iftrade.fpriority(action.functor))
         #msg = u'%s|%s:%s%s开仓%s,算法:%s,优先级:%s,止损:%s,条件单:%s' % (name,action.date,action.time,direction,action.price,action.fname,action.functor.priority,action.stop,action.mstop)
         #msg = u'%s|%s%s开仓%s,算法:%s,优先级:%s,止损:%s,条件单:%s,%s' % (name,action.time,direction,action.price,action.fname,action.functor.priority,action.stop,action.mstop,trend)
         msg = u'%s|%s:%s%s开仓%s,平仓%s:%s,条件单:%s%s,%s' % (name,action.date%10000,action.time,direction,action.price,action.close,action.stop,action.condition,action.mstop,trend) 
         if action.time < sms_begin:
             print u'\n忽略%s之前的信号:%s,%s,%s' % (sms_begin,action.time,msg,action.fname)
             #print action.time,sms_begin,type(action.time),int(action.time)>int(sms_begin)
             continue
         print '---------------------------------------------------------------------------'
         print action.fname,msg
         #if not msged :
         #    win32api.MessageBox(0,u'请注意眼睛休息',u'提示',0x00001000L)
         #    msged = True
         successed += DynamicScheduler.send_sms1(msg,action.fname)
         #successed += DynamicScheduler.sms_stub(msg,action.fname)
         mnum += 1
         #break  #测试短信用
     print u'\n计划发送 %s 条,成功发送 %s 条' % (mnum,successed)
     if mnum>0:
         pass
         win32api.MessageBox(0,u'请注意眼睛休息',u'提示',0x00001000L)
     return successed
Пример #3
0
def whget(strategy,functor,priority=2500):
    fname,sif = fetch_cur()
    print 'last updated--%s:%s' % (sif.transaction[IDATE][-1],sif.transaction[ITIME][-1])
    tradesy =  functor(sif,strategy,priority_level=priority)    #xfollow作为平仓信号,且去掉了背离平仓的信号
    #print tradesy
    xactions = iftrade.last_wactions(sif,tradesy)
    for action in xactions:
        action.price = action.price / 10.0
        action.priority = iftrade.fpriority(action.functor)
        action.state = sif.xstate[action.index-1]   #信号当时状态
        if action.xtype == XOPEN:
            calc_stop(sif,action)
            #action.sfollow = u'顺势' if action.xfollow else u'逆势'
            action.sfollow = u'顺势' if action.xfollow>0 else u'逆势' if action.xfollow < 0 else u'不明'
        else:
            action.sfollow = u''
    return fname,sif,xactions
Пример #4
0
def whget(strategy, functor, priority=2500):
    fname, sif = fetch_cur()
    print 'last updated--%s:%s' % (sif.transaction[IDATE][-1],
                                   sif.transaction[ITIME][-1])
    tradesy = functor(sif, strategy,
                      priority_level=priority)  #xfollow作为平仓信号,且去掉了背离平仓的信号
    #print tradesy
    xactions = iftrade.last_wactions(sif, tradesy)
    for action in xactions:
        action.price = action.price / 10.0
        action.priority = iftrade.fpriority(action.functor)
        action.state = sif.xstate[action.index - 1]  #信号当时状态
        if action.xtype == XOPEN:
            calc_stop(sif, action)
            #action.sfollow = u'顺势' if action.xfollow else u'逆势'
            action.sfollow = u'顺势' if action.xfollow > 0 else u'逆势' if action.xfollow < 0 else u'不明'
        else:
            action.sfollow = u''
    return fname, sif, xactions