"Historical quote data is unavailable for the specified date range" for Yahoo finance when querying stock history - yahoo-finance

I've got a very strange problem when query stock history prices via yahoo finance,
I cannot query google stock prices from Jan-04-2010 to Apr-19-2013, i.e.
http://finance.yahoo.com/q/hp?s=GOOG&a=00&b=04&c=2010&d=03&e=19&f=2013&g=d
got a error: "Historical quote data is unavailable for the specified date range."
but I can query prices from Jan-04-2010 to Apr-19-2014, i.e.
http://finance.yahoo.com/q/hp?s=GOOG&a=02&b=27&c=2011&d=03&e=19&f=2014&g=d
Anyone know what's wrong with my first query?
thanks.

I think Google symbol has been changed to Googl try this it works for me:
http://finance.yahoo.com/q/hp?s=GOOGl&a=00&b=04&c=2010&d=03&e=19&f=2013&g=d

Related

Google Finance does not show last closing price after market hours. It just shows last *traded* price instead of *closing*

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.

Get BTC prices on Google Sheets from Google Finance

I'm trying to get data from Google Finance in Google Sheets with this formula:
=GoogleFinance("CURRENCY:BTC")
But I'm getting this error:
GOOGLEFINANCE, the query for the symbol: 'CURRENCY:BTC' returned no data.
Although on Google Finance itself, I can get BTC prices:
https://www.google.com/finance?q=CURRENCY:BTC
with the same query strings.
How can I can fix this?
You need to have a from and to currency like this:
=GoogleFinance("CURRENCY:USDBTC")
For historic close price use:
=GoogleFinance("CURRENCY:USDBTC","close","07/07/2017")
If you want only the price returned use:
=iferror(index(GoogleFinance("CURRENCY:USDBTC","close","07/07/2017"),2,2))
As of 2020-08-15 the following formula works well (without any add-ons):
=GOOGLEFINANCE("BTCUSD")
Seems like it works only for BTC and ETH though.
2022-05-04, the following works on Google Sheets:
=googlefinance("CURRENCY:USDBTC") as well as most combinations of currency and BTC (and ETH, LTC, BNB, XRP, XLM, and ADA), for example GBPBTC and JPYBTC.
=googlefinance("CURRENCY:BTCUSD") works too, in the same combinations of coin and currency.
Although finance.google.com has DOGE and LINK pricing, they don't seem to work the same way in the Sheet's googlefinance function.
Another way to work with crypto currency is to use the add-on where you can extract data from other sources.
=CRYPTOFINANCE("BTCUSD")
Link below:
https://jbuty.com/how-to-get-crypto-currencies-rates-and-more-in-google-sheet-1a57e571bc14

How to get Yahoo Finance Key Statistics such as return on equity

I would like to get key statistics data for a given symbol in Yahoo! Finance.
I found a few ways to get statistics data using Yahoo Finance API.
For example, to get Apple’s name (n), ask (a), bid (b), market cap(j1),
http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=nabj1
(e.g. http://www.jarloo.com/yahoo_finance/)
But I would like to extract more information such as return on equity and enterprise value.
How can I do this?
I cannot even fetch these values from web scraping either.
Key statistics can be accessed by calling the following API-Call:
https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=defaultKeyStatistics
This includes enterprise value and book value.
I have not found a way to get return on equity directly from Yahoo Finance but it could be calculated from other values found in this answer.
Edit:
Return on equity can be found in the financial data:
https://query1.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=financialData

YQL don't provide Indian stock quote related data

we are very interested to use YQL but unfortunately the query is not supported for Indian stock market , we are building one large web app where wee need to show BSE and NSE tickers with live updates , so we thought to use yahoo financial services but I have tried a lot in the console the below line but this is return with zero data
select * from yahoo.finance.quotes where symbol IN("^BSESN")
For that result we can't able to use yql , I have also change the symbol ^BSESN with other Indian company names like reliance ,tata but nothing is shown, feeling very poor......
select * from yahoo.finance.quotes where symbol IN("^BSESN") ---- not working any idea or suggestion will helpful to me
Thanks in advance
Yahoo's YQL shows uneven performance for bourses outside the West. For example:
You can obtain historical data for Reliance Industries from yahoo.finance.historicaldata using YQL as follows: select * from yahoo.finance.historicaldata where symbol in ('RIL.BO')
You cannot get stock quote from yahoo.finance.quotes using YQL as follows: select * from yahoo.finance.quotes where symbol in ("RIL.BO")
Try it!

How to get a ticker symbol from a company name with the Google Finance API?

This matter (getting a symbol form a company name) has already been solved in the following thread with Yahoo's API and I found the first and third answers quite useful.
I also noticed that the second answer dealt with Google Finance but it uses ticker symbols and not the company name ...
Unfortunately, I learnt that Yahoo sometimes uses different ticker symbols from the stock exchanges.
So I would like to do the same thing — that is, I give a company name and I get its symbol — but with the Google Finance API, instead of Yahoo's.
Is that possible ? Thanks
Back when Google Finance first provided a Google Sheets formula, it was this:
=GoogleLookup(A1, "ticker")
But this no longer works, and Google has been dropping the ball on Finance for quite some time now. The REVERSE lookup is possible tho; ie, given the TICKER SYMBOL you can look up the official corporate name (according to GoogleFinance)...
=GOOGLEFINANCE(B1, "name")
Where A1 is the cell in Google Sheets with the corporate name,
and B1 is the cell in GS w the ticker symbol.
Basically, you now need the ticker symbol to do anything with 'GOOGLEFINANCE'.
'LOOKUP' is still around but has been changed.
If you want ticker symbols, you have to write some API calls, and those solutions can be found elsewhere.

Resources