Exemplo n.º 1
0
def run_fullfile_loop(barsize,duration,ibsecType,ibexchange,cashcurr):
    symbol_id = 1
    for i in symbol_list:
        global mode
        mode = 'fullfile'
        ### if fullmode, remember to delete the tick mode single files before tickmode restart
        mode = 'single'
##        global symbol_list
##        symbol_list = ['EUR', 'GBP', 'AUD', 'ES', 'USD']
        ##symbol_list = ['ES']
        ibsecType = 'CASH'  
        ibexchange = 'IDEALPRO'
        cashcurr = 'USD'
        expiry = '20150619'
        global today
        today =  rpu_rp.todaysdateunix()
                ##########################
        barlist = ['5 secs']#'5 mins', '15 mins', '1 hour', '1 day']
        barlist = ['15 mins', '1 hour', '1 day']
        ##barlist = ['5 mins']
        for bar in barlist:
            print i
            if i == 'EUR':
                ibsecType = 'CASH'  
                ibexchange = 'IDEALPRO'
                cashcurr = 'USD'
            elif i == 'ES':
                ibsecType = 'FUT'  
                ibexchange = 'GLOBEX'
                cashcurr = 'USD'
                expiry = '20150619'
            elif i == 'USD':
                ibsecType = 'CASH'  
                ibexchange = 'IDEALPRO'
                cashcurr = 'CHF'
            else:
                ibsecType = 'CASH'  
                ibexchange = 'IDEALPRO'
                cashcurr = 'USD'
            if bar == '5 mins' or bar == '15 mins':
                duration = '2 D'
                pass
            elif bar == '1 hour':
                duration = '7 D'
                pass
            elif bar == '5 secs':
                duration = '7200 S'
            else:
                duration = '3 M'
            newqqq = build_qqq_msg(symbol_id,i,ibsecType,ibexchange,cashcurr)
            global filename
            filename = 'ibdata.' + barsize.replace(' ','') + '.' + duration.replace(' ','') + '.' + today +'.'+ i + '.csv'
            con.reqHistoricalData(symbol_id, newqqq, '', duration, barsize, 'BID_ASK', 0, 2)  
            symbol_id = symbol_id + 1  
            sleep(20)

            run_fullfile_loop(bar,duration,ibsecType,ibexchange,cashcurr)
Exemplo n.º 2
0
def GetBars(arrayin,sym,Indtitle,dur,threshold):  #add barr age from last cross here
    bscloses = strip1float(arrayin,5,sym) ##raw close price
    date =  rpu_rp.todaysdateunix()  ##
    bsopens = strip1float(arrayin,2,sym) ##raw open price
    bshighs = strip1float(arrayin,3,sym)
    bslows = strip1float(arrayin,4,sym)
    timestamparray = strip1string(arrayin,1)
    arraybars = make_bars(timestamparray,bsopens,bshighs,bslows,bscloses)
    return arraybars
Exemplo n.º 3
0
def GetBars(arrayin, sym, Indtitle, dur,
            threshold):  #add barr age from last cross here
    bscloses = strip1float(arrayin, 5, sym)  ##raw close price
    date = rpu_rp.todaysdateunix()  ##
    bsopens = strip1float(arrayin, 2, sym)  ##raw open price
    bshighs = strip1float(arrayin, 3, sym)
    bslows = strip1float(arrayin, 4, sym)
    timestamparray = strip1string(arrayin, 1)
    arraybars = make_bars(timestamparray, bsopens, bshighs, bslows, bscloses)
    return arraybars
Exemplo n.º 4
0
entrywiderdict = rpu_rp.create_dict(libsyms,0,10)
libsymlines = EXE + 'library.symlines.csv'
symlinedict = rpu_rp.create_dict(libsymlines,0,1)
symbol_list = symdict.keys()
##symbol_list = ['AUD.USD']
barlistall = bardict.keys()  ##
barlist =[]
for b in barlistall:
    if modedict[b] == 'intraday':
        barlist.append(b)
barlist = ['1 hour']
print barlist
##################
prevsigid = ''
mode = 'livescan'
today =  rpu_rp.todaysdateunix()
##today ='20150618'
current_time = datetime.now().time()
print current_time.isoformat()
##########################################
def read_vars(): ##read variables from the control panel file
    cpfile = TMP + 'signalcontroller.txt'
    paramlines = rpu_rp.CsvToLines(cpfile)
    varstrings = ['TimeLimitRecentSigs','SignalsToShow','DurationToShow']
    var = {}
    for varstring in varstrings:
        for line in paramlines:
            if len(line) > 0:
                if line[0] == varstring:
                    var[varstring] = line[1]
