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



  • 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()




  • administrators

    @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


  • administrators


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.