ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.89k stars 2.44k forks source link

Fix error on empty options chain #1995

Closed stevenbischoff closed 4 months ago

stevenbischoff commented 4 months ago

Fixes #1969

Error occurs when Yahoo has no calls or puts for a ticker. I wasn't sure whether y'all would prefer an exception in this case instead (first pull request!), but I chose to return an "empty" Options namedtuple since _download_options() returns an empty dict.

ValueRaider commented 4 months ago

I don't use options so no opinion. Try tagging the few people that use options (search here).

BiggRanger commented 4 months ago

Returning empty works perfectly for me. I'd rather check for nothing than have to handle an exception.