def assemble_lines(sym,barsize,barsizeNtimeframe):
##    print sym, barsize,barsizeNtimeframe
    totalsecs = secdict[barsize]
    timebarforsnaps = barsize
    import datetime as dt
    htickfile =  DataDown+ today + '.'+sym+'.' + barsize + '.csv' #[date 5 mins.2 D.GBP.csv
    Snaptickfile = DataDown + today + '.' + sym + '.ticksnaps.csv'
    SnapBarsFname = DataDown + today + '.' + barsize + '.' + sym + '.SnapBars.csv'
    Sigfile = sigarea + sym +'.sigs.csv'
    snaplines = rpu_rp.CsvToLines(Snaptickfile)
    lline = 'ES, 2015-06-10 00:22:00, 2080.25, 2080.5, 2080.25, 2080.5, -1'
    try:
        lastline = rpu_rp.tail_to_txtfile(htickfile,2,'outfile') ## get last line of historical file for time check
        pass
    except:
        lastline = lline
    lastlineof_hticks = rpu_rp.catstring('outfile') ## this is the last line
    try:
        timeofbar = (lastlineof_hticks.split(',')[1]).split()[1]
    except:
        timeofbar ='23:59:58'
    time_of_last_hbar_dt = dt.datetime.strptime(timeofbar, time_format)
    snapbars = rpInd.create_bars(snaplines,50000,totalsecs,'fullbar','snapshot', sym,time_of_last_hbar_dt,SnapBarsFname)# also creates a file   
    rpu_rp.WriteArrayToCsvfile(DataDown+today + '.' + sym + '.'+ barsize + '.recent.csv',snapbars)
    lines = createlines(htickfile)
    decimalboost = dboostdict[sym]
    return lines
def ddload_cutoff_epoch(histfilename,formatchoice):
    if formatchoice == 'oldformat':
        formatstring = '%H:%M:%S'
    else:
        formatstring = ' %Y-%m-%d %H:%M:%S'
    try:
        rpu_rp.tail_to_txtfile(histfilename,1,TMP +'outfile') ## get last line of historical file for time check
        oneline = rpu_rp.catstring(TMP +'outfile') ## this is the last line
        timeofbar = (oneline.split(',')[1])
        epochtimeofbar = int(time.mktime(time.strptime(timeofbar, formatstring)))
    except:
        timeofbar =' 2015-03-01 23:59:58'
        print 'bombed getting ddload cutoff time in TicksUtile here'
##        rpu_rp.tail_to_txtfile(histfilename,1,TMP +'outfile') ## get last line of historical file for time check
##        oneline = rpu_rp.catstring(TMP +'outfile') ## this is the last line
##        timeofbar = (oneline.split(',')[1])
##        print timeofbar
        epochtimeofbar = int(time.mktime(time.strptime(timeofbar, formatstring)))
    return epochtimeofbar
Exemple #3
0
def ddload_cutoff_epoch(histfilename, formatchoice):
    if formatchoice == 'oldformat':
        formatstring = '%H:%M:%S'
    else:
        formatstring = ' %Y-%m-%d %H:%M:%S'
    try:
        rpu_rp.tail_to_txtfile(
            histfilename, 1, TMP +
            'outfile')  ## get last line of historical file for time check
        oneline = rpu_rp.catstring(TMP + 'outfile')  ## this is the last line
        timeofbar = (oneline.split(',')[1])
        epochtimeofbar = int(
            time.mktime(time.strptime(timeofbar, formatstring)))
    except:
        timeofbar = ' 2015-03-01 23:59:58'
        print 'bombed getting ddload cutoff time in TicksUtile here'
        ##        rpu_rp.tail_to_txtfile(histfilename,1,TMP +'outfile') ## get last line of historical file for time check
        ##        oneline = rpu_rp.catstring(TMP +'outfile') ## this is the last line
        ##        timeofbar = (oneline.split(',')[1])
        ##        print timeofbar
        epochtimeofbar = int(
            time.mktime(time.strptime(timeofbar, formatstring)))
    return epochtimeofbar
print current_time
prevt = 0
numsigs = len(ma)
signum =0
for symbol in symbol_list:
    for tf in barlist:
        bardur = bardict[tf]
        totalsecs = secdict[tf]
        dur = bardur + tf
        htickfile =  DataDown+ today + '.'+symbol+'.' + dur + '.csv') #[date 5 mins.2 D.GBP.csv
        Snaptickfile = DataDown + today + '.' + symbol + '.ticksnaps.csv'
        SnapBarsFname = DataDown + today + '.' +dur + '.' + symbol + '.SnapBars.csv'
        Sigfile = symbol+'.sigs.csv'
        snaplines = rpu_rp.CsvToLines(DataDown + today + '.' + sym + '.ticksnaps.csv')
