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


Python TicksUtile.time_to_epoch方法代码示例

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


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

示例1: run_oneloop

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
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,代码行数:32,代码来源:RunInds.py

示例2: ShowABarofIndByTime

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
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,代码行数:10,代码来源:rpInd+-+Copy+(2).py

示例3: parse_signalsNEW

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
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,代码行数:53,代码来源:CreateSmain+-+Copy.py

示例4: pnl

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
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,代码行数:52,代码来源:backtester5secs.py

示例5: look_for_dupe_sig

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def look_for_dupe_sig(livesigid,livesigtime):
    showflag = 'show'
    livesigepoch = TicksUtile.time_to_epoch(livesigtime)
    if os.path.isfile(sigarea + today +'.recentsigs.csv'): 
        tradedsigs= rpu_rp.CsvToLines(sigarea + today +'.recentsigs.csv')
        showflag = 'show'     
        for lin in tradedsigs:
            if len(lin) > 3:
                sigid = lin[3]
                sigtime = lin[4]
                sigtimeepoch = TicksUtile.time_to_epoch(sigtime)
                timediff = livesigepoch - sigtimeepoch
                if sigid == livesigid and timediff < 100:
                    showflag = 'supress'
    return showflag
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:17,代码来源:RP_CreateSignalsold+(3).py

示例6: show_hi_lo_bar_range

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def show_hi_lo_bar_range(sym,dur,startbartime,endbartime,date):
    hilow = []
    prevloprice =99999
    prevhiprice = 0.0
    lowtime = hitime = closetime ='na'
    clsprice =0.0

    newbars = show_bar_range(sym,dur,startbartime,endbartime,date)
    for bar in newbars:
        if len(bar) > 2:
            curbartime = TicksUtile.time_to_epoch(bar[1])
            lowprice = float(bar[4])
            hiprice = float(bar[3])
            clsprice = float(bar[5])
            closetime = bar[1]
            lowtime = hitime ='na'
            if lowprice < prevloprice:
                prevloprice = lowprice
                lowtime = bar[1]
            if hiprice > prevhiprice:
                prevhiprice = hiprice
                hitime = bar[1]
    hilow.append(prevloprice)
    hilow.append(prevhiprice)
    hilow.append(lowtime)
    hilow.append(hitime)
    hilow.append(clsprice)
    hilow.append(closetime)
    if len(newbars) == 0:
        hilow = ['na','na','na','na','na','na']
    return hilow
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:33,代码来源:RP_Snapshotpre.py

示例7: look_for_REECNTdupe_sig

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def look_for_REECNTdupe_sig(livesigid,livesigtime):
    livesigepoch = TicksUtile.time_to_epoch(livesigtime)
    if os.path.isfile(sigarea + today +'.recentsigs.csv'): 
        tradedsigs= rpu_rp.CsvToLines(sigarea + today +'.recentsigs.csv')
        showflag = 'show'
        
        for lin in tradedsigs:
            if len(lin) > 3:
                sigid = lin[3]
                sigtime = lin[1]
                sigtimeepoch = TicksUtile.time_to_epoch(sigtime)
                timediff = livesigepoch - sigtimeepoch
                if sigid == livesigid and timediff < 200:
                    showflag = 'supress'
                    print 'dupe ignored...',sigid, now
    else:
        showflag = 'show'
    return showflag
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:20,代码来源:RP_CreateSignalsModule.py

示例8: look_for_dupe_sig

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def look_for_dupe_sig(livesigid,livesigtime,delay):
    showflag = 'show'
    livesigepoch = TicksUtile.time_to_epoch(livesigtime)
    if os.path.isfile(sigarea + date +'.recentsigs.csv'):
        tradedsigs= rpu_rp.CsvToLines(sigarea + date +'.recentsigs.csv')
        showflag = 'show'
        for lin in tradedsigs:
##            print lin
            if len(lin) > 3:
##                print lin
                sigid = lin[9]
                sigtime = lin[3]
##                print sigid,sigtime,livesigid,livesigtime
                sigtimeepoch = TicksUtile.time_to_epoch(sigtime)
                timediff = livesigepoch - sigtimeepoch
                if sigid == livesigid and timediff < delay:
                    showflag = 'supress'
    return showflag
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:20,代码来源:CreateSmain+-+Copy.py

示例9: show_bar_range

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def show_bar_range(sym,dur,startbartime,endbartime,date):
##    print date
    datehyphen = rpu_rp.todaysdatehypens(date)
##    print datehyphen
    startbartime = TicksUtile.time_to_epoch(datehyphen + startbartime)
    endbartime = TicksUtile.time_to_epoch(datehyphen + endbartime)

    stem = '.'+dur +'.both.csv'
    if dur == 'RTicks':
        stem = '.RTticks.csv'
    barfile =  DataDown + date + '.' + sym + stem
    bars = rpu_rp.CsvToLines(barfile)
    newbars =[]
    for bar in bars:
        if len(bar) > 2:
##            print bar,'is bar'
            curbartime = TicksUtile.time_to_epoch(bar[1])
            if curbartime > startbartime and curbartime < endbartime:
                newbars.append(bar)
##    for b in newbars:
##        print b
    return newbars
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:24,代码来源:RP_Snapshotpre.py

