示例#1
0
def loop_one_prepare():
    barlist = ['1min', '3mins', '15mins', '1hour', '1day']
    ## pre prepare ES for compares
    startmode = 'initialize'
    TicksUtile.prepare_tickfilesto5secBars(
        today, 'ES',
        startmode)  ## merge the 5secddload with 5sec recents > 5sec boths
    for dur in barlist:
        durinseconds = secdict[dur]
        basisdur = '5secs'
        basisfile = DataDown + today + '.' + 'ES' + '.' + basisdur + '.both.csv'
        TicksUtile.assemble_dur_bars(today, 'ES', dur, startmode, basisfile)
############## end ES prepare
    for sym in symbol_list:
        startmode = 'initialize'
        TicksUtile.prepare_tickfilesto5secBars(
            today, sym,
            startmode)  ## merge the 5secddload with 5sec recents > 5sec boths
        for dur in barlist:
            ##                print dur, sym
            durinseconds = secdict[dur]
            basisdur = '5secs'
            basisfile = DataDown + today + '.' + sym + '.' + basisdur + '.both.csv'
            TicksUtile.assemble_dur_bars(today, sym, dur, startmode, basisfile)
            ##                indlist = ['StochK','Stoch_CROSS','StochD','pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower',\
            ##                           'kmid','ema','mcross', 'mcd','diffESTXvES','RSI']
            indlist = [
                'mcross', 'mcd', 'RSI', 'StochK', 'Stoch_CROSS', 'StochD',
                'kupper', 'klower', 'kmid', 'diffvES'
            ]
            rpInd.create_states_files(sym, dur.replace(' ', ''), today,
                                      threshold, indlist)
示例#2
0
def create_weeklies():
    sym = 'SPX'
    basisdur = '1day'
    TicksUtile.assemble_dur_bars(date,sym,'1day','initialize','5secs')
    TicksUtile.assemble_bars_1min_basis(date,sym,'1Week','bartobar',basisdur)
    indlist = ['mcross','pivot','R','R2','S','S2']
    threshold = 0.0
    rpInd.create_states_files(sym,'1Week',date,threshold,indlist)
    rpInd.create_states_files(sym,'1day',date,threshold,indlist)
def make_states(smode,date,symbollist):
    threshold = 0.0
    if smode == 'fullist':
        indlist = fullindlist
    else:
        indlist = partindlist
    barlist = barlistRecent78
    for sym in symbollist:
        for dur in barlist :
            rpInd.create_states_files(sym,dur,date,threshold,indlist)
示例#4
0
def make_states(smode, date, symbollist):
    threshold = 0.0
    if smode == 'fullist':
        indlist = fullindlist
    else:
        indlist = partindlist
    barlist = barlistRecent78
    for sym in symbollist:
        for dur in barlist:
            rpInd.create_states_files(sym, dur, date, threshold, indlist)
def make_states(smode,date,symbollist):
    threshold = 0.0
    if smode == 'fullist':
        indlist = ['pivot', 'ATR','R', 'S', 'S2', 'R2','kupper', 'klower','kmid','ema','diffvES','RSI','StochK','Stoch_CROSS','StochD']
    else:
        indlist = ['mcross','mcd','kupper','StochK','Stoch_CROSS','StochD','RSI']
    barlist = ['1min', '3mins', '5mins', '15mins']##,'78mins']

    for sym in symbollist:
        for dur in barlist :
            rpInd.create_states_files(sym,dur,date,threshold,indlist)
示例#6
0
def snapshot_sym(sym, today, durslist):
    ##    print 'got her'
    text = []
    barlist = ['1min', '3mins', '5mins', '15mins', '1hour']
    basisfile = DataDown + today + '.' + sym + '.' + '5secs' + '.both.csv'
    TicksUtile.assemble_dur_bars(today, sym, '1hour', 'initial', basisfile)
    posstate = rpInd.ShowRecentPositionState(sym)
    text.append(posstate + sym)
    threshold = 0.0
    indlist = ['mcross', 'kupper']
    ##    print posstate,sym,'recentstate age val | lastcrosstime| name USING THRESH ', threshold
    textline = 'recentstate age val name USING THRESH ' + str(threshold)
    text.append(textline)
    for dur in barlist:
        ##        print dur
        threshold = 0.0
        if dur == '1min':
            threshold = 0.1
