Skip to content

Commit

Permalink
BUG: Makes NoData{Before, After}Date subclass NoDataOnDate (#1507)
Browse files Browse the repository at this point in the history
This allows us to catch and handle all three of these exceptions in
`calc_dividend_ratios`.
  • Loading branch information
Andrew Daniels committed Sep 22, 2016
1 parent 9d7049a commit ca5f98b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions zipline/data/bar_reader.py
Expand Up @@ -22,11 +22,11 @@ class NoDataOnDate(Exception):
pass


class NoDataBeforeDate(Exception):
class NoDataBeforeDate(NoDataOnDate):
pass


class NoDataAfterDate(Exception):
class NoDataAfterDate(NoDataOnDate):
pass


Expand Down
6 changes: 3 additions & 3 deletions zipline/data/us_equity_pricing.py
Expand Up @@ -634,15 +634,15 @@ def get_last_traded_dt(self, asset, day):
while True:
try:
ix = self.sid_day_index(asset, search_day)
except NoDataOnDate:
return None
except NoDataBeforeDate:
return None
except NoDataAfterDate:
prev_day_ix = self.sessions.get_loc(search_day) - 1
if prev_day_ix > -1:
search_day = self.sessions[prev_day_ix]
continue
except NoDataOnDate:
return None
if volumes[ix] != 0:
return search_day
prev_day_ix = self.sessions.get_loc(search_day) - 1
Expand Down Expand Up @@ -965,7 +965,7 @@ def calc_dividend_ratios(self, dividends):
dtype=[
('sid', uint32),
('effective_date', uint32),
('ratio', float64),
('ratio', float64),
],
))
ex_dates = dividends.ex_date.values
Expand Down

0 comments on commit ca5f98b

Please sign in to comment.