Is there a method to use GoogleFinance() in Google Sheets to get the Adjusted Close price, which adjusts for Splits and Dividends like Yahoo Finance?
I believe the historical Price from Google Finance is adjusted
=GOOGLEFINANCE("GOOG", "Price", DATE(2021,6,16))
Matches the adjusted column in Yahoo Finance
Related
My query is on stock market of India where I fetch the quotes from =googlefinance function in my google sheet. I was very disappointed to know that the function does not show last closing price. Instead, it shows the last traded price.
Lets take an example of a stock RELIANCE:
=GoogleFinance("NSE:reliance", "price") result is 2498.00 which is incorrect.
Actual closing on Friday, 16 Sep 2022 was 2499.20 as per official National Stock Exchange of India. You may refer to this link for the Close price and the screenshot below
The incorrect quote 2498.00 is the last traded price before market closing
The correct quote is 2499.20 when the markets were closed.
This behavior is common across all stocks of Indian stock market. I have used almost all the parameters those are available in the =googlefinance function but I could not find a way to get the correct stock quote.
Then I decided to scrape the value from the official website using the following without success
<div id="closePrice">2,499.20</div>
//*[#id="closePrice"]
/html/body/div[2]/div[4]/div[2]/div[1]/div[4]/ul/li[6]/div[1]
document.querySelector("#closePrice")
I searched a lot of valuable articles on this site and also on google but could not find a solution which would fetch the desired result. Can someone help me with a way to get 2499.20 as a result for RELIANCE stock either using =googlefinance function or by scraping the value from office website?
Thank you.
Solution suggested by #TheMaster (Thank you so much!)
=LAMBDA(gf,INDEX(gf,ROWS(gf),2))(GOOGLEFINANCE("NSE:RELIANCE", "close",TODAY()-5,15))
Two other ways
=index(GOOGLEFINANCE("NSE:reliance","Close",today()-5,15),4,2)
=query(GOOGLEFINANCE("NSE:reliance","Close",today()-5,15),"select Col2 where Col1 < date '"&TEXT(today()+1, "YYYY-MM-DD")&"' order by Col1 desc limit 1",False)
I am also keen to know which one of these or other methods (if any) will get the results faster without crashes or any other processing issues as my googlesheet is loaded with thousands of stock quotes which will be refreshed every 1 minute.
Only historical prices support close attribute. Use the start date argument to get historical prices and get the last close:
=LAMBDA(gf,INDEX(gf,ROWS(gf),2))(GOOGLEFINANCE("NSE:RELIANCE", "close",TODAY()-5,15))
This is another way of achieving the result.
=query(GOOGLEFINANCE("NSE:reliance","Close",today()-5,15),"select Col2 where Col1 < date '"&TEXT(today()+1, "YYYY-MM-DD")&"' order by Col1 desc limit 1",False)
When I compared performance of both the solutions =LAMBDA and =QUERY on 2500+ stocks, I found query to be more faster than lambda.
Cheers!
However, my main query remains unresolved as no formula of google finance gives today's close until the actual day is over.
I have used the SUMPRODUCT formula in Google Sheets to work out the total sum made of 7 products in each month of 2022. Screenshot of the data set and formula used in Google Sheets Formula I am using for the total per month:
However, Data Studio does not seem to accept this formula.
I want to sum the total amount of each product multiplied by the corresponding price for each month it was purchased in. I then want to use this data set in Google Data Studio to show the total amount accumulated for each month.
Google Sheets: https://docs.google.com/spreadsheets/d/1F81cSdnqkoOjEtFWaxjNIdXgeQdwtbzmX2zslT8dXpE/edit?usp=sharing
Google Data Studio Report: https://datastudio.google.com/reporting/9fcbcd71-0c27-4d40-84d3-aef6ed332354
The Google Sheets needs a header also for column A.
Displaying the data in a Table in Data Studio shows:
A sum over the column "January" adds the quantity 1 and 4 and the £340. This gives the wrong 345. A quick solve is to apply a filter on the field "Option" and only consider the "SUM" row.
Another way is to calculate the product by the formula
January*Price
Summing over this product is the standard setting.
For each column (here: 12, January to December) such a formula is needed.
I created my own international portfolio tracker / dividend tracker through google sheets & yahoo finance.
The problem with international stocks is that you often cannot simply use the integrated data from google finance. KO (coca cola) is easy, CCC3.DE (also coca cola) cannot be found on google finance. suddenly some formulas stop working for some of the tickers.
For Example AD.AS does work but ccc3.de does not work.
For price is use; A1 = "CCC3.DE" or "AD.AS"
=IFNA(VALUE(IMPORTXML("https://finance.yahoo.com/quote/" &A1, "//*[#class=""D(ib) Mend(20px)""]/span[1]")))
For dividend amount I use;
=split(IMPORTXML(concatenate("http://finance.yahoo.com/quote/",index(split((E9&F9&G9),":"),0,2)),$F$22),"()"))/K9)))
It seems that Yahoo changed some things in their website and it resulted to the import formula not to work anymore for some of the webpage in Yahoo Finance as well as for some tickers. This is the result of the IMPORTXML command for the CCC3.DE ticker.
For now, I suggest finding another website/data source that will give you the same information that you need for those unavailable/unscrapeable tickers. Another option would be to wait for yahoo to fix this issue.
I can use ImportHTML in Google sheets to retrieve financial data from Yahoo Finance but it is lacking where Google Finance has the data. For example here is a link to Ford's financials on Google Finance how would I grab this data with ImportHTML in Google Sheets?
https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG
It depends on exactly what you want. These get all available tables:
Income Statement Quarterly Data
=importhtml(
"https://www.google.com/finance? q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",2)
Income Statement Annual Data
=importhtml(
"https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",3)
Balance Sheet Quarterly Data
=importhtml(
"https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",4)
Balance Sheet Annual Data
=importhtml(
"https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",5)
Cash Flow Quarterly Data
=importhtml(
"https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",6)
Cash Flow Annual Data
=importhtml(
"https://www.google.com/finance?q=NYSE%3AF&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",7)
To get other companies, enter the stock symvol (i.e.; F, GOOG, IBM) in a cell and reference the cell in the URL. Like this:
=importhtml(
"https://www.google.com/finance?q="&A2&"&fstype=ii&ei=viASWOnfNsfEeqqUnMgG","table",2)
The "&A2&" references the cell A2. The formula will get the data for the company in cell A2.
I would like to retrieve stock data on Google Spreadsheet through the ImportXML() function.
Suppose I want to retrieve stock data of SHA:000001
To retrieve price, the formula to use is;
=ImportXML("https://www.google.com/finance?q=SHA:000001", "//span[#class='pr']")
What is the formula to use for retrieving "price change in percentage" for the day?
This worked for me:
=ImportXML("https://www.google.com/finance?q=SHA:000001", "//div[#class='id-price-change nwp']/span/span[2]")