##        print sym,dur
##        make_dur_state(sym,dur,threshold,indlist)
        basisdur = '5secs'
        startmode = 'initialize'
        basisfile = DataDown + today + '.' + sym + '.' + basisdur + '.both.csv'
        TicksUtile.assemble_dur_bars(today, sym, dur, startmode, basisfile)
        ### this relys on the sig creator to assemble each time
        rpInd.create_states_files(sym, dur, today, threshold, indlist)
        indlist = ['mcross']
        for ind in indlist:
            mode = 'noboost'
            state = rpInd.ShowRecentState(sym, dur, ind, mode)
            stateAge = rpInd.ShowRecentAge(sym, dur, ind, mode)
            val = rpInd.ShowRecentStateValue(sym, dur, ind, mode)
            crxtime = rpInd.ShowRecentCRXTime(sym, dur, ind, mode)
            price = rpInd.ShowRecentClPrice(sym, dur, ind, mode)
            if ind == 'mcross':
                textline = []
                tlist = [
                    state, dur, stateAge, val, price, crxtime, threshold, sym,
                    ind
                ]
                for t in tlist:
                    textline.append(str(t))
                text.append(str(textline))

                print state, dur, stateAge, val, price, crxtime, threshold, sym, ind
##        Triggers = rpInd.Trigger_from_states(sym,dur,'kupper')
##        lasttwo = rpu_rp.tail_array_to_array(Triggers,2)
##        for l in lasttwo:
##            print l[0],l[1],l[7],l[5],l[8],l[11],'kupperflips'
    print recenttick(sym)
    print '======================='
    return text
def make_dur_state(sym, dur, threshold, indlist):
    ##    print sym,dur, crxcode
    rpInd.create_states_files(sym, dur, today, threshold, indlist)
    for ind in indlist:
        state = rpInd.ShowRecentState(sym, dur, ind)
        stateAge = rpInd.ShowRecentAge(sym, dur, ind)
        val = rpInd.ShowRecentStateValue(sym, dur, ind)
        crxtime = rpInd.ShowRecentCRXTime(sym, dur, ind)
        crxcode = rpInd.ShowRecentCRXCode(sym, dur, ind)
        price = rpInd.ShowRecentClPrice(sym, dur, ind)

        ##        print  state, stateAge,val,ind, crxtime,price , sym, dur, threshold, crxcode
        print crxcode, sym
def snapshot_sym(sym,today,durslist):
##    print 'got her'
    text = []
    barlist = ['1min', '3mins', '5mins', '15mins', '1hour']
    basisfile = DataDown +today+'.'+sym+'.'+'5secs'+'.both.csv'
    TicksUtile.assemble_dur_bars(today,sym,'1hour','initial',basisfile)
    posstate = rpInd.ShowRecentPositionState(sym)
    text.append(posstate + sym )
    threshold =0.0
    indlist = ['mcross','kupper']
##    print posstate,sym,'recentstate age val | lastcrosstime| name USING THRESH ', threshold
    textline = 'recentstate age val name USING THRESH ' + str(threshold)
    text.append(textline)
    for dur in barlist :
##        print dur
        threshold = 0.0
        if dur == '1min':
            threshold = 0.1
##        print sym,dur
##        make_dur_state(sym,dur,threshold,indlist)
        basisdur = '5secs'
        startmode ='initialize'
        basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
        TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisfile)
### this relys on the sig creator to assemble each time
        rpInd.create_states_files(sym,dur,today,threshold,indlist)
        indlist = ['mcross']
        for ind in indlist:
            mode = 'noboost'     
            state = rpInd.ShowRecentState(sym,dur,ind,mode)
            stateAge = rpInd.ShowRecentAge(sym,dur,ind,mode)
            val = rpInd.ShowRecentStateValue(sym,dur,ind,mode)
            crxtime = rpInd.ShowRecentCRXTime(sym,dur,ind,mode)
            price = rpInd.ShowRecentClPrice(sym,dur,ind,mode)
            if ind == 'mcross':
                textline = []
                tlist = [state, dur, stateAge,val, price, crxtime, threshold, sym, ind]
                for t in tlist:       
                    textline.append(str(t))
                text.append(str(textline))

                print  state, dur, stateAge,val, price, crxtime, threshold, sym, ind
##        Triggers = rpInd.Trigger_from_states(sym,dur,'kupper')
##        lasttwo = rpu_rp.tail_array_to_array(Triggers,2)
##        for l in lasttwo:
##            print l[0],l[1],l[7],l[5],l[8],l[11],'kupperflips'
    print recenttick(sym)
    print '======================='
    return text
