当前位置: 首页>>代码示例>>Python>>正文


Python TicksUtile类代码示例

本文整理汇总了Python中TicksUtile的典型用法代码示例。如果您正苦于以下问题:Python TicksUtile类的具体用法?Python TicksUtile怎么用?Python TicksUtile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TicksUtile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_oneloop

def run_oneloop(dur,now,sym):
    now_epoch = int(time.mktime(time.strptime(now, spaceYtime_format)))
    print '##### ',now, dur, sym,' ####### '
    Createlines.create_HAs([sym])
    ##########
    perc = .60
    maxlines = 12
    difflimit = 700
    taglist = ['buy','sell','allxx']
    for tag in taglist:    
        b = showlines(sym,dur,tag)
        print '#############'
        print '>>>>>> ',tag.upper(), 'WINDOW',dur,sym, ' <<<'
        lenha = len(b)
        c=0
        climitlines = int(lenha * perc)
        climit = max((lenha-maxlines),climitlines)
        bar_time = '  2016-02-21 13:16:30'
        for lha in b:
            c+=1
            if tag != 'allxx':
                if len(lha.split('|')) > 2:
                    bar_time = (lha.split('|')[3]).replace(' 201','201')  
                bar_time_epoch =  TicksUtile.time_to_epoch(bar_time)          
                tdiff =  now_epoch - bar_time_epoch
            else:
                    bar_time_epoch =  TicksUtile.time_to_epoch(bar_time)          
                    tdiff =  0# now_epoch - bar_time_epoch                
            if c > climit and tdiff < difflimit :
                print lha,'>>> ',tdiff #,difflimit
开发者ID:reprior123,项目名称:WEBPY,代码行数:30,代码来源:RunInds.py

示例2: chopMonthToDays

def chopMonthToDays(bararray,sym,dur,secs):  ### what does this do?
    lines = bararray
    print secs
    preve = 0
    prevfname = 0
    ubars =[]
    uubars =[]
    diffprev = 1
    daylist =[]
    for l in lines:
        if len(l) > 2:
            timestring = l[1]
            date = timestring[0:11]
            daylist.append(date)
    daylistu = rpu_rp.uniq(daylist)
    for day in daylistu:
        daysarray=[]
        for l in bararray:
            if day in l[1] :
                timestring = l[1]
                try:
                    e = TicksUtile.convertTime(timestring,'dashspace','timetoepoch')
                except:
                    e = TicksUtile.convertTime(timestring,'dashspace','timetoepoch')
                diffcur = e - preve
                preve = e
##                print diffcur,timestring
                if diffcur == int(secs):
                    daysarray.append(l)
##                    print l
        print day, sym,dur, len(daysarray)
        fileoutname = DataDown + day +'.' + sym +'.' + dur+'.cleaned.csv' 
        rpu_rp.WriteArrayToCsvfile(fileoutname, daysarray)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:33,代码来源:CreateBarDbase.py

示例3: get_vola

def get_vola():
    reqID =33
    ##contract = ibutiles.create_ticksym(99,sym)
    genericTicks =''
    snapshot = True
    sym = 'SPY'
    contract = contractdict[sym]
    tws_conn.reqMktData(reqID,contract,genericTicks,snapshot)
    #########################################
    symid = 0
    for sym in symbol_list:
        print sym
        underlying = symdict[sym]
        if underlying == 'SPY':
            underPricenew = TicksUtile.recenttick(underlying,'dload')
            optionpricenew = TicksUtile.recenttick(sym,'dload')
            optionprice = 5.00
            underPrice = 200.0
            print underPricenew, optionpricenew
            print typedict[sym]
            ATMstrike = round(underPrice,-2)
            print 'atm', ATMstrike
            if typedict[sym] == 'OPT':
                symid+=1
                contract  = contractdict[sym]
                tws_conn.calculateImpliedVolatility(reqID,contract,optionprice,underPrice)
                reqID +=1        
                sleep(1)
                tws_conn.cancelCalculateImpliedVolatility(reqID)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:29,代码来源:LiveTickerVola.py

示例4: createOneMerge

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)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:30,代码来源:RunLines+-+Copy.py

示例5: create_statesdaily

def create_statesdaily():
    for sym in symbol_list:      
        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 = ['pivot', 'R', 'S', 'S2', 'R2']
            for indicator in indlist:
##                print sym
                indarr = rpInd.GetPivots(DurBoth,sym,indicator)
                statename = sym+'.'+dur.replace(' ','')+'.'
                statefile = statearea +statename + indicator  + '.state.csv'
                rpu_rp.WriteArrayToCsvfile(statefile, indarr)
            indlist2 = ['kupper', 'klower', 'kmid']
            for indicator in indlist2:
    ##                print indicator
                indarr = rpInd.GetKupper(DurBoth,sym,indicator)
                statename = sym+'.'+dur.replace(' ','')+'.'
                statefile = statearea +statename + indicator  + '.state.csv'
                rpu_rp.WriteArrayToCsvfile(statefile, indarr)
    ##                keltner_channel_upper(highs,lows,closes,mult)
            indlist3 = ['ema']
            for indicator in indlist3:
    ##                print indicator
                indarr = rpInd.GetEMA(DurBoth,sym,indicator)
                statename = sym+'.'+dur.replace(' ','')+'.'
                statefile = statearea +statename + indicator  + '.state.csv'
                rpu_rp.WriteArrayToCsvfile(statefile, indarr)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:31,代码来源:RP_CreateSignalsxxx.py

