Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    No such file or directory: orcl....txt

    General Code/Help
    3
    4
    41
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      AeroAndy1 last edited by

      I tried running the first example that fetches a data feed, and got this:

      % ./bt1.py
      Starting Portfolio Value: 5000.00
      Traceback (most recent call last):
      File "/Users/andy/Documents/bt/./bt1.py", line 39, in <module>
      cerebro.run()
      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
      data._start()
      File "/usr/local/lib/python3.9/site-packages/backtrader/feed.py", line 203, in _start
      self.start()
      File "/usr/local/lib/python3.9/site-packages/backtrader/feeds/yahoo.py", line 94, in start
      super(YahooFinanceCSVData, self).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?

      B 1 Reply Last reply Reply Quote 0
      • B
        BorutF @AeroAndy1 last edited by

        @aeroandy1

        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'))
        

        this works.

        1 Reply Last reply Reply Quote 0
        • A
          AeroAndy1 last edited by

          Thank you!

          1 Reply Last reply Reply Quote 0
          • Nael Shichida
            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"

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors