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)
Пример #2
0
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)
def create_con_dict():
    symcontrdict = {}
    counter = 0
    symbol_list = symbol_listall
    print symbol_list
    for sym in symbol_list:
        counter +=1
        strike = '2'
        expiry ='20154'
        symcontract =  ibutiles.create_contract(sym,strike,expiry)
        print sym, counter
        sleep (1)
        dict2 = {sym : symcontract}
        symcontrdict.update(dict2)
        print 'adding to dict', sym
    print 'done with dict'
    return symcontrdict
def create_con_dict():
    symcontrdict = {}
    counter = 0
    symbol_list = symbol_listall
    print symbol_list
    for sym in symbol_list:
        counter += 1
        strike = '2'
        expiry = '20154'
        symcontract = ibutiles.create_contract(sym, strike, expiry)
        print sym, counter
        sleep(1)
        dict2 = {sym: symcontract}
        symcontrdict.update(dict2)
        print 'adding to dict', sym
    print 'done with dict'
    return symcontrdict
Пример #5
0
##libsyms = EXE + 'library.syms.csv'
##symdict = rpu_rp.create_dict(libsyms,0,1)
symbol_list = symdict.keys()
######################
print 'starting entry sender...'
##print
symcontrdict = {}
counter = 0
agelimit = 1200
symbol_list = ['ES']
print symbol_list
for sym in symbol_list:
    counter += 1
    strike = '2'
    expiry = '20154'
    symcontract = ibutiles.create_contract(sym, strike, expiry)
    print sym, counter
    sleep(1)
    dict2 = {sym: symcontract}
    symcontrdict.update(dict2)
    print 'adding to dict', sym
    #################
print 'done with dict'
while loop < loopmax:
    if testmode == 'online':
        order_id = get_orderid()
    else:
        order_id = '888'
        #################3
    for lastsig in ['1']:
        print lastsig
Пример #6
0
##libsyms = EXE + 'library.syms.csv'
##symdict = rpu_rp.create_dict(libsyms,0,1)
symbol_list = symdict.keys()
######################
print 'starting entry sender...'
##print
symcontrdict = {}
counter = 0
agelimit = 1200
symbol_list = ['ES']
print symbol_list
for sym in symbol_list:
    counter +=1
    strike = '2'
    expiry ='20154'
    symcontract =  ibutiles.create_contract(sym,strike,expiry)
    print sym, counter
    sleep (1)
    dict2 = {sym : symcontract}
    symcontrdict.update(dict2)
    print 'adding to dict', sym
    #################
print 'done with dict'
while loop < loopmax:   
    if testmode == 'online':                    
        order_id = get_orderid()
    else:
        order_id = '888'
        #################3
    for  lastsig in ['1']:
        print lastsig
        dataStr = '%s, %s, %s, %s, %s, %s, %s' % (sym, tdate, msg.open, msg.high, msg.low, msg.close, msg.volume)  
        newDataList = newDataList + [dataStr]  
    else:
        print 'next list'
        rpu_rp.WriteStringsToFile(fname,'') #flush the file
        for a in newDataList:
            if len(a) > 2:
                rpu_rp.WriteStringsToFileAppend(fname,a)
        newDataList = []  
####################################       
tws_conn = Connection.create(port=7496, clientId=109)
tws_conn.connect()
tws_conn.register(error_handler, 'Error')
tws_conn.registerAll(reply_handler)
tws_conn.register(historical_data_handler, message.historicalData)
#######################################
for sym in symbol_list:
    for bar in barlist:
        fname = DataDown+ today + '.' + sym + '.'  + bar.replace(' ','')+'.ddload.csv'
        os.system('cat ' + fname + ' >> ' + fname + 'bu')
        duration = bardict[bar]
        print bar, sym
        contract = ibutiles.create_contract(sym,'','')
        ticktype = ticktypedict[sym]
        tws_conn.reqHistoricalData(trans_id, contract, '', duration, bar, ticktype, 0, 2)
        trans_id = trans_id + 1  
        sleep(4)
###############
print 'disconnecting from ib..'
tws_conn.disconnect()
        rpu_rp.WriteStringsToFile(fname, '')  #flush the file
        for a in newDataList:
            if len(a) > 2:
                rpu_rp.WriteStringsToFileAppend(fname, a)
        newDataList = []


####################################
tws_conn = Connection.create(port=7496, clientId=109)
tws_conn.connect()
tws_conn.register(error_handler, 'Error')
tws_conn.registerAll(reply_handler)
tws_conn.register(historical_data_handler, message.historicalData)
#######################################
for sym in symbol_list:
    for bar in barlist:
        fname = DataDown + today + '.' + sym + '.' + bar.replace(
            ' ', '') + '.ddload.csv'
        os.system('cat ' + fname + ' >> ' + fname + 'bu')
        duration = bardict[bar]
        print bar, sym
        contract = ibutiles.create_contract(sym, '', '')
        ticktype = ticktypedict[sym]
        tws_conn.reqHistoricalData(trans_id, contract, '', duration, bar,
                                   ticktype, 0, 2)
        trans_id = trans_id + 1
        sleep(4)
###############
print 'disconnecting from ib..'
tws_conn.disconnect()