示例6: get_vola

def get_vola(symbol_list_opts):
    reqID =111
    symid = 0
    for sym in symbol_list_opts:
        if sym != 'SPY':
            print sym
            underlying = symdict[sym]
            if underlying == 'SPY':
                underPricenew =  float(TicksUtile.recenttick(underlying,'1min'))
                optionpricenew = float(TicksUtile.recenttick(sym,'both'))
                optionprice = underPricenew # 5.00
                underPrice = underPricenew #200.0
                
                ticktype = ticktypedict[sym]
                
                ATMstrike = round(underPrice,0)
                
                if 'SPYF' in sym:
                    print sym, underPrice, optionprice, typedict[sym], 'atm', ATMstrike
                    symid+=1
##                    contract  = contractdict[sym]
                    ATMspyoption = ibutiles.create_option_contract(sym,ATMstrike)
##                    tws_conn.reqRealTimeBars(reqID,ATMspyoption,'',ticktype,0)
##                    print rpu_rp.CsvToLines(replyfname)
##                    reqID +=1 
                    tws_conn.calculateImpliedVolatility(reqID,ATMspyoption,optionprice,underPrice)
                    reqID +=1        
                    sleep(1)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:28,代码来源:VolaCalculate.py

示例7: dload

def dload(symlist,barlist,strikelist,expirylist):
    print symlist
    global bar, sym
    trans_id = 0
    strikelist = [1]
    expirylist  = [1]
    for sym in symlist:
        print sym
        for bar in barlist:
            for strike in strikelist:
                for expiry in expirylist:
                    fname = DataDown+ today + '.' + sym + '.'  + bar.replace(' ','')+'.ddload.csv'
                    TicksUtile.backupTickfiles(fname)
                    ##########
                    duration = bardict[bar]
                    barspaced = bardictspaced[bar]
                    contract = ibutiles.create_contract(sym,strike,expiry)
                    ticktype = ticktypedict[sym]
                    print bar, sym, duration,ticktype, barspaced, strike, expiry
                    tws_conn.reqHistoricalData(trans_id, contract, '', duration, barspaced, ticktype, 0, 2)
                    trans_id = trans_id + 1  
                    sleep(10)
                    
                    tmp = DataDown+ today + '.' + 'tempdlfile' + '.ddload.csv'
                    fname = DataDown+ today + '.' + sym + '.'  + bar.replace(' ','')+'.ddload.csv'
                    shutil.copyfile(tmp,fname)
                    TicksUtile.throw_out_lastbar(fname)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:27,代码来源:IBHistlESFDAX1min.py

示例8: ShowABarofIndByTime

def ShowABarofIndByTime(sym,dur,ind,bartime,barfnumlimit):
    lastbar =[]
    statefile = statearea + sym + '.' +  dur + '.' + ind  + '.state.csv'
    lastfewbars = rpu_rp.tail_array_to_array(rpu_rp.CsvToLines(statefile),barfnumlimit)
    for bar in lastfewbars:
        if TicksUtile.time_to_epoch(bar[0]) <= TicksUtile.time_to_epoch(bartime) :
            lastbar = bar
    return lastbar
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:8,代码来源:rpInd+-+Copy+(2).py

示例9: make_bars_no_5sec

def make_bars_no_5sec(date,startmode,symbol_list,barlist):
    for sym in symbol_list:
        for dur in barlist :
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur  = '1min'
            TicksUtile.assemble_dur_bars(date,sym,dur,startmode,basisdur)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:8,代码来源:RP_CreateSPX.py

示例10: create_weeklies

def create_weeklies():
    sym = 'SPX'
    basisdur = '1day'
    TicksUtile.assemble_dur_bars(date,sym,'1day','initialize','5secs')
    TicksUtile.assemble_bars_1min_basis(date,sym,'1Week','bartobar',basisdur)
    indlist = ['mcross','pivot','R','R2','S','S2']
    threshold = 0.0
    rpInd.create_states_files(sym,'1Week',date,threshold,indlist)
    rpInd.create_states_files(sym,'1day',date,threshold,indlist)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:9,代码来源:CreateBarDbase.py

示例11: loop_one_prepare

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)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:10,代码来源:RP_CreateSignals20150921.py

示例12: parse_signalsNEW

def parse_signalsNEW(rulesetoutput):
##    [['result', 'SELL', 'stochkeasy1minSELL.rules.csv', ' 2015-09-23 08:16:05', 'CL', 46.36]]
    dur = ''
    if len(rulesetoutput) > 0:
        sigcount =0
        for sig in rulesetoutput:
            if len(sig) > 0  and sig[1] != 'nomatch':
                sig.append(now)
                sigtime = sig[3]
                nowepoch  =  TicksUtile.time_to_epoch(now)