示例#9
0
def make_states(smode, date):
    threshold = 0.0
    if smode == 'fullist':
        indlist = [
            'pivot', 'R', 'S', 'S2', 'R2', 'kupper', 'klower', 'kmid', 'ema',
            'diffvES', 'RSI', 'StochK', 'Stoch_CROSS', 'StochD'
        ]
##        print 'cose full'
    else:
        indlist = ['mcross', 'mcd', 'kupper']
    barlist = ['1min', '3mins', '5mins', '15mins']  ##,'78mins']
    for sym in symbol_list:
        ##        print sym,'makestates'
        for dur in barlist:
            rpInd.create_states_files(sym, dur, date, threshold, indlist)
def make_states():
    startmode = 'bothfile'
    startmode = 'initialize'
    for sym in symbol_list:
        TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
###### TicksUtile.prepare_fake_ddlfile(today,sym,'78mins',startmode)
        barlist = ['1min', '3mins', '5mins', '15mins']##,'78mins']
        for dur in barlist :
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur  = '1min'           
            durinseconds = secdict[dur]
            basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
            TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisfile)
##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd'] indlist = ['mcross','mcd','diffESTXvES','RSI','STOCH','stochastic_CROSS']
            indlist = ['mcross','mcd','RSI','StochK','Stoch_CROSS','StochD']
            rpInd.create_states_files(sym,dur,today,threshold,indlist)
示例#11
0
def make_states():
    startmode = 'bothfile'
    startmode = 'initialize'
    for sym in symbol_list:
        TicksUtile.prepare_tickfilesto5secBars(
            today, sym,
            startmode)  ## merge the 5secddload with 5sec recents > 5sec boths
        ###### TicksUtile.prepare_fake_ddlfile(today,sym,'78mins',startmode)
        barlist = ['1min', '3mins', '5mins', '15mins']  ##,'78mins']
        for dur in barlist:
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur = '1min'
            durinseconds = secdict[dur]
            basisfile = DataDown + today + '.' + sym + '.' + basisdur + '.both.csv'
            TicksUtile.assemble_dur_bars(today, sym, dur, startmode, basisfile)
            ##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd'] indlist = ['mcross','mcd','diffESTXvES','RSI','STOCH','stochastic_CROSS']
            indlist = [
                'mcross', 'mcd', 'RSI', 'StochK', 'Stoch_CROSS', 'StochD'
            ]
            rpInd.create_states_files(sym, dur, today, threshold, indlist)
def loop_one_prepare():
        barlist = ['1min','3mins', '15mins', '1hour', '1day']
        ## pre prepare ES for compares
        startmode = 'initialize'
        TicksUtile.prepare_tickfilesto5secBars(today,'ES',startmode) ## merge the 5secddload with 5sec recents > 5sec boths         
        for dur in barlist :
            durinseconds = secdict[dur]
            basisdur = '5secs'
            basisfile = DataDown +today+'.'+'ES'+'.'+basisdur+'.both.csv'
            TicksUtile.assemble_dur_bars(today,'ES',dur,startmode,basisfile)
############## end ES prepare
        for sym in symbol_list:
            startmode = 'initialize'
            TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths            
            for dur in barlist :
##                print dur, sym
                durinseconds = secdict[dur]
                basisdur = '5secs'
                basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
                TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisfile)
##                indlist = ['StochK','Stoch_CROSS','StochD','pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower',\
##                           'kmid','ema','mcross', 'mcd','diffESTXvES','RSI']
                indlist = ['mcross','mcd','RSI','StochK','Stoch_CROSS','StochD','kupper', 'klower','kmid','diffvES']
                rpInd.create_states_files(sym,dur.replace(' ',''),today,threshold,indlist)
示例#13
0
def make_states(date,symbol_list,barlist,indlist):
    threshold = 0.0
    for sym in symbol_list:
        for dur in barlist :
            rpInd.create_states_files(sym,dur,date,threshold,indlist)
def rounderrp(x,tickvalue):
    opptick = int(1/tickvalue)
    return round(x*opptick)/opptick
############################
def recenttick(sym):
    RecentTickFile = DataDown + today + '.' + sym + '.RTtickslastquote.csv'
    tickvalue = float(tickvaluedict[sym])
    if os.path.isfile(RecentTickFile) :
        tickline = rpu_rp.tail_array_to_array(rpu_rp.CsvToLines(RecentTickFile),1)[0]
        lasttick = rounderrp(float(tickline[5]),tickvalue)
    else:
        lasttick = 9999
    return lasttick
