Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tq_get, get = "stock.prices": Yahoo! Finance returns NA with error message #38

Closed
mdancho84 opened this issue May 17, 2017 · 2 comments
Closed
Labels

Comments

@mdancho84
Copy link
Collaborator

Yahoo has changed the URL to the financial data download as discussed in Quantmod Issue 157. The error shows up as follow:

> tq_get("AAPL")
[1] NA
Warning message:
x = 'AAPL', get = 'stock.prices': Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'https://ichart.finance.yahoo.com/table.csv?s=AAPL&a=0&b=01&c=2007&d=4&e=17&f=2017&g=d&q=q&y=0&z=AAPL&x=.csv'

An alternative is to use Quandl's WIKI End Of Day database which has many of the same data available. Note that you will need an API key if you plan to make more than 50 API calls per day.

> tq_get("WIKI/AAPL", get = "quandl", from = "2007-01-01", to = "2017-01-01")
# A tibble: 2,518 × 13
         date  open  high   low close    volume ex.dividend split.ratio adj.open adj.high  adj.low adj.close
       <date> <dbl> <dbl> <dbl> <dbl>     <dbl>       <dbl>       <dbl>    <dbl>    <dbl>    <dbl>     <dbl>
1  2007-01-03 86.29 86.58 81.90 83.80  44225700           0           1 11.13446 11.17188 10.56800  10.81316
2  2007-01-04 84.05 85.95 83.82 85.66  30259300           0           1 10.84542 11.09059 10.81575  11.05317
3  2007-01-05 85.77 86.20 84.40 85.05  29812200           0           1 11.06736 11.12285 10.89059  10.97446
4  2007-01-08 85.96 86.53 85.28 85.47  28468100           0           1 11.09188 11.16543 11.00414  11.02865
5  2007-01-09 86.45 92.98 85.15 92.57 119617800           0           1 11.15511 11.99771 10.98736  11.94480
6  2007-01-10 94.75 97.80 93.45 97.00 105460000           0           1 12.22610 12.61966 12.05836  12.51643
7  2007-01-11 95.94 96.78 95.10 95.80  51437600           0           1 12.37965 12.48804 12.27126  12.36159
8  2007-01-12 94.59 95.06 93.23 94.62  46881800           0           1 12.20546 12.26610 12.02997  12.20933
9  2007-01-16 95.68 97.25 95.45 97.10  44431300           0           1 12.34610 12.54869 12.31643  12.52934
10 2007-01-17 97.56 97.60 94.82 94.95  58795000           0           1 12.58869 12.59385 12.23513  12.25191
# ... with 2,508 more rows, and 1 more variables: adj.volume <dbl>
Warning message:
No Quandl API key detected. Limited to 50 anonymous calls per day. Set key with 'quandl_api_key()'. 

We apologize for any inconvenience.

@mdancho84
Copy link
Collaborator Author

Josh Ulrich has implemented a fix in quantmod that resolves this bug. Use devtools to install:

devtools::install_github("joshuaulrich/quantmod", ref="157_yahoo_502")

@mdancho84
Copy link
Collaborator Author

Upgrading to quantmod version 0.4-10 fixes this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant