Yahoo finance discontinued--now what?

Hi everyone! Lamentably, Yahoo finance is discontinued and getSymbols no longer works. Do any of you have alternative sources and codes to access stocks? My code, which I have used for years, now only states the following: "Could not establish session after 5 attempts." Google is also defunct. I used FRED, but not sure how to get stocks like Apple and Amazon.

Thanks!

Could you expand a little on what you mean by "Yahoo finance is discontinued?" I just went to Yahoo finance and downloaded a csv of daily Apple stock prices from 1980 through today. Is it a particular api that's been discontinued? If so, here is a link to some alternatives 11 Top Alternatives to Yahoo Finance API

Thanks for the quick reply! When I do a simple code like A<-getSymbols("AMZN", auto.assign = F), it always comes up as "Could not establish session after 5 attempts." I have run it in different ways. Previously, I never had a problem. When I searched for the issue, I read that yahoo finance was being discontinued. I started having this problem at the university and now at home. Essentially, getSymbols fails to work now.

Are you using the most up-to-date version of quantmod ( 0.4-20) ?
This issue the way you describe it seems to has been raised and dealt with in April 2022.
getSymbols.yahoo() always throws "Error in new.session()" · Issue #358 · joshuaulrich/quantmod (github.com)
and
NEWS (r-project.org)

Thanks, I am still having problems despite all the information. I never did previously and do not have problems with FRED or other sources. Are there other sources for stocks and could one give me the code. I have been looking at, for example, Alpha Vantage.

I'm fairly certain you just need to update quantmod, as @nirgrahamuk mentioned

Run install.packages("quantmod") then restart your R session and it should work.

Thanks, I have been reinstalling and it finally worked. Not sure why it failed to work the previous times. Maybe it was being masked by Tidyquant. I will have to see is the quantmod in tidyquant, which is a great package, has the newest quantmod. Thanks to you all!

But I would also like to here if there are other sources and codes for retrieving additional financial data like stocks and bonds. I have used FRED and have found there are other packages that link to Bloomberg and Alpha Vantage. I simply do not know the codes to access the data. Getsymbols is popular because it is easy. Nonetheless, I would like to access data through other ways. Any literature and/or codes would be welcomed.

I'll only speak about Bloomberg because that's the only one I know about; The best package available is Rblpapi. The R API works almost exactly the same as the Excel API:

library(Rblpapi)
#> Rblpapi version 0.3.10 using Blpapi headers 3.8.18.1 and run-time 3.8.18.1.
#> Please respect the Bloomberg licensing agreement and terms of service.

blp <- blpConnect()

bdp('XSP Index', 'px_last')
#>           px_last
#> XSP Index  403.04

Created on 2022-06-09 by the reprex package (v1.0.0)

Obviously to use the Bloomberg API you need a Bloomberg subscription, so that's definitely something to be aware of as you evaluate financial data sources.

Quandl used to provide stock prices as well as other data, much of it free within limits. It seems it is now part of Nasdaq (Quandl.com redirects to data.nasdaq.com). I can still retrieve data using the Quandl package, but only to March 2018, so not super useful, but might be helpful to someone for back testing...

> Quandl("WIKI/AAPL") %>% head()
        Date   Open   High    Low   Close   Volume Ex-Dividend Split Ratio Adj. Open
1 2018-03-27 173.68 175.15 166.92 168.340 38962839           0           1    173.68
2 2018-03-26 168.07 173.10 166.44 172.770 36272617           0           1    168.07
3 2018-03-23 168.39 169.92 164.94 164.940 40248954           0           1    168.39
4 2018-03-22 170.00 172.68 168.60 168.845 41051076           0           1    170.00
5 2018-03-21 175.04 175.09 171.26 171.270 35247358           0           1    175.04
6 2018-03-20 175.24 176.80 174.94 175.240 19314039           0           1    175.24
  Adj. High Adj. Low Adj. Close Adj. Volume
1    175.15   166.92    168.340    38962839
2    173.10   166.44    172.770    36272617
3    169.92   164.94    164.940    40248954
4    172.68   168.60    168.845    41051076
5    175.09   171.26    171.270    35247358
6    176.80   174.94    175.240    19314039

It may be that current prices are available from a different nasdaq/Quandl data set--I didn't find them after a quick search though.

riingo is an interface to the Tiingo API

You need an account and a token but its easy to set up An R Interface to the Tiingo Stock Price API • riingo

Thanks so much everyone for this wealth of information. I have used Quandl and the Bloomberg package, but never figured out the codes. I have found less information on finance/time series data on R than other subjects (anova, regression, etc.). Any great online updated books/sites would be great. All the best!

Your problem is you can not assign getSymbols with "stk -> getSymbols("SPY"), I had the problem many years ago and came across a torrent of aggression for being rather dull(stupid) when I posted on stackoverflow. I have forgotten the exact switch you need to assign a symbol , I think it maybe auto.assign =FALSE(F is not correct, I am writing in a hurry, please check syntax). But the issue is of that style.here is the proper way to assign names without weird behavior.
symbols <- c("SPY","IWM","QQQ")

prices <- getSymbols(symbols,
src = 'yahoo',
from = "2010-01-01",
auto.assign = TRUE,
warnings = FALSE)

I am sure it will work with that.
I did that 3 minutes ago on 1:58 PM 6/11/22 Australian Eastern Standard Time, works fine yahoo.
It could also be ghosts in the machine happens occasionally, you have to fully uninstall R and Rstudio load the latest version and load all libraries needed again, with install.packages(......., dependencies=TRUE), then load with library, I avoid and never use require command it is inadequate. It is advisable to install and load the latest R Tools library also.

There is a vast amount on time series with R the basic is Rob Hyman Ebook

Ruey Tsay Analysis of Time Series and his book on Finance with R are from intermediate to expert level books, the finance book is basic to intermediate and above.
Check out Matt Dancho's Tidy quant library and online videos.
See cran R repository and type in time series; you will be busy for a lifetime working through it. Tsbox is an interesting R universal timeseries conversion tool, you should check out. Columbia University Econometrics professor Eric Zivot used to have a definitive discussion of the (then existing time series methods and formats), it was available with a search on google although I am not sure if it still is it is about 8 or 10 years old there is only one new format I think tstibles I think. But their is literally hundreds of books too many too mention, on coursera there is a few courses, unsure about edx, Udemy has a dozen or so courses also, and others.

Seriously for stock data I have never bothered with quandl and bloomberg. However I though Bloomberg was a very expensive subscription service, I have no experience with tingo, quandl is good for economic data or subscription services for things which are not published like historical option implied volatility data. Tingo I have come across in forums, staff there promoting there service, they like quandl have data as there business, I only briefly checked quandl after nasdaq bought it and I am unsure if it has the depth of services previously provided as a unique data providing organisation. You could not get a lot for free previously on quandl just govt statistics such as Fred and Treasury and UK and worldwide economic stats data, and a basic daily price portal for shares.

Thanks for this. Yes, Hyman and the forecast package are great!

FRED now is free. I have found the same thing--high priced subscription rates for financial data! So sad.

Hi, the simfin project offers a free API for stocks and financial reports. There is an accompanying
simfinapi R package which I have used. Here I've written a short blog post about it. Hope it helps:)

I would recommend using tidyquant which uses quantmod for importing stock data and FRED for economic data. Plus tidyquant is just perfect for doing stock analysis.

Thanks, I always use that one. Not sure if tidyquant updated the quantmod in it. Regardless, I ended up updating quantmod and tidyquant. Thanks so much for the reply!