#################
loopmax = 2
loop = 0
symbol_list = ['ES']
########################
threshold = 0.0
while loop < loopmax:
    if loop == 0:
        for sym in symbol_list:
            barlist = ['1day']
            print 'here'
            for dur in barlist :            
                indlist = ['STOCH']
                print sym, dur
                rpInd.create_states_files(sym,dur.replace(' ',''),today,threshold,indlist)              
    loop +=1
####################
示例#15
0
def recenttick(sym):
    RecentTickFile = DataDown + today + '.' + sym + '.RTtickslastquote.csv'
    tickvalue = float(tickvaluedict[sym])
    if os.path.isfile(RecentTickFile):
        tickline = rpu_rp.tail_array_to_array(
            rpu_rp.CsvToLines(RecentTickFile), 1)[0]
        lasttick = rounderrp(float(tickline[5]), tickvalue)
    else:
        lasttick = 9999
    return lasttick


#################
loopmax = 2
loop = 0
symbol_list = ['ES']
########################
threshold = 0.0
while loop < loopmax:
    if loop == 0:
        for sym in symbol_list:
            barlist = ['1day']
            print 'here'
            for dur in barlist:
                indlist = ['STOCH']
                print sym, dur
                rpInd.create_states_files(sym, dur.replace(' ', ''), today,
                                          threshold, indlist)
    loop += 1
####################
barlist =[]
barlist = ['1 Week']
##########################################
date =  rpu_rp.todaysdateunix()
date = '20150905'
datehyphen = rpu_rp.todaysdatehypens(date)
##########################
import RP_Snapshot
sym = 'SPX'
##RP_Snapshot.snapshot_sym(sym,date)
basisdur = '1day'
TicksUtile.assemble_dur_bars(date,sym,'1day','initialize','5secs')
TicksUtile.assemble_bars_1min_basis(date,sym,'1Week','bartobar',basisdur)
indlist = ['mcross','pivot','R','R2','S','S2']
threshold = 0.0
rpInd.create_states_files(sym,'1Week',date,threshold,indlist)
rpInd.create_states_files(sym,'1day',date,threshold,indlist)

'''
def fibbo_50retrace(low,high,sym,perc) :  # could also use a time range for a range of bars / add this to states per duration
    retraceval = (high-low)/(100/perc)
    return retraceval

def check_lines(linesfile,curprice,tolerance):
    for l in linesfile:
        diff = curprice - l[0]
        if diff < tolerance:
            lines.append(l[0])
            pass
        pass
    return lines
barlist = []
barlist = ['1 Week']
##########################################
date = rpu_rp.todaysdateunix()
date = '20150905'
datehyphen = rpu_rp.todaysdatehypens(date)
##########################
import RP_Snapshot
sym = 'SPX'
##RP_Snapshot.snapshot_sym(sym,date)
basisdur = '1day'
TicksUtile.assemble_dur_bars(date, sym, '1day', 'initialize', '5secs')
TicksUtile.assemble_bars_1min_basis(date, sym, '1Week', 'bartobar', basisdur)
indlist = ['mcross', 'pivot', 'R', 'R2', 'S', 'S2']
threshold = 0.0
rpInd.create_states_files(sym, '1Week', date, threshold, indlist)
rpInd.create_states_files(sym, '1day', date, threshold, indlist)
'''
def fibbo_50retrace(low,high,sym,perc) :  # could also use a time range for a range of bars / add this to states per duration
    retraceval = (high-low)/(100/perc)
    return retraceval

def check_lines(linesfile,curprice,tolerance):
    for l in linesfile:
        diff = curprice - l[0]
        if diff < tolerance:
            lines.append(l[0])
            pass
        pass
    return lines
###################
def assemble_bars(sym,barlist,mergemode,loopingflag):
    startmode = 'initialize'
    indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd']
    indlist = ['mcross', 'mcd']
    TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
    
    for dur in barlist :            
    durinseconds = secdict[dur]
    basisdur = '5secs'
    basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
    TicksUtile.assemble_dur_bars(today,sym,dur,durinseconds,startmode,basisfile)
    threshold = 0.0
    
    rpInd.create_states_files(sym,dur.replace(' ',''),today,threshold,indlist)

    add different modes including first run mode to this then wrap into tickutiles and run with diff flags here

    if loop == 0 , run in firstpass mode
    if initialize mode, the basis file is chosen in the module
    
