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/

    Error in cerebro.run() when getting data with YahooFinanceData (new API)

    General Code/Help
    3
    4
    1765
    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.
    • Paul van der Stap
      Paul van der Stap last edited by Paul van der Stap

      I just tested the new YahooFinanceData function because the API has changed.
      getting the data works well, but I got an error in the main cerebro.run():

       Error Info: <type 'exceptions.ValueError'>: could not convert string to float: null
      

      but this only occurs when there are records with null values in the dataframe.
      tickersymbol = "EUNA.AS":

                   Open       High        Low      Close  Adj Close Volume
      

      Date
      2017-03-20 31.955000 32.099998 31.955000 32.009998 32.009998 4513
      2017-03-21 32.029999 32.130001 31.885000 31.895000 31.895000 6297
      2017-03-22 31.715000 31.820000 31.665001 31.790001 31.790001 400
      2017-03-23 31.709999 32.049999 31.709999 32.029999 32.029999 2193
      2017-03-24 null null null null null null
      2017-03-27 31.709999 31.844999 31.709999 31.844999 31.844999 3733
      2017-03-28 31.905001 32.029999 31.885000 32.025002 32.025002 2585
      2017-03-29 32.080002 32.169998 32.035000 32.165001 32.165001 442

      without null values in the datafram everything works well!
      digging deeper, without null values al dtypes are float64.
      with records with null values, dtypes are 'object', not float64.

      Is there a fix to filter these null values?

      code example:

      cerebro = bt.Cerebro()
      tickersymbol = "EUNA.AS"
      start = datetime.datetime(2017, 3, 23)
      end = datetime.date.today()
      dataYahoo = bt.feeds.YahooFinanceData(dataname=tickersymbol, fromdate=start, todate=end, retries=5)
      cerebro.adddata(dataYahoo)
      cerebro.run()
      cerebro.plot()

      B 1 Reply Last reply Reply Quote 0
      • C
        cgi1 last edited by cgi1

        Got the same problem

        1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators @Paul van der Stap last edited by

          @Paul-van-der-Stap said in Error in cerebro.run() when getting data with YahooFinanceData (new API):

          2017-03-24 null null null null null null

          Will have to be overcome. New formats, new times, new surprises. Why would anyone literally write null and push the prices out is a good question for Unsolved Mysteries

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            See the news release, Community - Release 1.9.50.117 and this note Community - YahooFinace Data Feeds

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }