From 63dbea5da430dea824cb258afa98c7c4e5695ab2 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 28 Apr 2015 14:23:07 -0400 Subject: [PATCH] ENH: Remove unused minute risk containers. The risk containers that are actually used for reports use the 'cumulative' style container which has an index of days, not minutes. The minute containers and copying of data etc. were causing an expanding memory footprint. --- zipline/finance/performance/tracker.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/zipline/finance/performance/tracker.py b/zipline/finance/performance/tracker.py index a60956e8..3f1451aa 100644 --- a/zipline/finance/performance/tracker.py +++ b/zipline/finance/performance/tracker.py @@ -116,7 +116,6 @@ class PerformanceTracker(object): if self.emission_rate == 'daily': self.all_benchmark_returns = pd.Series( index=self.trading_days) - self.intraday_risk_metrics = None self.cumulative_risk_metrics = \ risk.RiskMetricsCumulative(self.sim_params) @@ -124,8 +123,6 @@ class PerformanceTracker(object): self.all_benchmark_returns = pd.Series(index=pd.date_range( self.sim_params.first_open, self.sim_params.last_close, freq='Min')) - self.intraday_risk_metrics = \ - risk.RiskMetricsCumulative(self.sim_params) self.cumulative_risk_metrics = \ risk.RiskMetricsCumulative(self.sim_params, @@ -281,7 +278,6 @@ class PerformanceTracker(object): _dict.update({'daily_perf': self.todays_performance.to_dict()}) elif emission_type == 'minute': _dict.update({ - 'intraday_risk_metrics': self.intraday_risk_metrics.to_dict(), 'minute_perf': self.todays_performance.to_dict(self.saved_dt) }) @@ -401,22 +397,10 @@ class PerformanceTracker(object): todays_date = normalize_date(dt) account = self.get_account(True) - minute_returns = self.minute_performance.returns self.minute_performance.rollover() - # the intraday risk is calculated on top of minute performance - # returns for the bench and the algo - self.intraday_risk_metrics.update(dt, - minute_returns, - self.all_benchmark_returns[dt], - account) - # Duplicate intraday_risk_metrics work of calculating the benchmark - # returns since open. - # intraday_risk_metrics is marked for removal. - # - # This redundant work is in anticipation of no longer being able to - # depend on the 'since open' calculations in intraday_risk_metrics. bench_returns = self.all_benchmark_returns.loc[todays_date:dt] + # cumulative returns bench_since_open = (1. + bench_returns).prod() - 1 self.cumulative_risk_metrics.update(todays_date, @@ -436,10 +420,6 @@ class PerformanceTracker(object): Function called at market close only when emitting at minutely frequency. """ - # update_performance should have been called in handle_minute_close - # so it is not repeated here. - self.intraday_risk_metrics = \ - risk.RiskMetricsCumulative(self.sim_params) # increment the day counter before we move markers forward. self.day_count += 1.0 self.market_open = new_mkt_open