print 'got to loop'
while loop < loopmax:
    if loop == 0:
        for sym in symbol_list:
            startmode = 'initialize'
            TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
            barlist = ['1min','3mins', '15mins', '1hour', '1day']
            for dur in barlist :            
                durinseconds = secdict[dur]
                basisdur = '5secs'
                basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
                TicksUtile.assemble_dur_bars(today,sym,dur,durinseconds,startmode,basisfile)
                threshold = 0.0
                indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd']
                rpInd.create_states_files(sym,dur.replace(' ',''),today,threshold,indlist)
    ####################################
    if float(float(loop)/10) == round((loop/10),1):
        print 'cycle ', loop   
    now = datetime.strftime(datetime.now(),spaceYtime_format)
    now_epoch = int(time.mktime(time.strptime(now, spaceYtime_format)))      
    now_dt = dt.datetime.strptime(now, spaceYtime_format)   
    ###############
    recentsigs =[]
    startmode = 'bothfile'
    startmode = 'initialize'
    for sym in symbol_list:
        TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
        ####################################
        barlist = ['1min', '3mins', '5mins', '15mins']
        for dur in barlist :
            if dur == '1min':
                basisdur = '5secs'
                pass
            else:
                basisdur  = '1min'           
            durinseconds = secdict[dur]
            basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
            TicksUtile.assemble_dur_bars(today,sym,dur,durinseconds,startmode,basisfile)
##            DurBoth = rpu_rp.CsvToLines( DataDown+ today + '.'+sym+'.' + dur.replace(' ','') + '.both.csv')
            threshold = 0.0
##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd']
##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','mcross']
##            indlist = ['pivot', 'mcross','mcd']
            indlist = ['mcross','mcd']
            rpInd.create_states_files(sym,dur,today,threshold,indlist)        
####################
        state15 = rpInd.ShowRecentState(sym,'15mins','mcross','noboost')
        stateAge15 = rpInd.ShowRecentAge(sym,'15mins','mcross','noboost')
##        state5 = rpInd.ShowRecentState(sym,'5mins','mcross')
##        stateAge5 = rpInd.ShowRecentAge(sym,'5mins','mcross')        
        barlist = ['1min', '3mins', '5mins', '15mins']

        for dur in barlist :
            threshold = 0.0
            ALLTriggers=[]
            lasttwo = []

            if dur != '1min':
                Triggers = rpInd.Trigger_from_states(sym,dur,'mcross')
                lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
            for a in lasttwo:
                ALLTriggers.append(a)
            Triggers = rpInd.Trigger_from_states(sym,'15mins','mcd')
            lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
            for a in lasttwo:
                ALLTriggers.append(a)
                ## ADJUST THE TRIGGER TO USE JUT 5MIN IN SLOWER MKTS....
                ## 1 MIN CAN BE USED FOR THE FAST MKTS....OR TO EXIT A POSITION
                
##            threshold = float(-0.20)
##            maCrossNEARTriggers = rpInd.Trigger_MACross(DurBoth,sym,dur,threshold,'manearcross')
##            rpu_rp.WriteArrayToCsvfileAppend(sigarea +sym+'.sigs.csv', ALLTriggers)
############################         
            prevt = 0
            numsigs = len(ALLTriggers)
            signum =0                      
            prevbart_dt = now_dt
            prevbart_epoch = now_epoch
##            2015-08-24 17:35:05,0.0245,pos,0.0646,slopeup,kupper,USD.JPY,poscrxx,1min,118.43,118.36,118.36,5            
            for onesig in ALLTriggers:
                bart =  onesig[0]
                action =onesig[7]
                bart_dt = dt.datetime.strptime(bart, spaceYtime_format)
                bart_epoch = int(time.mktime(time.strptime(bart, spaceYtime_format)))         
                barToNow = now_epoch - bart_epoch
##                barToPrev =  bart_epoch - prevbart_epoch
##                prevbart_epoch = bart_epoch
##                print bart_epoch, barToNow, barToPrev, bart
                if barToNow < recentlimit :
                    tflag = 'nopass'
##                    print 'recent15 min state and age:', state15, stateAge15,sym
                    posstate = rpInd.ShowRecentPositionState(sym)
                    if action == 'negcrxx' and state15 == 'neg' and dur != '1min':
##                        print 'is a sell'
                        tflag = 'passedtest'
                    elif action == 'poscrxx' and state15 == 'pos' and dur != '1min':
##                        print 'is a buy'
                        tflag = 'passedtest'
                        pass
                    elif action == 'poscrxx' and posstate == 'SELL':
                        tflag = 'passedtest'
                        pass
                    elif action == 'negcrxx' and posstate == 'BUY':
                        tflag = 'passedtest'
                        pass
                    else:
