The Motley Fool Discussion Boards

Previous Page

Investing/Strategies / Mechanical Investing

URL:  https://boards.fool.com/it-appears-that-my-google-sheets-suggestion-in-34174580.aspx

Subject:  Re: Investopedia Historical Data Date:  4/5/2019  5:41 PM
Author:  StevnFool Number:  273826 of 278423

It appears that my Google Sheets suggestion in post 273817 above for grabbing Yahoo data has some issues.

I believe it is because the response time from the Yahoo page is too slow that the Google Sheets INDEX function times out before Yahoo returns the data so you get a lot of cells with a #REF error.

One workaround which give better results but is both cumbersome and still not perfect is to avoid using the INDEX function.

One way of doing this is to pull the data into a different sheet.

Lets assume that as before, in Sheet1 we have:

Cell A2 contains the ticker symbol
Cell B1 contains the date for which I want the adjusted close price

In Sheet2, then you could use one cell to pull the URL together. Say we use cell A1. In this cell we would have the formula:

="https://finance.yahoo.com/quote/" & Sheet1!A2 & "/history?period1=" & Sheet1!B1*86400-2209078800 & "&period2=" & Sheet1!B1*86400-2209078800 & "&interval=1d&filter=history&frequency=1d"

Then we could enter the following formula in Cell A3 to pull in the data:

=importHTML(A1, "table",1)

This will pull the data into a table that covers the range A3:G4 and an additional note in A5. The adjusted close price will be in cell F4

So back in Sheet1, to pull the adjusted close back into Cell B2, you would enter the formula

=Sheet2!F4

This will probably work for a few datapoints but I don't think will be too successful for a large number of datapoints.

StevnFool
Copyright 1996-2020 trademark and the "Fool" logo is a trademark of The Motley Fool, Inc. Contact Us