##                print sig
                sigepoch  =  TicksUtile.time_to_epoch(sigtime)
                elapsed = nowepoch - sigepoch
##                print elapsed
##                print sig,'sigline',elapsed
                sigtime = sig[3]
                indvalue = 0.0 #float(sig[len(sig)-2])   <<<<<<<<<<<<<<<<<<
                sym = sig[4]
                sigtype = sig[2]
                priceinsignal = float(sig[5]) ### need to unboost the price...
                dboost = dboostdict[sym]
                newprice = priceinsignal / float(dboost)
                sig[5] = newprice
                tside =sig[1]
                dur = '0mins' # sig[8]   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                livesigid = sym+tside+dur+sigtype
                sig.append(livesigid)
                showflag = look_for_dupe_sig(livesigid,sigtime,delaydupetime)   #'notsupress'
                sigcount+=1
######                print sym,tside,sigtype,sigtime,elapsed,str(newprice)
##                if btmode == 'BACKTEST':
##                    soundarea = 'gg'
                if showflag != 'supress':
                    if tside == 'SELL':
####                        beep(soundarea+'sell')
                        print sig
####                        beep(soundarea+sym)
                        print '==============='
##                        Mbox('BuySignal', sig, style)
                    elif tside == 'BUY':
####                        beep(soundarea+'buy')
                        print sig
####                        beep(soundarea+sym)
                        print '==============='
##                        Mbox('BuySignal', sig, style)
                    else:
                        print 'supressing'
    ######                RP_Snapshot.snapshot_sym(sym,date)
                    frsigline=[]
                    rpu_rp.WriteArrayToCsvfileAppend(sigarea + date +'.recentsigs.csv', [sig])
                    rpu_rp.WriteArrayToCsvfileAppend(sigarea + date +'.recentsigsexec.csv', [sig])
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:51,代码来源:CreateSmain+-+Copy.py

示例13: pnl

def pnl(tside,tprice,starttime,sym,exitpnl,stoppnl,tickvalue):   
    dur = '1min'
    estarttime = TicksUtile.time_to_epoch(starttime)
    barcount =0
    sidesign = 1
    if tside == 'BUY':
        sidesign = (-1)
    DurBoth = rpu_rp.CsvToLines( DataDown+ today + '.'+sym+'.' + dur.replace(' ','') + '.both.csv')
    triggertime = 'open'
    maxpnl = -99999
    minpnl = 999999
    profittrigger =  stoptrigger = endflag ='o'
    for line in DurBoth:
        if len(line) > 2:
            rtpricelow = float(line[4])
            rtpricehigh = float(line[3])
            rangegap = rtpricehigh - rtpricelow
            time = line[1]
            baretime = TicksUtile.time_to_epoch(time)
##        else:
##            rtpricelow = rtpricehigh = 0.0
##            baretime = TicksUtile.time_to_epoch(' 2015-08-18 01:54:05')
##            time = ' 2015-08-18 01:54:05'
##            print estarttime, baretime
            if estarttime  > baretime:
                triggertime = 'tripped'
                barcount =0
            
            if triggertime == 'tripped':
                barcount +=1
                if tside == 'BUY':
                    priceused = rtpricelow
                else:
                    priceused = rtpricehigh
                pnl = ((tprice -priceused)/ tickvalue)*sidesign
                maxpnl = max(pnl,maxpnl)
                minpnl = min(pnl,minpnl)
                if maxpnl > exitpnl:
                    profittrigger = 't'
                    pass
                if minpnl < stoppnl:
                    stoptrigger ='t'
                if profittrigger == 't' and stoptrigger == 'o' and endflag != 't':
                    print 'exited for profit'
                    print sym, time, tprice, tside, pnl,maxpnl,minpnl,priceused,rangegap,barcount,starttime
                    endflag ='t'
                if stoptrigger == 't' and profittrigger == 'o' and endflag != 't':
                    print 'exited for loss'
                    endflag ='t'
                    print sym, time, tprice, tside, pnl,maxpnl,minpnl,priceused,rangegap,barcount,starttime
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:50,代码来源:backtester5secs.py

示例14: make_bars_no_5sec

def make_bars_no_5sec(startmode,durmode):
    for sym in symbol_list:
        if durmode == 'alldurs':
            barlist =  ['1min','3mins', '15mins', '1hour', '1day']
            pass
        else:
            barlist = ['1min', '3mins', '5mins', '15mins']##,'78mins']
        for dur in barlist :
##            print dur
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur  = '1min'
            TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisdur)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:14,代码来源:RP_CreateSignals20150921.py

示例15: make_bars_no_5sec

def make_bars_no_5sec(startmode,durmode):
    for sym in symbol_list:
        if durmode == 'alldurs':
            barlist =  barlistAll
        elif durmode == '78':
            barlist = barlist78
        else:
            barlist = barlistRecent
        for dur in barlist :
            if dur == '1min':
                basisdur = '5secs'
            else:
                basisdur  = '1min'
            TicksUtile.assemble_dur_bars(today,sym,dur,startmode,basisdur)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:14,代码来源:RP_CreateavgINnds.py


注:本文中的TicksUtile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。