How to get Historical Price from a specific time?

Viewed 2477

Does anyone know if it is possible to get the price of a stock using =googlefinance from a time stamp? Dates are fairly easy but it does not seem possible to do times on days? for example if I wanted to look at GOOG for 10:00AM 21/12/2020

=index(GOOGLEFINANCE("GOOG","price","21/12/2020 10:00:00"),2,2)

That provides the stock for that date but not the time. I am not sure if it's possible but it would be very useful in a sheet I am making.

2 Answers

Unfortunately, you can only retrieve the closing price of a particular day or days but not specific times.

When you pass a historical data as an argument, google assumes that you are looking for the closing price. Therefore, if you choose either "price" or "close" for a past data, you will get the same results.

The official documentation for the attribute "close":

"close" - The closing price for the specified date(s).

therefore getting the closing price of a particular time is not possible.

For example, this will return the price for each day, starting from 21st of December 2020 until 30 days later:

=GOOGLEFINANCE("GOOG","price","12/21/2020",30,1)

or this =GOOGLEFINANCE("GOOG","close","12/21/2020",30,1)

enter image description here

you see that the closing price time is fixed at 16:00:00.

If you want real time historical data you should look for other APIs that you may need to pay.

You can filter once you get the values

As an example, you can retrieve the prices at 13:xx:xx hs or 16:xx:xx hs by using regular expressions and QUERY:

=ARRAYFORMULA(QUERY(GOOGLEFINANCE("GOOG","price","12/22/2020",30,1), "SELECT * WHERE Col1 matches '.* 13:.*|.* 16:.*'", 0))

Or you can filter just one specific hour:

=ARRAYFORMULA(QUERY(GOOGLEFINANCE("GOOG","price","12/22/2020",30,1), "SELECT * WHERE Col1 matches '.* 13:.*'", 0))

References

Related