From 79c91897ba0e08da9ffb7d7565663fb5c343fa47 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 9 Jun 2014 17:42:41 -0400 Subject: [PATCH] ENH: Add `freq_filter` argument to `HistoryContainer.update_digest_panels`. Adds a new argument, `freq_filter`, to `HistoryContainer.update_digest_panels`, which can be used to supply a predicate determining which digest panels are updated by the call. This is useful for supporting initialization/backfilling of multi-frequency panels in subclasses. --- zipline/history/history_container.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zipline/history/history_container.py b/zipline/history/history_container.py index 83f088f6..49cc9a49 100644 --- a/zipline/history/history_container.py +++ b/zipline/history/history_container.py @@ -305,14 +305,20 @@ class HistoryContainer(object): sid in self.buffer_panel.minor_axis)}) self.buffer_panel.add_frame(algo_dt, frame) - def update_digest_panels(self, algo_dt, buffer_panel): + def update_digest_panels(self, algo_dt, buffer_panel, freq_filter=None): """ Check whether @algo_dt is greater than cur_window_close for any of our frequencies. If so, roll a digest for that frequency using data drawn from @buffer panel and insert it into the appropriate digest panels. + + If @freq_filter is specified, only use the given data to update + frequencies on which the filter returns True. """ for frequency in self.unique_frequencies: + if freq_filter is not None and not freq_filter(frequency): + continue + # We don't keep a digest panel if we only have a length-1 history # spec for a given frequency digest_panel = self.digest_panels.get(frequency, None)