From 2d02431e6d714e3c921581611ea98f5904562760 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 15 Aug 2016 22:58:04 -0400 Subject: [PATCH] MAINT: Add alt-constructor for NoFurtherDataError. --- zipline/errors.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/zipline/errors.py b/zipline/errors.py index 84db348f..c602c099 100644 --- a/zipline/errors.py +++ b/zipline/errors.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from textwrap import dedent from zipline.utils.memoize import lazyval @@ -583,6 +584,29 @@ class NoFurtherDataError(ZiplineError): # that can be usefully templated. msg = '{msg}' + @classmethod + def from_lookback_window(cls, + initial_message, + first_date, + lookback_start, + lookback_length): + return cls( + msg=dedent( + """ + {initial_message} + + lookback window started at {lookback_start} + earliest known date was {first_date} + {lookback_length} extra rows of data were required + """ + ).format( + initial_message=initial_message, + first_date=first_date, + lookback_start=lookback_start, + lookback_length=lookback_length, + ) + ) + class UnsupportedDatetimeFormat(ZiplineError): """