Although my folder is in the correct path, the function can't find it.
I am relatively new to programming, maybe some obvious mistakes?
import backtrader as bt
cerebro = bt.Cerebro()
data = bt.feeds.GenericCSVData(dataname=r'D:\Programme\Visual Studio Code\Projekte\D_Candles.csv', dtformat=2)
cerebro.adddata(data)
cerebro.run()
cerebro.plot()
All dependencies and packages were installed.
Error Message:
PS D:\Programme\Visual Studio Code\Projekte> & C:/Users/William/AppData/Local/Microsoft/WindowsApps/python3.10.exe "d:/Programme/Visual Studio Code/Projekte/Trading/backtest.py"
Traceback (most recent call last):
File "d:\Programme\Visual Studio Code\Projekte\Trading\backtest.py", line 9, in <module>
cerebro.run()
File "C:\Users\William\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\backtrader\cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "C:\Users\William\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\backtrader\cerebro.py", line 1210, in runstrategies
data._start()
File "C:\Users\William\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\backtrader\feed.py", line 203, in _start
self.start()
File "C:\Users\William\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\backtrader\feeds\csvgeneric.py", line 88, in start
super(GenericCSVData, self).start()
File "C:\Users\William\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\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: 'D:\\Programme\\Visual Studio Code\\Projekte\\D_Candles.csv'
PS D:\Programme\Visual Studio Code\Projekte>
What I tried so far:
- just tiping the folder name, not the whole path
- switching the backslashes, tried //, \, /, \ and with & without r
- copied the folder in an other path
- it is not because of spaces between words
I really appreciate your help. Even if you just know an alternative function I could try...