##########
        lastline = rpu_rp.tail_to_txtfile(htickfile,2,'outfile') ## get last line of historical file for time check
        lastlineof_hticks = rpu_rp.catstring('outfile') ## this is the last line
        try:
            timeofbar = (lastlineof_hticks.split(',')[1]).split()[1]
        except:
            timeofbar ='23:59:58'
        time_of_last_hbar_dt = dt.datetime.strptime(timeofbar, time_format)
        snapbars = rpInd.create_bars(ticklines,50000,timebarforsnaps,'fullbar','snapshot', sym,time_of_last_hbar_dt,SnapBarsFname)# also creates a file   
        rpu_rp.WriteArrayToCsvfile(DataDown+today + '.' + sym + '.'+ dur + '.recent.csv',newbars)
        lines = createlines(htickfile)
        decimalboost = dboostdict[sym]
        create_report(sigfile,lines,decimalboost,tf)

'''
create a report on all distances.....
##############################
    slopemcd = rpInd.show_slope(macrossval,'mcd')
    print len(signmcd),len(macrossval),len(crossesmcd)
    MDarray = rpInd.makearrayJust2(timestamparray,slopebs,signbs,bs,macrossval,crossesmcd,signmcd)
##    macdcrosses = rpInd.show_macd_low_lines(MDarray,'Slope','Slope',3,.001,4)#(arrayin,texttosell,texttobuy,pricefnum,macdtestval,macdfnum)
    ma = rpu_rp.grep_array_to_array(MDarray,'cross')
    rpInd.format_lines(ma,5)  #tailamount
    ################################################
##    setup aloop for time durations
durationselect = '4 D15 mins' ## this has to match timebarforsnaps
files =  glob.glob(DataDown+ today + '.EUR.' +durationselect + '*.csv') #[date 5 mins.2 D.GBP.csv
print files
#############################################
for inputfile in files:  
    sym = inputfile.split('.')[1]
    ticklines = rpu_rp.CsvToLines(today + '.' + sym + '.ticksnaps.csv')
    lastline = rpu_rp.tail_to_txtfile(inputfile,2,'outfile')
    strings= rpu_rp.catstring('outfile')
    fulldatetime = strings.split(',')[1]
    time = fulldatetime.split()[1]
    hourmincutoff = time.split(':')[0] + time.split(':')[1]
    print hourmincutoff
    timebarforsnaps = 900
    newbars =   rpInd.create_bars(ticklines,5000,timebarforsnaps,'fullbar','snapshot', sym,hourmincutoff) #field three is timesize in seconds
##        ## idendify last line of historical as 9:05
##        meld the ticksaps bars to  historical
##        EUR, 2015-06-04 09:05:00, 1.12455, 1.12485, 1.12425, 1.1246, -1
##    the last minute of the main bars = ?
##    tail last line of inputfile
    rpu_rp.WriteArrayToCsvfile(DataDown+today + '.' + sym+ '.recent'+ durationselect + '.csv',newbars)
    lines = createlines(inputfile)
    if 'ES' in str(inputfile) or 'NQ' in str(inputfile):
Exemple #6
0
             currentbar =  l[0].split()[1]
         else:
             currentbar = (l[0].split()[0])   
         currentbar_dt = dt.datetime.strptime(currentbar, time_format)
         now_dt = dt.datetime.strptime(now, time_format)
         barToNow = (now_dt - currentbar_dt).seconds
         barToPrev = (currentbar_dt - prevbart_dt).seconds
         alerttxt = l[1] + '|' + str(barToNow) + '|' + str(barToPrev)+ '|' +str(l)
         prevbart_dt  = currentbar_dt               
         recentlimit = int(var['TimeLimitRecentSigs'])                
         if barToNow < recentlimit:
             rpu_rp.WriteArrayToCsvfileAppend(sigarea +today +'.sigs.csv',ma)
             onesig = ma[len(ma)-1]
             need to add here one sig added to full list, full list of this sym dur sent to file as a whole....
             Snaptickfile = DataDown + today + '.' + sym + '.ticksnaps.csv'
             rpu_rp.tail_to_txtfile(Snaptickfile,2,'lasttick')
             a5 = rpu_rp.CsvToLines('lasttick')
             a6= a5[0]
             bid = a6[1]
             ask = a6[3]
             bsize = a6[2]
             asize = a6[4]
             side =onesig[5]
             rside = 'BUY'
             if side == 'negcrossmcd':
                 rside = 'SELL'
             sym =onesig[1]
             sigdur =onesig[2]
             pricedrift = round((sigprice / float(decimalboost)) - float(ask),4)
             timedrift = barToNow
 ##            print  barToPrev,'second lastsig..bid/ask',bid, ask,a6[2],'X',a6[4],
Exemple #7
0
    ##    macdcrosses = rpInd.show_macd_low_lines(MDarray,'Slope','Slope',3,.001,4)#(arrayin,texttosell,texttobuy,pricefnum,macdtestval,macdfnum)
    ma = rpu_rp.grep_array_to_array(MDarray, 'cross')
    rpInd.format_lines(ma, 5)  #tailamount
    ################################################


##    setup aloop for time durations
durationselect = '4 D15 mins'  ## this has to match timebarforsnaps
files = glob.glob(DataDown + today + '.EUR.' + durationselect +
                  '*.csv')  #[date 5 mins.2 D.GBP.csv
print files
#############################################
for inputfile in files:
    sym = inputfile.split('.')[1]
    ticklines = rpu_rp.CsvToLines(today + '.' + sym + '.ticksnaps.csv')
    lastline = rpu_rp.tail_to_txtfile(inputfile, 2, 'outfile')
    strings = rpu_rp.catstring('outfile')
    fulldatetime = strings.split(',')[1]
    time = fulldatetime.split()[1]
    hourmincutoff = time.split(':')[0] + time.split(':')[1]
    print hourmincutoff
    timebarforsnaps = 900
    newbars = rpInd.create_bars(
        ticklines, 5000, timebarforsnaps, 'fullbar', 'snapshot', sym,
        hourmincutoff)  #field three is timesize in seconds
    ##        ## idendify last line of historical as 9:05
    ##        meld the ticksaps bars to  historical
    ##        EUR, 2015-06-04 09:05:00, 1.12455, 1.12485, 1.12425, 1.1246, -1
    ##    the last minute of the main bars = ?
    ##    tail last line of inputfile
    rpu_rp.WriteArrayToCsvfile(
def process_ticks(lines,decimalboost,dur):
    ################
    ##read variables from the control panel file
    cpfile = EXE + 'signalcreator.controlpanel.csv'
    paramlines = rpu_rp.CsvToLines(cpfile)
    varstrings = ['TimeLimitRecentSigs','SignalsToShow','DurationToShow']
    var = {}
    for varstring in varstrings:
        for line in paramlines:
            if len(line) > 0:
                if line[0] == varstring:
                    var[varstring] = line[1]    
    bs = rpInd.strip1float(lines,5,decimalboost) ##raw close price
    bshighs = rpInd.strip1float(lines,3,decimalboost)
    bslows = rpInd.strip1float(lines,4,decimalboost)
    timestamparray = rpInd.strip1string(lines,1)
    symarray = rpInd.strip1string(lines,0)
    sym = symarray[1]
    durarray = []
    for b in symarray:
        durarray.append(dur) 
### create pivots rs and ss ###
    piv = rpInd.pivotpoint(bs,bshighs,bslows)
    R1 = rpInd.R1(piv,bshighs)
########################################
    signbs = rpInd.show_sign(bs,'price')
    slopebs = rpInd.show_slope(bs,'price')
    ##### MA Cross ##
    macrossval = rpInd.difftwoarrays(rpInd.EMAmvavgToArray(bs,9),rpInd.EMAmvavgToArray(bs,21))
    signmcd = rpInd.show_sign(macrossval,'mcd') 
    crossesmcd = rpInd.show_crossover(signmcd,'mcd')
    slopemcd = rpInd.show_slope(macrossval,'mcd')
    MDarray = rpInd.makearrayJust2(timestamparray,symarray,durarray,bs,macrossval,crossesmcd,signmcd)
    ma = rpu_rp.grep_array_to_array(MDarray,'cross')
    rpu_rp.WriteArrayToCsvfileAppend(sigarea +sym+'.sigs.csv', ma)    
##############################
    from datetime import datetime
    prevt = 0
    numsigs = len(ma)
    signum =0
    import datetime as dt  
    now = datetime.strftime(datetime.now(),time_format)
    now_dt = dt.datetime.strptime(now, time_format)
    prevbart_dt = now_dt
    for l in ma:
        sym = l[1] #.split()[0])
        sigprice = float(l[3]) #.split()[0])
##        print l
        signum +=1
        if len(l[0].split()) == 2:  
            currentbar =  l[0].split()[1]
        else:
            currentbar = (l[0].split()[0])   
        currentbar_dt = dt.datetime.strptime(currentbar, time_format)
        now_dt = dt.datetime.strptime(now, time_format)
        barToNow = (now_dt - currentbar_dt).seconds
        barToPrev = (currentbar_dt - prevbart_dt).seconds
        alerttxt = l[1] + '|' + str(barToNow) + '|' + str(barToPrev)+ '|' +str(l)
        prevbart_dt  = currentbar_dt
        
        recentlimit = int(var['TimeLimitRecentSigs'])
        
        if barToNow < recentlimit and signum == numsigs:
            rpu_rp.WriteArrayToCsvfile(sigarea +'sigs.csv',ma)
            onesig = ma[len(ma)-1]
            Snaptickfile = DataDown + today + '.' + sym + '.ticksnaps.csv'
            rpu_rp.tail_to_txtfile(Snaptickfile,2,'lasttick')
            a5 = rpu_rp.CsvToLines('lasttick')
            a6= a5[0]
            bid = a6[1]
            ask = a6[3]
            bsize = a6[2]
            asize = a6[4]
            side =onesig[5]
            rside = 'BUY'
            if side == 'negcrossmcd':
                rside = 'SELL'
            sym =onesig[1]
            sigdur =onesig[2]
            pricedrift = round((sigprice / float(decimalboost)) - float(ask),4)
            timedrift = barToNow
##            print  barToPrev,'second lastsig..bid/ask',bid, ask,a6[2],'X',a6[4],
            print timedrift, pricedrift, sym, rside,sigdur, sigprice,bid,ask,bsize,asize,barToPrev
            print '=========='