From 702e6f00d2f00cd47590f75c347c3cfc7da22899 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Thu, 28 Mar 2013 18:59:39 -0400 Subject: [PATCH] MAINT: Use numpy for risk period returns. Following the lead of the RiskMetricsBatch conversion to use more pandas and numpy. Bringing the iterative and batch versions closer together as we work towards folding them into one. --- zipline/finance/risk.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index ef7f625d..b31af1a1 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -591,13 +591,8 @@ algorithm_returns ({algo_count}) in range {start} : {end}" ) def calculate_period_returns(self, returns): - period_returns = 1.0 - - for r in returns: - period_returns *= (1.0 + r) - - period_returns -= 1.0 - return period_returns + returns = np.array(returns) + return (1. + returns).prod() - 1 def update_current_max(self): if len(self.compounded_log_returns) == 0: