No such file or directory: orcl....txt
I tried running the first example that fetches a data feed, and got this:
Starting Portfolio Value: 5000.00
Traceback (most recent call last):
File "/Users/andy/Documents/bt/./bt1.py", line 39, in <module>
File "/usr/local/lib/python3.9/site-packages/backtrader/cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "/usr/local/lib/python3.9/site-packages/backtrader/cerebro.py", line 1210, in runstrategies
File "/usr/local/lib/python3.9/site-packages/backtrader/feed.py", line 203, in _start
File "/usr/local/lib/python3.9/site-packages/backtrader/feeds/yahoo.py", line 94, in start
File "/usr/local/lib/python3.9/site-packages/backtrader/feed.py", line 674, in start
self.f = io.open(self.p.dataname, 'r')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/xxxx/Documents/bt/datas/orcl-1995-2014.txt'
Any thoughts? Should I have downloaded the orcl file first?
I have seen this before. I don't know how to make it work.
On the other hand I know
data = bt.feeds.PandasData(dataname=yf.download('ORCL', '2011-01-01', '2021-12-01'))
Nael Shichida last edited by
You can also add 'r' before feeding the path, if you are using a string as input. It basically converts it into Raw string.
datapath = r"C:\Users\XXX\PycharmProjects\BackTesting\venv\datas\orcl-1995-2014.txt"