##                        print action, ' signal failed on ... ',dur,sym
                        pass
                    if tflag == 'passedtest':
                        lasttick = recenttick(sym)
                        onesig.append(barToNow)
                        onesig.append('xx')
                        onesig.append(lasttick)
                        recentsigs.append(onesig)
    dur = ''
    if len(recentsigs) > 0:
        sigcount =0
        for sig in sorted(recentsigs):
            sigtime = sig[0]
            sym = sig[6]
            sigtype = sig[5]
##            barToPrev=sig[len(sig)-2]
##            barToNow = sig[len(sig)-3]
            priceinsignal = float(sig[len(sig)-1])
            action =sig[7]
            dur = sig[8]
            livesigid = sym+action+dur.replace(' ','')  + sigtype          
            showflag =  look_for_REECNTdupe_sig(livesigid,sigtime)    #'notsupress'                              
            sigcount+=1
            if showflag != 'supress':
                indlist = ['mcross']#, 'R', 'S'] #'1hour',
                stateinfo = ''
                durstatelist = ['15mins', '1hour', '1day']
                tside = 'BUY'
                if 'negcrxx' in action:
                    tside = 'SELL'
                if tside == 'SELL':
                    beep(soundarea+'sellStocks')
                else:
                    beep(soundarea+'buyStocks')
                beep(soundarea+sym)

                print '==============='
                RP_Snapshot.snapshot_sym(sym)               
                print '==============='
                print sym, tside, sigtype, dur, sigtime, now, priceinsignal
########                rpInd.create_lines(sym,bid)
##                print symNEWSdict[sym]
                frsigline=[]                                          
                frsigline.append(sym)
                frsigline.append(tside)
                frsigline.append(priceinsignal)
                frsigline.append(livesigid)
                frsigline.append(sigtime)
                frsigline.append(now)
                rpu_rp.WriteArrayToCsvfileAppend(sigarea + today +'.recentsigs.csv', [frsigline]) 
                rpu_rp.WriteArrayToCsvfileAppend(sigarea + today +'.recentsigsexec.csv', [frsigline]) 
    loop +=1
####################
    sleep(cycledelay)
print 'finished ',loopmax,' loops  by Signal Creator...dead since..',now
#############
def create_report(Sigfile,sym,barsize):
    print barsize,sym,'number bars studied=',numberBars,numsigs,'=numsigs'
    print 'if i am 20 bars old in signal, start with trail stop depends on dur...shotrt dur = short age'
示例#19
0
def runsigloop():

    ###############
    recentsigs = []
    startmode = 'bothfile'
    startmode = 'initialize'
    blist = ['5mins', '15mins']  #, '1hour']
    for sym in symbol_list:
        ######        for dur in blist:
        ######            new_signaler(sym,dur)
        check_for_lines(sym)
        if sym == 'ES' and 'bla' == 'bla':
            ##            show_bar8_range('04:00:00','7:00:00',sym,date) #asia
            ##            show_bar8_range('09:35:00','12:25:00',sym,date) #europe
            show_bar8_range('16:00:10', '18:25:00', sym, date)  #usa
##        print ' roundies and 10pt intervals' ## then the other lines
        TicksUtile.prepare_tickfilesto5secBars(
            today, sym,
            startmode)  ## merge the 5secddload with 5sec recents > 5sec boths
        ####################################
        ######        TicksUtile.prepare_fake_ddlfile(today,sym,'78mins',startmode)
        barlist = ['1min', '3mins', '5mins', '15mins']  ##,'78mins']
        for dur in barlist:
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur = '1min'
            durinseconds = secdict[dur]
            basisfile = DataDown + today + '.' + sym + '.' + basisdur + '.both.csv'
            TicksUtile.assemble_dur_bars(today, sym, dur, startmode, basisfile)
            ##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd']
            ##            indlist = ['mcross','mcd','diffESTXvES','RSI','STOCH','stochastic_CROSS']
            indlist = [
                'mcross', 'mcd', 'RSI', 'StochK', 'Stoch_CROSS', 'StochD'
            ]
            rpInd.create_states_files(sym, dur, today, threshold, indlist)
