Skip to content

Commit ca5f98b

Browse files
author
Andrew Daniels
authored
BUG: Makes NoData{Before, After}Date subclass NoDataOnDate (#1507)
This allows us to catch and handle all three of these exceptions in `calc_dividend_ratios`.
1 parent 9d7049a commit ca5f98b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

zipline/data/bar_reader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class NoDataOnDate(Exception):
2222
pass
2323

2424

25-
class NoDataBeforeDate(Exception):
25+
class NoDataBeforeDate(NoDataOnDate):
2626
pass
2727

2828

29-
class NoDataAfterDate(Exception):
29+
class NoDataAfterDate(NoDataOnDate):
3030
pass
3131

3232

zipline/data/us_equity_pricing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,15 @@ def get_last_traded_dt(self, asset, day):
634634
while True:
635635
try:
636636
ix = self.sid_day_index(asset, search_day)
637-
except NoDataOnDate:
638-
return None
639637
except NoDataBeforeDate:
640638
return None
641639
except NoDataAfterDate:
642640
prev_day_ix = self.sessions.get_loc(search_day) - 1
643641
if prev_day_ix > -1:
644642
search_day = self.sessions[prev_day_ix]
645643
continue
644+
except NoDataOnDate:
645+
return None
646646
if volumes[ix] != 0:
647647
return search_day
648648
prev_day_ix = self.sessions.get_loc(search_day) - 1
@@ -965,7 +965,7 @@ def calc_dividend_ratios(self, dividends):
965965
dtype=[
966966
('sid', uint32),
967967
('effective_date', uint32),
968-
('ratio', float64),
968+
('ratio', float64),
969969
],
970970
))
971971
ex_dates = dividends.ex_date.values

0 commit comments

Comments
 (0)