So to my huge surprise, it seems impossible to get historical stock prices inside a Google Apps Script (for populating a google sheet) in any way. For some nice reason the scripts do not allow to call GoogleFinance and the FinanceApp does not exist anymore. Additionally, the Yahoo URL API no longer supports to be able to get historical stock. So how the heck is it possible to get stock prices data in a Google sheet via Script?
1
votes
Pay for the data, from someone that offers the paid data? This isn't the place to request foreign resources like tutorials, API service recommendations, etc.
– tehhowch
Well maybe I made phrased the question really bad, but what I'm asking is if there is any way which I have missed for getting the data from the Google Apps or the via web URL. Paying although an option is not really feasible for small personal projects, as well as it makes 0 sense to provide this service inside a sheet yet being somehow inaccessible via a script operating on a sheet. My main assumption is that I'm missing something and this is actually doable.
– Alex Botev
No, you cannot use Google Finance programmatically. That is by Google's design. Consider that they may have a some condition associated with their own access to that data, such that they are not allowed to support operations which would make competitor APIs possible.
– tehhowch
2 Answers
2
votes
There are plenty of other free sources of historical quotes (note that some require being logged in, or API keys):
https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv
https://stooq.com/q/d/l/?s=AAPL.US&i=d
https://api.iextrading.com/1.0/stock/aapl/chart/5y?format=csv
https://api.tiingo.com/tiingo/daily/AAPL/prices?startDate=2012-1-1&endDate=2016-1-1
And there are more...
0
votes
Though Google cleary says they don't support GOOGLEFINANCE from the app script, but there is a way to improvise. You may use the following:
var ticker = cs.getRange(row_idx, ticker_column_idx).getValue();
formula="=GOOGLEFINANCE(" + '"' + ticker + '", ' + '"PRICE")';
cs.getRange(row_idx, price_col_idx).setValue(formula);