####################
        state15 = rpInd.ShowRecentState(sym, '15mins', 'mcross', 'noboost')
        stateAge15 = rpInd.ShowRecentAge(sym, '15mins', 'mcross', 'noboost')
        ##        state5 = rpInd.ShowRecentState(sym,'5mins','mcross')
        ##        stateAge5 = rpInd.ShowRecentAge(sym,'5mins','mcross')
        barlist = ['1min', '3mins', '5mins', '15mins']
        for dur in barlist:
            ALLTriggers = []
            lasttwo = []
            if dur != '1111min':
                Triggers = rpInd.Trigger_from_states(sym, dur, 'mcross')
                lasttwo = rpu_rp.tail_array_to_array(Triggers, 1)
                for a in lasttwo:
                    ALLTriggers.append(a)
            Triggers = rpInd.Trigger_from_states(sym, '15mins', 'mcd')
            lasttwo = rpu_rp.tail_array_to_array(Triggers, 1)
            for a in lasttwo:
                ALLTriggers.append(a)
            Triggers = rpInd.Trigger_from_statesValues(
                sym, dur, 'StochD', 25,
                85)  #def Trigger_from_statesValues(sym,dur,label,30,70):
            lasttwo = rpu_rp.tail_array_to_array(Triggers, 1)
            for a in lasttwo:
                ALLTriggers.append(a)
            if dur != '1min':
                ##                Triggers = rpInd.Trigger_from_statesValues(sym,dur,'RSI',20,80)
                Triggers = rpInd.Trigger_from_states(sym, dur, 'RSI')
                lasttwo = rpu_rp.tail_array_to_array(Triggers, 1)
                for a in lasttwo:
                    ALLTriggers.append(
                        a
                    )  ## ADJUST THE TRIGGER TO USE JUT 5MIN IN SLOWER MKTS....
                ## 1 MIN CAN BE USED FOR THE FAST MKTS....OR TO EXIT A POSITION
##            threshold = float(-0.20)
##            maCrossNEARTriggers = rpInd.Trigger_MACross(DurBoth,sym,dur,threshold,'manearcross')
##            rpu_rp.WriteArrayToCsvfileAppend(sigarea +sym+'.sigs.csv', ALLTriggers)
############################
##            print ALLTriggers
            prevt = 0
            numsigs = len(ALLTriggers)
            ##            print numsigs
            signum = 0
            prevbart_dt = now_dt
            prevbart_epoch = now_epoch
            ##            2015-08-24 17:35:05,0.0245,pos,0.0646,slopeup,kupper,USD.JPY,poscrxx,1min,118.43,118.36,118.36,5
            for onesig in ALLTriggers:
                bart = onesig[0]
                action = onesig[7]
                indvalue = onesig[1]
                ind = onesig[5]
                bart_dt = dt.datetime.strptime(bart, spaceYtime_format)
                bart_epoch = int(
                    time.mktime(time.strptime(bart, spaceYtime_format)))
                barToNow = now_epoch - bart_epoch
                lasttick = recenttick(sym)
                onesig.append(barToNow)
                onesig.append(indvalue)
                onesig.append(lasttick)
                if barToNow < recentlimit:
                    ##                    print onesig
                    tflag = 'nopass'
                    ##                    print 'recent15 min state and age:', state15, stateAge15,sym
                    posstate = rpInd.ShowRecentPositionState(sym)
                    if action == 'negcrxx' and state15 == 'neg' and dur != '1min':
                        ##                        print 'is a sell'
                        tflag = 'passedtest'
                    elif action == 'poscrxx' and state15 == 'pos' and dur != '1min':
                        ##                        print 'is a buy'
                        tflag = 'passedtest'
                        pass
                    elif action == 'poscrxx' and posstate == 'SELL':
                        tflag = 'passedtest'
                        pass
                    elif action == 'negcrxx' and posstate == 'BUY':
                        tflag = 'passedtest'
                        pass
                    elif ind == 'RSI':
                        ##                        print onesig
                        tflag = 'passedtest'
                        pass
                    else:
                        ##                        print action, ' signal failed on ... ',dur,sym
                        pass
                    if tflag == 'passedtest':
                        recentsigs.append(onesig)
    return recentsigs
def runsigloop():

    ###############
    recentsigs =[]
    startmode = 'bothfile'
    startmode = 'initialize'
    blist = ['5mins', '15mins']#, '1hour']
    for sym in symbol_list:
######        for dur in blist:
######            new_signaler(sym,dur)
        check_for_lines(sym)
        if sym == 'ES' and 'bla' == 'bla':
##            show_bar8_range('04:00:00','7:00:00',sym,date) #asia
##            show_bar8_range('09:35:00','12:25:00',sym,date) #europe
            show_bar8_range('16:00:10','18:25:00',sym,date) #usa  
##        print ' roundies and 10pt intervals' ## then the other lines
        TicksUtile.prepare_tickfilesto5secBars(today,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
        ####################################
######        TicksUtile.prepare_fake_ddlfile(today,sym,'78mins',startmode)
        barlist = ['1min', '3mins', '5mins', '15mins']##,'78mins']
        for dur in barlist :
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur  = '1min'           
            durinseconds = secdict[dur]
            basisfile = DataDown +today+'.'+sym+'.'+basisdur+'.both.csv'
            TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisfile)
