From 0cc84e7a15659583c5426a788d44dcdb6a030aa6 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Mon, 3 Aug 2015 12:09:26 -0400 Subject: [PATCH] BUG: Use normed last_close instead of period_end. `period_end` can be outside the range of data for which we have dates. `last_close` properly gets pulled back to the last date for which we actually have data. We should consider whether or not we need to be storing period_end at all. --- zipline/algorithm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index bc088774..3a99dc11 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -1281,7 +1281,7 @@ class TradingAlgorithm(object): """ days = self.trading_environment.trading_days start_date_loc = days.get_loc(start_date) - sim_end = self.sim_params.period_end + sim_end = self.sim_params.last_close.normalize() end_loc = min(start_date_loc + 252, days.get_loc(sim_end)) end_date = days[end_loc] return self.engine.factor_matrix(