ENH: Adds last_available_{session, minute} args to DataPortal (#1528)

This allows optionally setting the last available dts in the DataPortal
explicitly. If these args aren't provided, we fall back to inferring
these from the underlying readers, which was the previous behavior.
This commit is contained in:
Andrew Daniels
2016-10-06 20:46:54 -04:00
committed by GitHub
parent b6f8a67aad
commit 2f097ead76
4 changed files with 44 additions and 7 deletions
+15 -2
View File
@@ -35,11 +35,21 @@ class AssetDispatchBarReader(with_metaclass(ABCMeta)):
- readers : dict
A dict mapping Asset type to the corresponding
[Minute|Session]BarReader
- last_available_dt : pd.Timestamp or None, optional
If not provided, infers it by using the min of the
last_available_dt values of the underlying readers.
"""
def __init__(self, trading_calendar, asset_finder, readers):
def __init__(
self,
trading_calendar,
asset_finder,
readers,
last_available_dt=None,
):
self._trading_calendar = trading_calendar
self._asset_finder = asset_finder
self._readers = readers
self._last_available_dt = last_available_dt
for t, r in iteritems(self._readers):
assert trading_calendar == r.trading_calendar, \
@@ -72,7 +82,10 @@ class AssetDispatchBarReader(with_metaclass(ABCMeta)):
@lazyval
def last_available_dt(self):
return min(r.last_available_dt for r in self._readers.values())
if self._last_available_dt is not None:
return self._last_available_dt
else:
return min(r.last_available_dt for r in self._readers.values())
@lazyval
def first_trading_day(self):