So I am trying download the historical data from IB.
So I try run getdata on the store like this:
stockkwargs = dict(
timeframe = bt.TimeFrame.Days,
rtbar = False, # use RealTime 5 seconds bars
historical = True, # only historical download
what = 'TRADES', # historical - what to show TRADES MIDPOINT BID ASK BID_ASK HISTORICAL_VOLATILITY OPTION_IMPLIED_VOLATILITY
useRTH = False, # historical - download only Regular Trading Hours
qcheck = 0.5, # timeout in seconds (float) to check for events
backfill_start = True, # do backfilling at the start
backfill = True, # do backfilling when reconnecting
backfill_from = datetime.datetime(2017,1,2,tzinfo=timezone('US/Eastern')), # additional data source to do backfill from
latethrough = False, # let late samples through
tradename = None # use a different asset as order target
)
data0 = ibstore.getdata(dataname="AAPL-STK-SMART-USD", **stockkwargs)
cerebro.adddata(data0)
But I get an error:
Server Version: 76
TWS Time at connection:20170503 10:13:24 AEST
Traceback (most recent call last):
File "tutorial3.py", line 129, in <module>
runstrat()
File "tutorial3.py", line 122, in runstrat
cerebro.run()
File "/home/ric/miniconda3/envs/bt34/lib/python3.5/site-packages/backtrader/cerebro.py", line 1070, in run
runstrat = self.runstrategies(iterstrat)
File "/home/ric/miniconda3/envs/bt34/lib/python3.5/site-packages/backtrader/cerebro.py", line 1144, in runstrategies
data._start()
File "/home/ric/miniconda3/envs/bt34/lib/python3.5/site-packages/backtrader/feed.py", line 203, in _start
self.start()
File "/home/ric/miniconda3/envs/bt34/lib/python3.5/site-packages/backtrader/feeds/ibdata.py", line 361, in start
self.p.backfill_from._start()
AttributeError: 'datetime.datetime' object has no attribute '_start'
Now as far as I can see backfill_from should be a datetime object.
Now looking at git blame I can see that line 361 of ibdata.py was added a few months ago.
Ensure initialization of backfill_from feeds takes place
Now if I simply remove that section of ibdata.py and set
self._state = self._ST_START
The historical download works and it disconnects and then plots beautifully.
So my question? Bug in ibdata.py or I am doing it wrong?
Thanks,
Ric