quantopian / empyrical

Common financial risk and performance metrics. Used by zipline and pyfolio.
https://quantopian.github.io/empyrical
Apache License 2.0
1.27k stars 398 forks source link

MAINT: Migrate from Yahoo and Google APIs to Quandl #96

Closed eigenfoo closed 6 years ago

eigenfoo commented 6 years ago

Yahoo has suffered large breaks in the API with no stable replacement. Our current backup, Google, has not been stable since late 2017. Both these errors are upstream, with pandas-datareader, which they are currently trying to fix.

In the meantime, we are using the Quandl API to fetch returns data.

Note that users must make a free Quandl account in order to get an API key. This API key must then be set as an environment variable. In bash, this can be done simply by running export QUANDL_API_KEY='quandl_api_key'. Without an API key, users may only make up to 50 calls a day, and will not have access to data on certain tickers (most notably SPY).

Clearly, this is an undesirable position to be in: this should be considered a temporary fix until Yahoo or Google Finance transition to more stable APIs, and pandas-datareader starts supporting them again.

Closes #89. Thanks to @jaycode for authoring most of this!

eigenfoo commented 6 years ago

Not read to merge yet. It appears that Quandl does not have SPY returns?!

RemoteDataError: Unable to read URL: https://www.quandl.com/api/v3/datasets/WIKI/SPY.csv?start_date=2010-01-01&end_date=2018-05-17&order=asc
Response Text:
b'code,message\nQECx02,You have submitted an incorrect Quandl code. Please check your Quandl codes and try again.\n'
eigenfoo commented 6 years ago

It turns out you need a Quandl API key in order to read SPY returns, among other tickers. Also, without an API key, users are limited to 50 calls per day. I've updated the main description with this info.