For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Error running example code from "Quickstart"
-
Hi,
I'm trying to run the example code from the Quickstart section of the website. (I've made slight modifications to hardcode the data file location with absolute the path).
Below is my code:
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() datapath = os.path.abspath('/Users/98thpixel/backtrader/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())```
I get an error when trying to read the "orcl-1995-2014.txt" file.
Below is the error I'm getting:
Starting Portfolio Value: 100000.00 Traceback (most recent call last): File "program.py", line 36, in <module> cerebro.run() File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/cerebro.py", line 1212, in runstrategies data.preload() File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/feed.py", line 688, in preload while self.load(): File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/feed.py", line 479, in load _loadret = self._load() File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/feed.py", line 710, in _load return self._loadline(linetokens) File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/feeds/yahoo.py", line 174, in _loadline self.lines.adjclose[0] = adjustedclose AttributeError: 'Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst' object has no attribute 'adjclose'
-
It is a byproduct of having cleaned up the Yahoo feed. Will be corrected today.
-