zavtech / morpheus-yahoo

An adapter that returns Morpheus DataFrames from Yahoo Finance
6 stars 4 forks source link

401 response code running YahooReturnSource #2

Open chadworth opened 7 years ago

chadworth commented 7 years ago

Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://query1.finance.yahoo.com/v7/finance/download/BLK?period1=1104537600&period2=1401580800&interval=1d&events=history&crumb=jValG4P3fLj at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) at com.zavtech.morpheus.util.http.HttpClient$DefaultClient.execute(HttpClient.java:133) ... 10 more

Zavster commented 7 years ago

Hey chadworth, apologies but the Yahoo adapter is currently broken as it was written a few years ago and Yahoo has discontinued some of the services on which it depends (hence why the adapter is not available on Maven Central at this moment). I do plan to address the issues in the next few weeks and will post a reply here when it is working again. Be aware however that when it is fixed it can break at anytime as it relies on screen scrapping and other non-supported apis in Yahoo Finance which are subject to change without notice. So the adapter is fine for research purposes, but I would not rely on it for production. If you are looking for end of day close prices, you can use the Quandl adapter and the WIKI price source: https://www.quandl.com/data/WIKI-Wiki-EOD-Stock-Prices

chadworth commented 7 years ago

Yep. We could call the library below which seems to be kept up-to-date with Yahoo: https://github.com/sstrickx/yahoofinance-api

Zavster commented 7 years ago

Thanks for the pointer, I'll take a look at that

chadworth commented 7 years ago

I found they have a new JSON api that works much better. I sent a PR for it here: https://github.com/sstrickx/yahoofinance-api/pull/96/files

You might want to just copy in the code from this PR

Zavster commented 7 years ago

This has been fixed in the latest release which is now on Maven Central. The documentation can be found at the link: http://www.zavtech.com/morpheus/docs/providers/yahoo/