For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

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,
    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(
        # 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),
    # Add the Data Feed to Cerebro
    # Set our desired cash start
    # Print out the starting conditions
    print('Starting Portfolio Value: %.2f' %
    # Run over everything
    # Print out the final result
    print('Final Portfolio Value: %.2f' %```

    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 "", line 36, in <module>
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/", line 1127, in run
    runstrat = self.runstrategies(iterstrat)
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/", line 1212, in runstrategies
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/", line 688, in preload
    while self.load():
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/", line 479, in load
    _loadret = self._load()
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/", line 710, in _load
    return self._loadline(linetokens)
      File "/Users/98thpixel/anaconda3/lib/python3.7/site-packages/backtrader/feeds/", line 174, in _loadline
    self.lines.adjclose[0] = adjustedclose
    AttributeError: 'Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst' object has no attribute 'adjclose'

  • administrators

    It is a byproduct of having cleaned up the Yahoo feed. Will be corrected today.

  • administrators

Log in to reply