How to use getReturns with Yahoo's Finance API

I'm having problems with the R package getReturns

. I ran into this error since May 17th:

Warning in file ("rt" file): Unable to open URL http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=4&b=28&c=2014&d=4&e=27&f=2017&g=w&ignore=. csv ': HTTP status was' 404 Not Found'

It looks like the API ichart

is not starting anymore. Can anyone help me with this question? Does anyone know how to fix this? I faced the same problem with quantmod

R.

+3


source to share


4 answers


You can follow my previous post which may help you.

I tried:

library(quantmod)
# Create an object containing the Pfizer ticker symbol
symbol <- "PFE"    
# Use getSymbols to import the data
getSymbols(symbol, src="yahoo", auto.assign=T) 
# because src='google' throws error, yahoo was used, and even that is down

      

When I tried another source, it worked:

# "quantmod::oanda.currencies" contains a list of currencies provided by Oanda.com
currency_pair <- "GBP/CAD"    
# Load British Pound to Canadian Dollar exchange rate data
getSymbols(currency_pair, src="oanda")
str(GBPCAD)    

      

There seems to be problems with google and yahoo while we are using quantmod pkg.



I suggest you use "Quandl" instead. Plz goto Quandl, sign up for free and create an API key then copy it below:

# Install Quandl
install.packages("Quandl")
# or from github
install.packages("devtools")
library(devtools)
install_github("quandl/quandl-r")

# Load the Quandl package
library(Quandl)

# use API for full access
Quandl.api_key("xxxxxx")

# Download APPLE stock data
mydata = Quandl::Quandl.datatable("ZACKS/FC", ticker="AAPL")

      

For HDFC on BSE you can use:

hdfc = Quandl("BSE/BOM500180")

      

for more details:

https://www.quandl.com/data/BSE-Bombay-Stock-Exchange?keyword=HDFC

      

+1


source


I faced this problem too. Yahoo! took off ichart and the open source libraries that rely on it are now broken. Yahoo! Also does not plan to introduce a replacement. For more information see this post on Yahoo! Forums .



+4


source


I switched to eodhistoricaldata.com after Yahoo's failure, a few weeks ago I found a good alternative with an API very similar to Yahoo Finance.

Basically, for almost all R scripts I use, I just changed this:

URL <- paste0("ichart.finance.yahoo.com/table.csv?s=", symbols[i])

      

to:

URL <- paste0("eodhistoricaldata.com/api/table.csv?s=", symbols[i])

      

Then add the API key and it will work the same as before. I saved a lot of time for my R scripts on it.

+1


source


from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
yf.pdr_override() # <== that all it takes :-)

# download dataframe
df = pdr.get_data_yahoo('GOOGL', start="2010-01-01", end="2018-04-30")
df.to_csv('GOOGL')

      

0


source







All Articles