Interactive Brokers "Broker" function issue
I am trying to connect to IB TWS and retrieve positions and balances.
However, the IB script just returns "0.0" for both Value and Cash, which is incorrect. My script:
import backtrader as bt cerebro = bt.Cerebro() ibstore = bt.stores.IBStore(port=7496, clientId=123,timeout=180,reconnect=3) cerebro.broker = ibstore.getbroker() # or cerebro.setbroker(...) print(cerebro.broker.getvalue()) print(cerebro.broker.getcash())
What am I missing? How can I fix this to display the correct values and cash positions, instead of "0.0"?
cerebrois not running, which means there is no communication with the broker. Anything other than
0.0would be a surprise.