def createOneMerge(dur, now, sym, date): now_epoch = int(time.mktime(time.strptime(now, spaceYtime_format))) ## print '##### ', dur, sym,' ####### ' durinseconds = secdict[dur] basisdur = '1min' if dur == '1min': basisdur = '5secs' basisfile = DataDown + date + '.' + sym + '.' + basisdur + '.both.csv' ### this bit not used yet until expand startmode basisbars = rpu_rp.CsvToLines(basisfile) ## print'creating bars' recentbars = TicksUtile.create_bars_from_bars(basisbars, date, sym, dur, durinseconds, 'noHA') ## print 'done creating bars' filerecent = DataDown + date + '.' + sym + '.' + dur.replace( ' ', '') + '.recent' + '.csv' rpu_rp.WriteArrayToCsvfile(filerecent, recentbars) ## now merge recent and both fileddload = filerecent.replace('recent', 'ddload') outfile = filerecent.replace('recent', 'both') cutoffmintime = int(int(durinseconds) - 5) if os.path.isfile(filerecent): TicksUtile.merge_bar_files(filerecent, fileddload, outfile, cutoffmintime) else: shutil.copyfile(fileddload, outfile) ## print 'found no ddload file so did no merge' ########## basisfile = DataDown + date + '.' + sym + '.' + dur + '.both.csv' ### note the basis dur changed to just dur!! basisbars = rpu_rp.CsvToLines(basisfile) HAbars = TicksUtile.create_bars_from_bars(basisbars, date, sym, dur, durinseconds, 'hamode') ## print 'done creating HA bars' fileHABoth = DataDown + date + '.' + sym + '.' + dur.replace( ' ', '') + '.bothHA' + '.csv' rpu_rp.WriteArrayToCsvfile(fileHABoth, HAbars)
def createOneMerge(dur,now,sym,date): now_epoch = int(time.mktime(time.strptime(now, spaceYtime_format))) ## print '##### ', dur, sym,' ####### ' durinseconds= secdict[dur] basisdur = '1min' if dur == '1min': basisdur ='5secs' basisfile = DataDown +date+'.'+sym+'.'+basisdur+'.both.csv' ### this bit not used yet until expand startmode basisbars = rpu_rp.CsvToLines(basisfile) ## print'creating bars' recentbars = TicksUtile.create_bars_from_bars(basisbars,date,sym,dur,durinseconds,'noHA') ## print 'done creating bars' filerecent = DataDown +date+'.'+sym+'.'+dur.replace(' ','')+'.recent' +'.csv' rpu_rp.WriteArrayToCsvfile(filerecent,recentbars) ## now merge recent and both fileddload = filerecent.replace('recent','ddload') outfile = filerecent.replace('recent','both') cutoffmintime = int(int(durinseconds) - 5) if os.path.isfile(filerecent): TicksUtile.merge_bar_files(filerecent,fileddload,outfile,cutoffmintime) else: shutil.copyfile(fileddload,outfile) ## print 'found no ddload file so did no merge' ########## basisfile = DataDown +date+'.'+sym+'.'+dur+'.both.csv' ### note the basis dur changed to just dur!! basisbars = rpu_rp.CsvToLines(basisfile) HAbars = TicksUtile.create_bars_from_bars(basisbars,date,sym,dur,durinseconds,'hamode') ## print 'done creating HA bars' fileHABoth = DataDown +date+'.'+sym+'.'+dur.replace(' ','')+'.bothHA' +'.csv' rpu_rp.WriteArrayToCsvfile(fileHABoth,HAbars)
## raw_input('ddd') ## os.system('grep " 16:1" ' + f + ' | head -5 >> newtempf ') ## os.system('grep " 16:2" ' + f + ' | head -5 >> newtempf ') bararrayin = rpu_rp.CsvToLines('allticks') laterticks = rpu_rp.CsvToLines('laterticks') for l in bararrayin: pass ## print l print '=====' filemode ='test' startmode = 'no merge' durinseconds = 300 dur = '5 mins' today = 'bla' arrayout = TicksUtile.create_bars_from_bars(bararrayin,today,sym,dur,durinseconds,startmode,filemode) ## os.system('grep pos tempf | grep slopedn | tail -15 > newtempf ') ## for item in sorted(arrayout): ## print arrayout for item in arrayout: ## print item if '16:05:' in str(item): low = float(item[4]) high = item[3] date = item[1] sym = item[0] ## print date,sym, high, low print 'xxxxx' # which happended first...violate the high or the low?
loop += 1 sleep(cycledelay) ## print command,'com setting timedrift..pricedrift',now recentsigs = [] rpu_rp.WriteArrayToCsvfile(sigarea + today + '.sigs.csv', []) # flush the file to keep all sigs for sym in symbol_list: rpu_rp.WriteArrayToCsvfile(sigarea + sym + '.sigs.csv', []) # flush the file to keep all sigs ## merge the 5secddload with 5sec recents > 5sec boths RTticksFile = DataDown + today + '.' + sym + '.RTticks.csv' RTBarsin = rpu_rp.CsvToLines(RTticksFile) RTTickBarsReformatted = TicksUtile.format_RTTicks_to_5secBars( RTBarsin, sym) RTBars5Sec = TicksUtile.create_bars_from_bars( RTTickBarsReformatted, today, sym, '5 secs', 1) ##RTticks > RTbars[5secRecentBars] ## print '5sec bars done' filetomerge = DataDown + today + '.' + sym + '.' + '5 secs' + '.ddload.csv' #. .. only really need to do this once..test for recent file? TicksUtile.merge_bar_files(filetomerge) #this creates the both file ## print 'finish tick rewrite' #################################### for barsize in barlist: #[barlist[0]]: timeframe = bardict[barsize] durinseconds = secdict[barsize] barsizeNtimeframe = timeframe + barsize decimalboost = dboostdict[sym] dur = barsize TicksUtile.create_bars_from_bars(RTBars5Sec, today, sym, dur, durinseconds) ## writes recent
controlflag = False print 'got the order to exit program....!!! <<<' loopmax = 1 ############### loop +=1 sleep(cycledelay) ## print command,'com setting timedrift..pricedrift',now recentsigs =[] rpu_rp.WriteArrayToCsvfile(sigarea +today+'.sigs.csv', []) # flush the file to keep all sigs for sym in symbol_list: rpu_rp.WriteArrayToCsvfile(sigarea +sym+'.sigs.csv', []) # flush the file to keep all sigs ## merge the 5secddload with 5sec recents > 5sec boths RTticksFile = DataDown +today+'.'+sym+ '.RTticks.csv' RTBarsin = rpu_rp.CsvToLines(RTticksFile) RTTickBarsReformatted = TicksUtile.format_RTTicks_to_5secBars(RTBarsin,sym) RTBars5Sec = TicksUtile.create_bars_from_bars(RTTickBarsReformatted,today,sym,'5 secs',1) ##RTticks > RTbars[5secRecentBars] ## print '5sec bars done' filetomerge = DataDown +today+'.'+sym+'.'+'5 secs'+'.ddload.csv' #. .. only really need to do this once..test for recent file? TicksUtile.merge_bar_files(filetomerge) #this creates the both file ## print 'finish tick rewrite' #################################### for barsize in barlist :#[barlist[0]]: timeframe = bardict[barsize] durinseconds = secdict[barsize] barsizeNtimeframe = timeframe + barsize decimalboost = dboostdict[sym] dur = barsize TicksUtile.create_bars_from_bars(RTBars5Sec,today,sym,dur,durinseconds) ## writes recent ## merge the dur ddload with dur recents > dur boths filetomerge = DataDown +today+'.'+sym+'.'+dur+'.ddload.csv'
## raw_input('ddd') ## os.system('grep " 16:1" ' + f + ' | head -5 >> newtempf ') ## os.system('grep " 16:2" ' + f + ' | head -5 >> newtempf ') bararrayin = rpu_rp.CsvToLines('allticks') laterticks = rpu_rp.CsvToLines('laterticks') for l in bararrayin: pass ## print l print '=====' filemode = 'test' startmode = 'no merge' durinseconds = 300 dur = '5 mins' today = 'bla' arrayout = TicksUtile.create_bars_from_bars(bararrayin, today, sym, dur, durinseconds, startmode, filemode) ## os.system('grep pos tempf | grep slopedn | tail -15 > newtempf ') ## for item in sorted(arrayout): ## print arrayout for item in arrayout: ## print item if '16:05:' in str(item): low = float(item[4]) high = item[3] date = item[1] sym = item[0] ## print date,sym, high, low print 'xxxxx'