Quickstart Guide Error
-
I keep on getting strange error messages after the 3rd quickstart guide, each one differing but the first one is listed below, any idea to fix?
Starting Portfolio Value: 100000.00
Traceback (most recent call last):
File "c:\Users\ryanz\OneDrive\Desktop\Python Code\AlgoTrading\2nd Program.py", line 61, in <module>
cerebro.run()
File "C:\Users\ryanz\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\cerebro.py", line 1127, in run
runstrat = self.runstrategies(iterstrat)
File "C:\Users\ryanz\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\cerebro.py", line 1210, in runstrategies
data._start()
File "C:\Users\ryanz\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\feed.py", line 203, in _start
self.start()
File "C:\Users\ryanz\AppData\Local\Programs\Python\Python310\lib\site-packages\backtrader\feeds\yahoo.py", line 94, in start
super(YahooFinanceCSVData, self).start()
File "C:\Users\ryanz\AppData\Local\Programs\Python\Python310\lib\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: 'c:\Users\ryanz\OneDrive\Desktop\Python Code\AlgoTrading\../../datas/orcl-1995-2014.txt'from future import (absolute_import, division, print_function,
unicode_literals)import datetime # For datetime objects
import os.path # To manage paths
import sys # To find out the script name (in argv[0])Import the backtrader platform
import backtrader as bt
if name == 'main':
# Create a cerebro entity
cerebro = bt.Cerebro()# Datas are in a subfolder of the samples. Need to find where the script is # because it could have been called from anywhere modpath = os.path.dirname(os.path.abspath(sys.argv[0])) datapath = os.path.join(modpath, '../../datas/orcl-1995-2014.txt') # Create a Data Feed data = bt.feeds.YahooFinanceCSVData( dataname=datapath, # Do not pass values before this date fromdate=datetime.datetime(2000, 1, 1), # Do not pass values after this date todate=datetime.datetime(2000, 12, 31), reverse=False) # Add the Data Feed to Cerebro cerebro.adddata(data) # Set our desired cash start cerebro.broker.setcash(100000.0) # Print out the starting conditions print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue()) # Run over everything cerebro.run() # Print out the final result print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())