Stuart Cracraft
So how would this code be modified to make it more likely to retrieve data rather than get a data frame error?
toggle quoted message
Show quoted text
def read_navs(): #read all accounts NAVs from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.common import TickerId from threading import Thread import pandas as pd import time class ib_class(EWrapper, EClient): def __init__(self, addr, port, client_id): EClient.__init__(self, self) self.connect(addr, port, client_id) # Connect to TWS thread = Thread(target=self.run) # Launch the client thread thread.start() self.all_accounts = pd.DataFrame([], columns = ['reqId','Account', 'Tag', 'Value' , 'Currency']) def error(self, reqId:TickerId, errorCode:int, errorString:str): if reqId > -1: print("Error. Id: " , reqId, " Code: " , errorCode , " Msg: " , errorString) def accountSummary(self, reqId, account, tag, value, currency): index = str(account) self.all_accounts.loc[index]=reqId, account, tag, value, currency ib_api = ib_class("127.0.0.1", 7497, 10) ib_api.reqAccountSummary(0,"All","NetLiquidation") # associated callback: accountSummary print("Waiting for IB's API response for Net Asset Value Liquidation requests...\n") time.sleep(3.0) current_nav = ib_api.all_accounts ib_api.disconnect() return(current_nav) On Jun 13, 2021, at 9:05 AM, Rational-IM <ds@...> wrote: |