Skip to content

Commit

Permalink
Merge pull request ranaroussi#1995 from stevenbischoff/dev
Browse files Browse the repository at this point in the history
Fix error on empty options chain
  • Loading branch information
ValueRaider authored Jul 24, 2024
2 parents 59178f4 + d70c99c commit fa37798
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions yfinance/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def option_chain(self, date=None, tz=None):
date = self._expirations[date]
options = self._download_options(date)

if not options:
return _namedtuple('Options', ['calls', 'puts', 'underlying'])(**{
"calls": None, "puts": None, "underlying": None
})

return _namedtuple('Options', ['calls', 'puts', 'underlying'])(**{
"calls": self._options2df(options['calls'], tz=tz),
"puts": self._options2df(options['puts'], tz=tz),
Expand Down

0 comments on commit fa37798

Please sign in to comment.