From 823416e9fdcfacb888f54f8bd8da7abbd013aa03 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Thu, 2 May 2013 14:36:10 -0400 Subject: [PATCH] MAINT: Remove unecessary conversion to Series on each risk update. We were converting to pd.Series for historical reasons as an artifact during development, now that we pass dt we can just pass the float values instead of wrapping it in a series. --- zipline/finance/performance.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index f3178edd..02e7785f 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -299,12 +299,9 @@ class PerformanceTracker(object): def handle_minute_close(self, dt): #update risk metrics for cumulative performance - algorithm_returns = pd.Series({dt: self.todays_performance.returns}) - benchmark_returns = pd.Series({dt: self.all_benchmark_returns[dt]}) - self.cumulative_risk_metrics.update(dt, - algorithm_returns, - benchmark_returns) + self.todays_performance.returns, + self.all_benchmark_returns[dt]) def handle_market_close(self): # add the return results from today to the list of DailyReturn objects. @@ -320,15 +317,10 @@ class PerformanceTracker(object): self.returns.append(todays_return_obj) #update risk metrics for cumulative performance - algorithm_returns = pd.Series({todays_return_obj.date: - todays_return_obj.returns}) - benchmark_returns = pd.Series({ - todays_return_obj.date: - self.all_benchmark_returns[todays_return_obj.date]}) - - self.cumulative_risk_metrics.update(todays_return_obj.date, - algorithm_returns, - benchmark_returns) + self.cumulative_risk_metrics.update( + todays_return_obj.date, + todays_return_obj.returns, + self.all_benchmark_returns[todays_return_obj.date]) # increment the day counter before we move markers forward. self.day_count += 1.0