示例10: ShowIndBar

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def ShowIndBar(sym,dur,ind,mode,barnum,bartime):
    barfnumlimit = 500
    lastbar =[]
    statefile = statearea + sym + '.' +  dur + '.' + ind  + '.state.csv'
    arrayin = rpu_rp.CsvToLines(statefile)
    barcount = len(arrayin)
    lastbar = (rpu_rp.tail_array_to_array(arrayin,1))[0]
    nbar = (rpu_rp.tail_array_to_array(arrayin,barnum))[0]
    lastfewbars = (rpu_rp.tail_array_to_array(arrayin,barfnumlimit))
    for bar in lastfewbars:
        if TicksUtile.time_to_epoch(bar[0]) <= TicksUtile.time_to_epoch(bartime) :
            timedbar = bar
    if mode == 'barcount':
        output = barcount
    elif mode == 'LastBar':
        output = lastbar
    elif mode == 'nbar':
        output = nbar
    elif mode == 'bytime':
        output = timedbar
    elif mode == 'barcount':
        output = barcount
    return output
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:25,代码来源:rpInd+-+Copy+(1).py

示例11: run_oneloop

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def run_oneloop(dur,now,sym):
    now_epoch = int(time.mktime(time.strptime(now, spaceYtime_format)))
    print '##### ',now, dur, sym,' ####### '

    Createlines.create_HAs([sym])
    filen = DataDown +date +'.'+sym+'.'+dur + '.both.HA.csv'
    perc = .80
    maxlines = 4
    difflimit = 400
    taglist = ['buy','sell']
    for tag in taglist:    
        b = showlines(filen,tag)
        print '#############'
        print '>>>>>> ',tag.upper(), ' <<<'
        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:
            if len(lha.split('|')) > 2:
                bar_time = (lha.split('|')[3]).replace(' 201','201')
            c+=1
            bar_time_epoch =  TicksUtile.time_to_epoch(bar_time)
            
            tdiff =  now_epoch - bar_time_epoch
            if c > climit and tdiff < difflimit :
                print lha,'>>> ',tdiff #,difflimit
            #######
    taglist = ['allxx']
    for tag in taglist:    
        b = showlines(filen,tag)
        print '    '
        print '>>>>>> ',tag,sym,dur,now
        lenha = len(b)
        c=0
        climitlines = int(lenha * perc)
        climit = max((lenha-maxlines+2),climitlines)
        bar_time = '  2016-02-21 13:16:30'
        for lha in b:
##            if len(lha.split('|')) > 2:
##                bar_time = (lha.split('|')[3]).replace(' 201','201')
            c+=1
##            bar_time_epoch =  TicksUtile.time_to_epoch(bar_time)
            difflimit = 1800000000
            tdiff = bar_time_epoch - now_epoch + difflimit
            if c > climit and tdiff > 0 :
                print lha    
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:50,代码来源:hatester+hard.py

示例12: get_dload_barsWbu

# 需要导入模块: import TicksUtile [as 别名]
# 或者: from TicksUtile import time_to_epoch [as 别名]
def get_dload_barsWbu(start_path,dur,barfileout,sym):
    total_size = 0
    alllines =[]
    alltimes =[]
    fileoutname = barfileout
    for dirpath, dirnames, filenames in os.walk(start_path):
##        print dirpath
        subdirsize = 0
        for f in filenames:
##            if 'ES.'+dur+'.ddload' in f :
            if '.'+sym+'.'+dur+'.ddload' in f  :
                print f
                fp = os.path.join(dirpath, f)
                total_size += os.path.getsize(fp)
                print  fp,'working'
                lines = rpu_rp.CsvToLines(fp)
                for l in lines:
##                    print l
                    newl =[]
                    if len(l) > 2:
                        timestring = l[1]
                        e = TicksUtile.time_to_epoch(timestring)
##                        fsourcedate = f.replace('.ES.'+dur+'.ddload.csv','')
                        fsourcedate = f.split('.')[0]
                        fsourcesym = f.split('.')[1]
                        fsourcedur = f.split('.')[2]
                        l.append(fsourcedate)
                        l.append(fsourcesym)
                        l.append(fsourcedur)
                        newl.append(l[8])
                        newl.append(l[9])

                        newl.append(l[1])
                        newl.append(l[7])

                        newl.append(l[2])
                        newl.append(l[3])
                        newl.append(l[4])
                        newl.append(l[5])
                        newl.append(l[6])
                        alllines.append(newl)
    from operator import itemgetter, attrgetter, methodcaller
    sortedall = sorted(alllines,key=itemgetter(0,1,2,3),reverse=True)
    usort = rpu_rp.uniqnosort(sortedall)
    prevdur = time = ''
    cleans =[]
    for y in usort:
##        print y
        dur = y[2]
        time = y[3]
        if dur == prevdur and time == prevtime:
##            print y
##            print prevy,'prev'
            pass
        else:
            cleans.append(y)
        prevdur = dur
        prevtime = time
        prevy = y
    rpu_rp.WriteArrayToCsvfile(fileoutname+'news', cleans)
    newalls=[]
    for n in cleans:
##        print n
        newn =[]
        sym = n[0]
        dur = n[1]
        time = n[2]
        openp = n[4]
        hip = n[5]
        lowp = n[6]
        closep = n[7]
        volu = n[8]
        newn.append(sym)
        newn.append(time)
        newn.append(openp)
        newn.append(hip)
        newn.append(lowp)
        newn.append(closep)
        newn.append(volu)
        newalls.append(newn)
    rpu_rp.WriteArrayToCsvfile(fileoutname, newalls)
开发者ID:reprior123,项目名称:TraderSoftwareRP,代码行数:83,代码来源:CreateIndDbase.py


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