From 28b1da443e088d495eaca478c2ce5ce53353ecc5 Mon Sep 17 00:00:00 2001 From: Andrew Liang Date: Fri, 10 Jun 2016 17:37:08 -0400 Subject: [PATCH] MAINT: Raise when trying to get a date outside trading calendar next_scheduled_day and previous_scheduled day should raise if trying a return a date outside the calendar. Previously it just returns None, but it should be made consistent with the behavior of add_scheduled_days --- zipline/utils/calendars/calendar_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/utils/calendars/calendar_helpers.py b/zipline/utils/calendars/calendar_helpers.py index e6ea29cc..f99c41d1 100644 --- a/zipline/utils/calendars/calendar_helpers.py +++ b/zipline/utils/calendars/calendar_helpers.py @@ -73,7 +73,7 @@ def next_scheduled_day(date, last_trading_day, is_scheduled_day_hook): dt += delta if is_scheduled_day_hook(dt): return dt - return None + raise NoFurtherDataError(msg='Cannot find next day after %s' % date) def previous_scheduled_day(date, first_trading_day, is_scheduled_day_hook): @@ -97,7 +97,7 @@ def previous_scheduled_day(date, first_trading_day, is_scheduled_day_hook): dt += delta if is_scheduled_day_hook(dt): return dt - return None + raise NoFurtherDataError(msg='Cannot find previous day before %s' % date) def next_open_and_close(date, open_and_close_hook,