From ad06acd49d9a6afdc1e9b354660519579274c7c2 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 8 May 2013 11:29:35 -0400 Subject: [PATCH] MAINT: Slice into returns containers instead of using .valid() The slicing syntax is more explicit about declaring: 'get all returns up until the current dt'. Also, protects against NaNs that occur before the current dt being silently ignored. i.e. the *_returns_cont series *should* have values from start to current dt, but the .valid() call was occluding a bug where it wasn't. --- zipline/finance/risk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index e5f99a00..edae7536 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -615,10 +615,10 @@ class RiskMetricsIterative(RiskMetricsBase): def update(self, dt, algorithm_returns, benchmark_returns): self.algorithm_returns_cont[dt] = algorithm_returns - self.algorithm_returns = self.algorithm_returns_cont.valid() + self.algorithm_returns = self.algorithm_returns_cont[:dt] self.benchmark_returns_cont[dt] = benchmark_returns - self.benchmark_returns = self.benchmark_returns_cont.valid() + self.benchmark_returns = self.benchmark_returns_cont[:dt] self.num_trading_days = len(self.algorithm_returns)