##    return int(var['TimeLimitRecentSigs'])
moduleNames = open('importmodlist.txt').readlines()
print moduleNames
for module in moduleNames:
    if module != titleself:
        my_module = importlib.import_module(module.strip())
######################
from ib.ext.Contract import Contract  
from ib.opt import ibConnection, message
from ib.ext.Order import Order
from ib.opt import Connection, message   ##??
#############################
########################################
date = today
symbol_list = symlistTicker
now = datetime.strftime(datetime.now(),spaceYtime_format)
today =  rpu_rp.todaysdateunix()
todaysigs = sigarea + today+ '.recentsigs.csv'
todaypos = sigarea + today +'.positionstate.csv'
currentpos = rpu_rp.CsvToLines(todaypos)
addon = rpu_rp.CsvToLines(todaysigs)
rpu_rp.WriteArrayToCsvfileAppend(todaypos,addon)

os.system('cat ' + todaysigs + ' >> ' + todaysigs + 'bu')
filelist = glob.glob(sigarea + '*recent*')
for f in filelist:
    print f
    if os.path.isfile(f):
        os.remove(f)
filelist = glob.glob(TMP + '*')
for f in filelist:
    print f
Exemplo n.º 6
0
def run_fullfile_loop(barsize, duration, ibsecType, ibexchange, cashcurr):
    symbol_id = 1
    for i in symbol_list:
        global mode
        mode = 'fullfile'
        ### if fullmode, remember to delete the tick mode single files before tickmode restart
        mode = 'single'
        ##        global symbol_list
        ##        symbol_list = ['EUR', 'GBP', 'AUD', 'ES', 'USD']
        ##symbol_list = ['ES']
        ibsecType = 'CASH'
        ibexchange = 'IDEALPRO'
        cashcurr = 'USD'
        expiry = '20150619'
        global today
        today = rpu_rp.todaysdateunix()
        ##########################
        barlist = ['5 secs']  #'5 mins', '15 mins', '1 hour', '1 day']
        barlist = ['15 mins', '1 hour', '1 day']
        ##barlist = ['5 mins']
        for bar in barlist:
            print i
            if i == 'EUR':
                ibsecType = 'CASH'
                ibexchange = 'IDEALPRO'
                cashcurr = 'USD'
            elif i == 'ES':
                ibsecType = 'FUT'
                ibexchange = 'GLOBEX'
                cashcurr = 'USD'
                expiry = '20150619'
            elif i == 'USD':
                ibsecType = 'CASH'
                ibexchange = 'IDEALPRO'
                cashcurr = 'CHF'
            else:
                ibsecType = 'CASH'
                ibexchange = 'IDEALPRO'
                cashcurr = 'USD'
            if bar == '5 mins' or bar == '15 mins':
                duration = '2 D'
                pass
            elif bar == '1 hour':
                duration = '7 D'
                pass
            elif bar == '5 secs':
                duration = '7200 S'
            else:
                duration = '3 M'
            newqqq = build_qqq_msg(symbol_id, i, ibsecType, ibexchange,
                                   cashcurr)
            global filename
            filename = 'ibdata.' + barsize.replace(
                ' ', '') + '.' + duration.replace(
                    ' ', '') + '.' + today + '.' + i + '.csv'
            con.reqHistoricalData(symbol_id, newqqq, '', duration, barsize,
                                  'BID_ASK', 0, 2)
            symbol_id = symbol_id + 1
            sleep(20)

            run_fullfile_loop(bar, duration, ibsecType, ibexchange, cashcurr)
Exemplo n.º 7
0
path = os.getcwd() + '/'
rootpath = ((path.replace('EXE','|')).split('|'))[0]
localtagSLASH = '_RP/'
localtag = '_RP'
EXEnoslash = rootpath + 'EXE' + localtag
sys.path[0:0] = [EXEnoslash]
#####################
import  rpu_rp, rpInd
################################
EXE = EXEnoslash + '/'
DATA = rootpath + 'DATA' + localtagSLASH
TMP = rootpath + 'TMP' + localtagSLASH
DataDown = 'C:/TS/TSIBData/'
DataDownNoSlash = 'C:/TS/TSIBData'
#######################################
today =  rpu_rp.todaysdateunix()  ##today ='20150605'
##############################################
##        from datetime import timedelta
##        date_format = "%d-%m-%Y"
from datetime import datetime
current_time = datetime.now().time()
print current_time.isoformat()
##############################
libbars = EXE + 'library.bars.csv'
libsyms = EXE + 'library.syms.csv'
bardict = rpu_rp.create_dict(libbars,0,1)
secdict = rpu_rp.create_dict(libbars,0,4)
barlist = bardict.keys()  ##
barlist = ['15 mins', '15 secs', '1 min', '1 hour', '5 mins']
##########################
rpsymdict = rpu_rp.create_dict(libsyms,0,1)