Пример #1
0
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
Пример #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 '\'vname\' => ' +  '\''+labelprefix+newf.upper() +'\','
        print '\'type\' => ' +  '\''+ ftype +'\','
        if ftype == 'decimal':
            floatval ='15'
            floatprec = '3'
            flen = '14'
            print '\'precision\' => ' +  '\''+ floatprec +'\','         
            print '\'len\' => ' +  '\''+ flen +'\','
        elif ftype =='varchar':
            flen = '40'
            print '\'len\' => ' +  '\''+ flen +'\','
        elif ftype == 'datetime':
            pass
        elif ftype == 'enum':
            flen ='66'
            print '\'len\' => ' +  '\''+ flen +'\','
            print '\'options\' => \'' + dropdownname + '\','
            print '\'default\' => \'' + defaultval + '\','
            pass
        else:
            flen =''
        print '),'
        lablearray.append('\''+labelprefix + newf.upper()  +'\''+ ' => \'' + newf.replace('_',' ') +'\',')

for  l in lablearray:
    print l
        #print '\'LBL_'+newf.upper()  +'\''+ ' => \'' + newf.replace('_',' ') +'\','
    ########################
    
print rpu_rp.catstring('simplefield.vardeftpl.txt')
Пример #5
0
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.....
##############################
1day = buy,6 bars ago, 9 positive ticks ago, starting to roll, nearing a daily pivot
    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):
        decimalboost = 1
Пример #7
0
##        print symbol
        rpu_rp.WriteArrayToCsvfile(symbol+'.sigs.csv', '') # flush the file to keep all sigs
        for tf in barlist:
            bardur = bardict[tf]
            totalsecs = secdict[tf]
            dur = bardur + tf
            files =  glob.glob(DataDown+ today + '.'+symbol+'.' + dur + '.csv') #[date 5 mins.2 D.GBP.csv 
            for inputfile in files:
                fsplit = inputfile.split('.')
                if len(fsplit) == 4:
                    sym = inputfile.split('.')[1]
                else:
                    sym = inputfile.split('.')[1] + '.' + inputfile.split('.')[2]
                ticklines = rpu_rp.CsvToLines(DataDown + today + '.' + sym + '.ticksnaps.csv')
                lastline = rpu_rp.tail_to_txtfile(inputfile,2,'outfile') ## get last line of historical file for time check
                strings= rpu_rp.catstring('outfile') ## this is the last line
                fulldatetime = strings.split(',')[1] #figure out the time
                try:
                    time = fulldatetime.split()[1]
                    pass
                except:
                    time ='23:59:58'
                hourmincutoff = time.split(':')[0] + time.split(':')[1] ## this the cutoff time
                timebarforsnaps = totalsecs
                newbars =   rpInd.create_bars(ticklines,50000,timebarforsnaps,'fullbar','snapshot', sym,hourmincutoff) #field three is timesize in seconds
                for b in newbars:
                    if 'ESxxxx' in b:
                        print b
                rpu_rp.WriteArrayToCsvfile(DataDown+today + '.' + sym + '.'+ dur + '.recent.csv',newbars)
                lines = createlines(inputfile)
                decimalboost = dboostdict[sym]
Пример #8
0
    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',