本文整理汇总了Python中TicksUtile.prepare_tickfilesto5secBars方法的典型用法代码示例。如果您正苦于以下问题:Python TicksUtile.prepare_tickfilesto5secBars方法的具体用法?Python TicksUtile.prepare_tickfilesto5secBars怎么用?Python TicksUtile.prepare_tickfilesto5secBars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TicksUtile
的用法示例。
在下文中一共展示了TicksUtile.prepare_tickfilesto5secBars方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loop_one_prepare
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
def loop_one_prepare():
basisdur = '5secs'
barlist = ['1min','3mins', '15mins', '1hour', '1day']
## pre prepare ES for compares
startmode = 'initialize'
## sym='ES'
TicksUtile.prepare_tickfilesto5secBars(today,'ES',startmode) ## merge the 5secddload with 5sec recents > 5sec boths
for dur in barlist :
## sym = 'ES'
TicksUtile.assemble_dur_bars(today,'ES',dur,startmode,basisdur)
示例2: make_states
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
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)
示例3: loop_one_prepare
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
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)
示例4: make_bars_just_5sec
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
def make_bars_just_5sec(date,startmode,symbol_list):
for sym in symbol_list:
TicksUtile.prepare_tickfilesto5secBars(date,sym,startmode) ## merge the 5secddload with 5sec recents > 5sec boths
示例5: read_vars
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
command = read_vars('Setting',cpfname)
cycledelay = int(read_vars('CycleTime',cpfname))
recentlimit = int(read_vars('TimeLimitRecentSigs',cpfname))
print 'cycle delay changed to...',cycledelay
# change to cycledelay later
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)
print 'cycle heartbeat...searching for sigs in last ',recentlimit
###############
recentsigs =[]
symbol_list = ['ES']
for sym in symbol_list:
## print sym
rpu_rp.WriteArrayToCsvfile(sigarea +sym+'.sigs.csv', []) # flush the file to keep all sigs
TicksUtile.prepare_tickfilesto5secBars(today,sym) ## merge the 5secddload with 5sec recents > 5sec boths
####################################
rpu_rp.WriteArrayToCsvfile(sigarea +sym+'.sigs.csv', [])
for barsize in barlist :
timeframe = bardict[barsize]
durinseconds = secdict[barsize]
barsizeNtimeframe = timeframe + barsize
dur = barsize
TicksUtile.assemble_dur_bars(today,sym,dur,durinseconds)
DurBoth = rpu_rp.CsvToLines( DataDown+ today + '.'+sym+'.' + dur.replace(' ','') + '.both.csv')
indlist = ['MACROSS', 'MCDiv', 'price']
for indicator in indlist:
indarr = rpInd.GetStates(DurBoth,sym,indicator)
statename = sym+'.'+dur.replace(' ','')+'.'
statefile = statearea +statename + indicator + '.state.csv'
示例6: create_slicendice
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
def create_slicendice():
#analyze
prevcycledelay = 2
########################
print 'got to loop'
while loop < loopmax:
if loop == 0:
create_statesdaily()
if (round((loop/10),-1) - loop) == 0:
print 'cycle ', loop
fileage = check_for_CP_change(cpfname)
if fileage < 50:
command = read_vars('Setting',cpfname)
cycledelay = int(read_vars('CycleTime',cpfname))
recentlimit = int(read_vars('TimeLimitRecentSigs',cpfname))
print 'cycle delay changed to...',cycledelay
# change to cycledelay later
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)
## print 'ccreate sigs searching for sigs in last ',recentlimit
###############
recentsigs =[]
## symbol_list = ['ES']
for sym in symbol_list:
## print sym
rpu_rp.WriteArrayToCsvfile(sigarea +sym+'.sigs.csv', []) # flush the file to keep all sigs
TicksUtile.prepare_tickfilesto5secBars(today,sym) ## merge the 5secddload with 5sec recents > 5sec boths
####################################
rpu_rp.WriteArrayToCsvfile(sigarea +sym+'.sigs.csv', [])
for barsize in barlist :
timeframe = bardict[barsize]
durinseconds = secdict[barsize]
barsizeNtimeframe = timeframe + barsize
dur = barsize
TicksUtile.assemble_dur_bars(today,sym,dur,durinseconds)
DurBoth = rpu_rp.CsvToLines( DataDown+ today + '.'+sym+'.' + dur.replace(' ','') + '.both.csv')
indlist = ['MACROSS', 'MCDiv', 'price']
for indicator in indlist:
indarr = rpInd.GetStates(DurBoth,sym,indicator)
statename = sym+'.'+dur.replace(' ','')+'.'
statefile = statearea +statename + indicator + '.state.csv'
rpu_rp.WriteArrayToCsvfile(statefile, indarr)
indlist = ['klower', 'kmid', 'kupper']
for indicator in indlist:
indarr = rpInd.GetKupper(DurBoth,sym,indicator)
statename = sym+'.'+dur.replace(' ','')+'.'
statefile = statearea +statename + indicator + '.state.csv'
rpu_rp.WriteArrayToCsvfile(statefile, indarr)
####################
macdTriggers = rpInd.Trigger_MACD(DurBoth,sym,barsize)
maCrossTriggers = rpInd.Trigger_MACross(DurBoth,sym,barsize)
for a in maCrossTriggers:
macdTriggers.append(a)
state = 'seefile'
## sigbart = ((lline[0])[0])
## sigbart_epoch = int(time.mktime(time.strptime(sigbart, spaceYtime_format)))
## barage = str(round((now_epoch - sigbart_epoch)/int(durinseconds),2))
barage = 'need barage'
rpu_rp.WriteArrayToCsvfileAppend(sigarea +sym+'.sigs.csv', macdTriggers)
############################
prevt = 0
numsigs = len(macdTriggers)
signum =0
prevbart_dt = now_dt
prevbart_epoch = now_epoch
for l in macdTriggers:
bart = l[0]
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
if barToNow < recentlimit:
onesig = l
sym =onesig[1]
lasttick = recenttick(sym)
onesig.append(barToNow)
onesig.append(barToPrev)
onesig.append(lasttick)
recentsigs.append(onesig)
dur = ''
if len(recentsigs) > 0:
## macrossstate = statefile = sigarea +statename +'.MACROSS.state.csv'
sigcount =0
for sig in sorted(recentsigs):
sigtime = sig[0]
sym = sig[1]
sigtype = sig[5]
barToPrev=sig[len(sig)-2]
barToNow = sig[len(sig)-3]
bid = sig[len(sig)-1]
action =sig[5]
dur = sig[2]
livesigid = sym+action+dur.replace(' ','')
showflag = look_for_dupe_sig(livesigid)
sigcount+=1
#.........这里部分代码省略.........
示例7: assemble_bars
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
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:
#.........这里部分代码省略.........
示例8: runsigloop
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
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
#.........这里部分代码省略.........
示例9: createOneMerge
# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import prepare_tickfilesto5secBars [as 别名]
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)
#################################
loopmax = 505
loop = 0
while loop < loopmax:
TicksUtile.prepare_tickfilesto5secBars(date,sym,'initialize')
# need to create 5secs and then each dur before proceding
now = datetime.strftime(datetime.now(),spaceYtime_format)
durlist = ['1min','3mins','5mins','15mins','1hour','1day']
for dur in durlist:
createOneMerge(dur,now,sym,date)
dur = '5mins'
run_oneloop(dur,now,sym,date)
factor = 1
limitlines = 5.0
if sym == 'FDAX':
limitlines = 15.0
curprice = float(TicksUtile.recenttick(sym,'recent'))
print '###### LINEFADES #### ',curprice ,sym
spotfiles = ['Full.','WBDaily.','Roundies.','AutoPivot.']
print 'range is ',limitlines, 'check for passes'