Hello
I connect to an existing paper account as following:
ibstore = bt.stores.IBStore(host='127.0.0.1', port=4002, clientId=cid)
data = ibstore.getdata(dataname="aapl", historical=True, fromdate=datetime(2019, 1, 1), todate=datetime(2019, 8, 1),
timeframe=bt.TimeFrame.Minutes, compression=5)
cerebro.adddata(data)
I get the following error:
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'openOrder' for 'openOrder'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1291, in openOrder
self.broker.push_orderstate(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstate'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'orderStatus' for 'orderStatus'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1301, in orderStatus
self.broker.push_orderstatus(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstatus'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'openOrder' for 'openOrder'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1291, in openOrder
self.broker.push_orderstate(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstate'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'orderStatus' for 'orderStatus'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1301, in orderStatus
self.broker.push_orderstatus(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstatus'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'openOrder' for 'openOrder'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1291, in openOrder
self.broker.push_orderstate(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstate'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'orderStatus' for 'orderStatus'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1301, in orderStatus
self.broker.push_orderstatus(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstatus'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'openOrder' for 'openOrder'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1291, in openOrder
self.broker.push_orderstate(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstate'
14-Aug-19 12:24:24 ERROR Exception in message dispatch. Handler 'orderStatus' for 'orderStatus'
Traceback (most recent call last):
File "C:\Python37-64\lib\site-packages\ib\opt\dispatcher.py", line 44, in __call__
results.append(listener(message))
File "C:\Users\ksander\correlation\backtrader\stores\ibstore.py", line 1301, in orderStatus
self.broker.push_orderstatus(msg)
AttributeError: 'NoneType' object has no attribute 'push_orderstatus'
It seems to be that the server starts pushing order status etc to the client and the BackBroker does not know what to do with them. Quite logical. When I add an IBBroker as following:
ibstore = bt.stores.IBStore(host='127.0.0.1', port=4002, clientId=cid)
cerebro.broker = ibstore.getbroker()
data = ibstore.getdata(dataname="aapl", historical=True, fromdate=datetime(2019, 1, 1), todate=datetime(2019, 8, 1),
timeframe=bt.TimeFrame.Minutes, compression=5)
cerebro.adddata(data)
that error is gone but I will soon get another one:
Traceback (most recent call last):
File "C:/Users/ksander/correlation/bt_katse.py", line 66, in <module>
cerebro.broker.setcash(100000.0)
AttributeError: 'IBBroker' object has no attribute 'setcash'
Also logical - the live broker cannot let you set your cash indeed :)
The question is, what is the proper way to download the historical data from the IB if I cannot use an existing paper account with standing orders etc because of that issue?
Does the BackBroker need some exception handling?
Thanks in advance.