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
## rpInd.backtest_sigs(newarray[tailstart:600000],'slope','slope',3) ## rpInd.show_test_lines(newarray[tailstart:600000],'negnegcross','posposcross',3) ## rpInd.show_macd_low_lines(newarray[tailstart:600000],'negnegcross','posposcross',3,(0.005/decimalboost)) smiarray = rpInd.join_8arrays_to_1_array(timestamparray,slope50,sign50,bs,sma50,smacrossdiff,tenkan,kijunSen,'3strings') rpInd.show_macd_low_lines(smiarray[tailstart:600000],'negnegcrossxxx','posposcrossxxx',3,(1.0/decimalboost)) ################################################ durationselect = '3 M1 Day' files = glob.glob(EXE+ 'IbPy-master/' + today + '.*.' +durationselect + '*.csv') #[date 5 mins.2 D.GBP.csv print files ############################################# for inputfile in files: sym = inputfile.split('.')[1] print sym ticklines = rpu_rp.CsvToLines(today + '.' + sym + '.ticksnaps.csv') newbars = rpInd.create_bars(ticklines,5000,900,'fullbar','snapshot', sym) rpu_rp.WriteArrayToCsvfile(today + '.' + sym+ '.recent'+ durationselect + '.csv',newbars) lines = createlines(inputfile) if 'ES' in str(inputfile) or 'NQ' in str(inputfile): decimalboost = 1 elif 'USD' in str(inputfile): decimalboost= 100 else: decimalboost = 1000 process_ticks(lines,decimalboost) raw_input('click to continue ' + sym ) ########################################## ''' TenkanSenmvavgToArray(arrayhighs,arraylows,smaNum): C:\Users\bob\GDRIVE\EXE_RP\IbPy-master>grep def rpI* def strip1string(multilinearrayin,fieldnum):
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 124.81,13:17:22,124.8075,124.8275,124.7975,124.8125,50000,904,124.8125 ES, 2015-06-02 00:00:00, 2111.0, 2111.5, 2110.75, 2111.25, -1 import ctypes # An included library with Python install. def Mbox(title, text, style): ctypes.windll.user32.MessageBoxA(0, text, title, style)
## 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 elif 'USD' in str(inputfile): decimalboost= 100 else: decimalboost = 100 process_ticks(lines,decimalboost) raw_input('click to continue ' + sym + inputfile)
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] process_ticks(lines,decimalboost,tf) sleep(9) ''' create a report on all distances..... ############################## 1day = buy,6 bars ago, 9 positive ticks ago, starting to roll, nearing a daily pivot 124.81,13:17:22,124.8075,124.8275,124.7975,124.8125,50000,904,124.8125 ES, 2015-06-02 00:00:00, 2111.0, 2111.5, 2110.75, 2111.25, -1
rpInd.show_macd_low_lines(smiarray[tailstart:600000], 'negnegcrossxxx', 'posposcrossxxx', 3, (1.0 / decimalboost)) ################################################ durationselect = '3 M1 Day' files = glob.glob(EXE + 'IbPy-master/' + today + '.*.' + durationselect + '*.csv') #[date 5 mins.2 D.GBP.csv print files ############################################# for inputfile in files: sym = inputfile.split('.')[1] print sym ticklines = rpu_rp.CsvToLines(today + '.' + sym + '.ticksnaps.csv') newbars = rpInd.create_bars(ticklines, 5000, 900, 'fullbar', 'snapshot', sym) rpu_rp.WriteArrayToCsvfile( today + '.' + sym + '.recent' + durationselect + '.csv', newbars) lines = createlines(inputfile) if 'ES' in str(inputfile) or 'NQ' in str(inputfile): decimalboost = 1 elif 'USD' in str(inputfile): decimalboost = 100 else: decimalboost = 1000 process_ticks(lines, decimalboost) raw_input('click to continue ' + sym) ########################################## ''' TenkanSenmvavgToArray(arrayhighs,arraylows,smaNum): C:\Users\bob\GDRIVE\EXE_RP\IbPy-master>grep def rpI*