From d067f13ba8cef2d1dd9e4e8598d597bf1e33d60f Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Wed, 24 Apr 2013 10:40:46 -0400 Subject: [PATCH] MAINT: Use a fake progress value for minute performance. Eventually should to either return None or remove progress completely, but in the meantime, return a constant of 1.0 for progress of minute emissions. Also, factor out the daily calculation into a property instead of calculating during process. --- zipline/finance/performance.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/zipline/finance/performance.py b/zipline/finance/performance.py index 6935543c..328c8fc4 100644 --- a/zipline/finance/performance.py +++ b/zipline/finance/performance.py @@ -202,13 +202,20 @@ class PerformanceTracker(object): self.day_count = 0.0 self.txn_count = 0 self.event_count = 0 - self.progress = 0.0 def __repr__(self): return "%s(%r)" % ( self.__class__.__name__, {'simulation parameters': self.sim_params}) + @property + def progress(self): + if self.emission_rate == 'minute': + # Fake a value + return 1.0 + elif self.emission_rate == 'daily': + return self.day_count / self.total_days + def transform(self, stream_in): """ Main generator work loop. @@ -258,13 +265,13 @@ class PerformanceTracker(object): 'period_end': self.period_end, 'capital_base': self.capital_base, 'cumulative_perf': self.cumulative_performance.to_dict(), + 'progress': self.progress } if emission_type == 'daily': _dict.update({'cumulative_risk_metrics': self.cumulative_risk_metrics.to_dict(), 'daily_perf': - self.todays_performance.to_dict(), - 'progress': self.progress}) + self.todays_performance.to_dict()}) if emission_type == 'minute': # Currently reusing 'todays_performance' for intraday trading # result, should be analogous, but has the potential for needing @@ -360,8 +367,6 @@ class PerformanceTracker(object): # increment the day counter before we move markers forward. self.day_count += 1.0 - # calculate progress of test - self.progress = self.day_count / self.total_days # Take a snapshot of our current peformance to return to the # browser.