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

getYahooData no longer works #43

Closed
humbletrader123 opened this issue Apr 19, 2017 · 8 comments
Closed

getYahooData no longer works #43

humbletrader123 opened this issue Apr 19, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@humbletrader123
Copy link

humbletrader123 commented Apr 19, 2017

Hi for last two days (started April 17, 2017) the TTR::getYahooData returns the following errors

> getYahooData("IBM", 19990404, 20050607)
Error in file(file, "rt") : cannot open the connection

There is absolutely no issue with my internet.

My TTR package version is 0.23-1
and R version is 2.15.2

I'd very much appreciate if someone takes a quick look and fix. This get function has been working daily for last 5 years.

Thanks

@joshuaulrich
Copy link
Owner

Thanks for the report! This is likely the same as joshuaulrich/quantmod#149. Will patch this evening, but might not be on CRAN for a few more days.

Out of curiosity, why are you using a version of R that is nearly 5 years old?

@joshuaulrich joshuaulrich self-assigned this Apr 19, 2017
@humbletrader123
Copy link
Author

humbletrader123 commented Apr 19, 2017 via email

joshuaulrich added a commit that referenced this issue Apr 19, 2017
Yahoo Finance is now redirecting HTTP requests to HTTPS. Some users' R
installations are not able to follow this redirect, so they error.

Use HTTPS directly for Yahoo Finance.

Fixes #43.
@joshuaulrich
Copy link
Owner

Okay, just pushed a patch to branch 43_yahoo_https. Note that HTTPS wasn't supported and used as a default on all platforms until R-3.3.0. So it's quite possible you will still have issues until you upgrade...

@humbletrader123
Copy link
Author

humbletrader123 commented May 18, 2017 via email

@joshuaulrich
Copy link
Owner

@humbletrader123 It's the same issue as quantmod:157_yahoo_502, but I have to patch it in TTR too. The fix in quantmod doesn't apply to the TTR functions.

@ghost
Copy link

ghost commented May 22, 2017

Joshua, thank you, fix 157 works well for downloading data off Yahoo again.. Somehow it did break something, when calculating historical volatility on a vector of logreturns: xts(apply(retGSPC,2,runSD,n=30),index(retGSPC))*sqrt(252) it gives a Error in runCov(x, x, n, use = "all.obs", sample = sample, cumulative) : Series contain non-leading NAs. The runCov function can't handle NAs and how did the quantmod patch change that ?

@joshuaulrich
Copy link
Owner

@ghost The running/rolling functions in TTR cannot handle missing values. Those are called inhomogeneous indicators, and they aren't simple to implement. While one single missing value may be easy to handle, missing values are hard to handle in these functions in a robust and general way.

@humbletrader123
Copy link
Author

humbletrader123 commented May 29, 2017 via email

joshuaulrich added a commit that referenced this issue May 29, 2017
This commit simply uses code from the quantmod::getSymbols.yahoo fix
from the quantmod repository. See these commits for details:
793601805c5d7291d5cda22ce4df4001a40ff312..aa19272d170d9b35be4279e5abbe310182e08c4f

Fixes #43.
joshuaulrich added a commit that referenced this issue May 29, 2017
getYahooData() does essentially the same thing as getSymbols.yahoo(),
and it doesn't make sense to maintain two interfaces to the same data
source. This will also make it clear that quantmod is the package for
data management.

See #43.
joshuaulrich added a commit that referenced this issue May 29, 2017
This commit simply uses code from the quantmod::getSymbols.yahoo fix
from the quantmod repository. See these commits for details:
793601805c5d7291d5cda22ce4df4001a40ff312..aa19272d170d9b35be4279e5abbe310182e08c4f

Fixes #43.
joshuaulrich added a commit that referenced this issue May 29, 2017
getYahooData() does essentially the same thing as getSymbols.yahoo(),
and it doesn't make sense to maintain two interfaces to the same data
source. This will also make it clear that quantmod is the package for
data management.

See #43.
joshuaulrich added a commit that referenced this issue Jul 10, 2017
Trying to fetch the Yahoo Finance! homepage multiple times can result
in getting a cached response from a proxy. The cached response does
not have a "Set-cookie" header, so the curl handle will still not have
a cookie and the connection will be retried.

This StackOverflow Q/A has two approaches to avoid a cache hit:
https://stackoverflow.com/q/31653271/271616
1) Add a "Cache-control: no-cache" header
2) Add a random query to the URL.

The first approach didn't work because it appears the Yahoo proxies
simply ignore the request. The second approach did work though.

Replace get0() call, so dependency on R>=3.2.0 isn't required.

See #43.
joshuaulrich added a commit that referenced this issue Jul 10, 2017
Looks like Yahoo does not provide data for IBM, so switch to using GE
instead. Also remove the 'dontrun' from the example and set
adjust = FALSE so the examples run faster.

See #43.
joshuaulrich added a commit that referenced this issue Jul 10, 2017
The new Yahoo URL uses UNIX timestamps, but the OHLC subset right before
exiting the function assumed the 'start' and 'end' objects are Date.

See #43.
@joshuaulrich joshuaulrich added this to the 0.23-2 milestone Sep 9, 2018
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

2 participants