GriffinAustin / pynance

Lightweight Python library for assembling and analysing financial data
MIT License
317 stars 43 forks source link

Distinct exception when `pn.opt.retrieve()` tries to find non-existent options. #7

Closed aisthesis closed 8 years ago

aisthesis commented 9 years ago

The user should get an exception that allows her to distinguish between connection errors (where retry logic will often be called for) and cases where the stock doesn't exist or doesn't have any options.

It appears that ValueError is raised in these cases.

aisthesis commented 9 years ago

It's probably best just to re-raise whatever exception Pandas raises. Everything except ValueError seems to mean that something is wrong with the connection to Yahoo, including times when Yahoo is resetting its servers.

aisthesis commented 8 years ago

The try-except block should just be removed at https://github.com/aisthesis/pynance/blob/master/pynance/opt/retrieve.py#L57

This is more in the spirit of this library as wrapper for pandas.

The documentation should have notes stating what exception to expect in case of bad connection. pandas_datareader has also changed RemoteDataError to a private exception type defined under _utils: https://github.com/pydata/pandas-datareader/blob/master/pandas_datareader/_utils.py#L10

The reference in the pynance comments should be deleted.

aisthesis commented 8 years ago

The way it is, the code is vulnerable to changes in pandas_datareader. Currently I'm getting this;

...
AttributeError: module 'pandas_datareader.data' has no attribute 'RemoteDataError'
aisthesis commented 8 years ago

Resolved in develop branch