Hello, as the title suggests, I am following along an online tutorial from PartTimeLarry https://www.youtube.com/watch?v=ouveMWaInn8
where he is backtesting an opening range breakout strategy.
My main interest is utilizing the sqlite3 database to load data for backtesting. The tutorial uses the pandas read_sql function to build the dataframe and insert into BT with PandasData bt datafeeds.
The dataframe appears correct, however I receive this error when I run:
(venv) griz@gemini-/backtrade/fullBT.py
== Testing 1 ==
open high low close volume
datetime
2016-02-05 09:30:00 153.2 153.67 153.0 153.66 607.0
2016-02-05 09:31:00 153.66 153.78 153.28 153.28 85.0
2016-02-05 09:32:00 153.23 153.24 153.0 153.04 43.0
2016-02-05 09:33:00 153.16 153.23 152.9 152.9 35.0
2016-02-05 09:34:00 152.9 152.94 152.76 152.82 54.0
... ... ... ... ... ...
2017-01-04 14:39:00 177.99 178.0 177.99 178.0 5.0
2017-01-04 14:40:00 178.01 178.01 177.96 177.96 23.0
2017-01-04 14:41:00 177.95 177.95 177.9 177.9 17.0
2017-01-04 14:42:00 177.9 177.9 177.83 177.86 17.0
2017-01-04 14:43:00 177.87 177.94 177.87 177.87 15.0
[90000 rows x 5 columns]
Traceback (most recent call last):
File "/home/griz/backtrade/fullBT.py", line 124, in <module>
cerebro.run()
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/cerebro.py", line 1212, in runstrategies
data.preload()
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/feed.py", line 438, in preload
while self.load():
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/feed.py", line 479, in load
_loadret = self._load()
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/feeds/pandafeed.py", line 255, in _load
line[0] = self.p.dataname.iloc[self._idx, colindex]
File "/home/griz/backtrade/venv/lib/python3.8/site-packages/backtrader/linebuffer.py", line 222, in setitem
self.array[self.idx + ago] = value
TypeError: must be real number, not str
Here is my code for reference. I have searched through other examples in the discussions. I wasn't able to find anything that works. Any help would be much appreciated, thanks for all you guys do.
