Exemple #1
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
Exemple #2
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
Exemple #3
0
    def check_signal1(self, name, his_data, dyn_data):
        #print "check_signal"
        sif = DataObject()
        sif.name = name
        sif.transaction = DynamicScheduler.concatenate(his_data.transaction,
                                                       dyn_data.transaction)
        ifreader.prepare_index(sif)
        #print 'prepared ok'
        tradesy = trade_functor(sif,
                                trade_strategy,
                                priority_level=trade_priority)
        xactions = iftrade.last_wactions(sif, tradesy)  #最新的在最前面
        sms_actions = []
        #if len(xactions)>2:
        #    action = xactions[0]
        #    action1 = xactions[1]
        #    action2 = xactions[2]
        #    print 'actions[0]:',action.xtype,action.date,action.time,action.price
        #    print 'actions[1]:',action1.xtype,action1.date,action1.time,action1.price
        #    print 'actions[2]:',action2.xtype,action2.date,action2.time,action2.price
        #    action.xtype = XOPEN
        cdate = sif.transaction[IDATE][-1]
        ctime = sif.transaction[ITIME][-1]
        xlog = open('d:/temp/actions.txt', 'a+')

        print >> xlog, '\n', cdate, ctime, ':'
        for xa in xactions[:10]:
            if xa.date == cdate:
                print >> xlog, '\t', xa.date, xa.time, xa.xtype
        xlog.close()
        for action in xactions:
            if action.xtype == XOPEN and (
                    action.date > dyn_data.last_checked_date or
                (action.date == dyn_data.last_checked_date
                 and action.time > dyn_data.last_checked_time)):
                action.price = action.price / 10.0
                dynamic.calc_stop(sif, action)
                #print 'to sms:', action.date,action.time,action.price
                sms_actions.append(action)
        dyn_data.last_checked_date = xactions[0].date
        dyn_data.last_checked_time = xactions[0].time
        #print 'check time:',dyn_data.last_checked_time
        return sms_actions
Exemple #4
0
    def check_signal1(self,name,his_data,dyn_data):
        #print "check_signal"
        sif = DataObject()
        sif.name = name
        sif.transaction = DynamicScheduler.concatenate(his_data.transaction,dyn_data.transaction)
        ifreader.prepare_index(sif)
        #print 'prepared ok'
        tradesy = trade_functor(sif,trade_strategy,priority_level=trade_priority)
        xactions = iftrade.last_wactions(sif,tradesy)   #最新的在最前面
        sms_actions = []
        #if len(xactions)>2:
        #    action = xactions[0]
        #    action1 = xactions[1]
        #    action2 = xactions[2]            
        #    print 'actions[0]:',action.xtype,action.date,action.time,action.price
        #    print 'actions[1]:',action1.xtype,action1.date,action1.time,action1.price
        #    print 'actions[2]:',action2.xtype,action2.date,action2.time,action2.price
        #    action.xtype = XOPEN
        cdate = sif.transaction[IDATE][-1]
        ctime = sif.transaction[ITIME][-1]
        xlog = open('d:/temp/actions.txt','a+')

        print >>xlog,'\n',cdate,ctime,':'
        for xa in xactions[:10]:
            if xa.date == cdate:
                print >> xlog,'\t',xa.date,xa.time,xa.xtype
        xlog.close()
        for action in xactions:
            if action.xtype == XOPEN and (action.date > dyn_data.last_checked_date 
                        or (action.date == dyn_data.last_checked_date and action.time > dyn_data.last_checked_time)):
                action.price = action.price / 10.0
                dynamic.calc_stop(sif,action)
                #print 'to sms:', action.date,action.time,action.price
                sms_actions.append(action)
        dyn_data.last_checked_date = xactions[0].date
        dyn_data.last_checked_time = xactions[0].time
        #print 'check time:',dyn_data.last_checked_time
        return sms_actions