##            indlist = ['pivot', 'R', 'S', 'S2', 'R2','kupper', 'klower', 'kmid','ema','mcross', 'mcd']
##            indlist = ['mcross','mcd','diffESTXvES','RSI','STOCH','stochastic_CROSS']
            indlist = ['mcross','mcd','RSI','StochK','Stoch_CROSS','StochD']
            rpInd.create_states_files(sym,dur,today,threshold,indlist)
####################
        state15 = rpInd.ShowRecentState(sym,'15mins','mcross','noboost')
        stateAge15 = rpInd.ShowRecentAge(sym,'15mins','mcross','noboost')
##        state5 = rpInd.ShowRecentState(sym,'5mins','mcross')
##        stateAge5 = rpInd.ShowRecentAge(sym,'5mins','mcross')        
        barlist = ['1min', '3mins', '5mins', '15mins']
        for dur in barlist :
            ALLTriggers=[]
            lasttwo = []
            if dur != '1111min':
                Triggers = rpInd.Trigger_from_states(sym,dur,'mcross')
                lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
                for a in lasttwo:
                    ALLTriggers.append(a)
            Triggers = rpInd.Trigger_from_states(sym,'15mins','mcd')
            lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
            for a in lasttwo:
                ALLTriggers.append(a)
            Triggers = rpInd.Trigger_from_statesValues(sym,dur,'StochD',25,85)  #def Trigger_from_statesValues(sym,dur,label,30,70):
            lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
            for a in lasttwo:
                ALLTriggers.append(a)                
            if dur != '1min':
##                Triggers = rpInd.Trigger_from_statesValues(sym,dur,'RSI',20,80)
                Triggers = rpInd.Trigger_from_states(sym,dur,'RSI')
                lasttwo = rpu_rp.tail_array_to_array(Triggers,1)
                for a in lasttwo:
                    ALLTriggers.append(a)                ## ADJUST THE TRIGGER TO USE JUT 5MIN IN SLOWER MKTS....
                ## 1 MIN CAN BE USED FOR THE FAST MKTS....OR TO EXIT A POSITION                
##            threshold = float(-0.20)
##            maCrossNEARTriggers = rpInd.Trigger_MACross(DurBoth,sym,dur,threshold,'manearcross')
##            rpu_rp.WriteArrayToCsvfileAppend(sigarea +sym+'.sigs.csv', ALLTriggers)
############################
##            print ALLTriggers
            prevt = 0
            numsigs = len(ALLTriggers)
##            print numsigs
            signum =0                      
            prevbart_dt = now_dt
            prevbart_epoch = now_epoch
##            2015-08-24 17:35:05,0.0245,pos,0.0646,slopeup,kupper,USD.JPY,poscrxx,1min,118.43,118.36,118.36,5
            for onesig in ALLTriggers:
                bart =  onesig[0]
                action =onesig[7]
                indvalue = onesig[1]
                ind =onesig[5]
                bart_dt = dt.datetime.strptime(bart, spaceYtime_format)
                bart_epoch = int(time.mktime(time.strptime(bart, spaceYtime_format)))         
                barToNow = now_epoch - bart_epoch
                lasttick = recenttick(sym)
                onesig.append(barToNow)
                onesig.append(indvalue)
                onesig.append(lasttick)
                if barToNow < recentlimit :
##                    print onesig
                    tflag = 'nopass'
##                    print 'recent15 min state and age:', state15, stateAge15,sym
                    posstate = rpInd.ShowRecentPositionState(sym)
                    if action == 'negcrxx' and state15 == 'neg' and dur != '1min':
##                        print 'is a sell'
                        tflag = 'passedtest'
                    elif action == 'poscrxx' and state15 == 'pos' and dur != '1min':
##                        print 'is a buy'
                        tflag = 'passedtest'
                        pass
                    elif action == 'poscrxx' and posstate == 'SELL':
                        tflag = 'passedtest'
                        pass
                    elif action == 'negcrxx' and posstate == 'BUY':
                        tflag = 'passedtest'
                        pass
                    elif ind == 'RSI':
##                        print onesig
                        tflag = 'passedtest'
                        pass
                    else:
##                        print action, ' signal failed on ... ',dur,sym
                        pass
                    if tflag == 'passedtest':
                        recentsigs.append(onesig)
    return recentsigs