MAINT: Handle gaps in input to daily bars writer (#1778)

Previously, a dataframe passed into BcolzDailyBarWriter.write that was
missing an expected session between its first and last sessions would be
written incorrectly. Upon converting the dataframe to a ctable, the
values for all days following the gap would be shifted backwards, and
nans would be shifted in at the end.

This commit handles the issue by asserting that the number of rows in
the input table matches the number of sessions in the calendar between
the table's first and last sessions.

Also fixes a test that was mistakenly using minutes_in_range where it
should have been using sessions_in_range (uncovered by this change).
This commit is contained in:
Andrew Daniels
2017-05-03 20:49:22 -04:00
committed by GitHub
parent f0e100bcf3
commit 52667b4a90
3 changed files with 84 additions and 23 deletions
+1 -1
View File
@@ -2261,7 +2261,7 @@ class TestCapitalChanges(WithLogger,
@classmethod
def make_equity_daily_bar_data(cls):
days = cls.trading_calendar.minutes_in_range(
days = cls.trading_calendar.sessions_in_range(
pd.Timestamp('2006-01-03', tz='UTC'),
pd.Timestamp('2006-01-09', tz='UTC')
)