mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-11 11:16:15 +08:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user