From 701687b812be6172699022d0c91217b98a9858ed Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 4 Apr 2012 11:37:19 -0400 Subject: [PATCH 1/2] fixed bug where year report list included months instead. added a period_label to risk metrics corresponding to the end date. e.g. April 2006 --- zipline/finance/risk.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index 06a683b4..ab2d10f3 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -123,6 +123,7 @@ class RiskMetrics(): Creates a dictionary representing the state of the risk report. Returns a dict object of the form: """ + period_label = self.end_date.strftime("%B %Y") return { 'trading_days' : self.trading_days, 'benchmark_volatility' : self.benchmark_volatility, @@ -134,7 +135,8 @@ class RiskMetrics(): 'beta' : self.beta, 'alpha' : self.alpha, 'excess_return' : self.excess_return, - 'max_drawdown' : self.max_drawdown + 'max_drawdown' : self.max_drawdown, + 'period_label' : period_label } def __repr__(self): @@ -345,7 +347,7 @@ class RiskReport(): '1_month' : [x.to_dict() for x in self.month_periods], '3_month' : [x.to_dict() for x in self.three_month_periods], '6_month' : [x.to_dict() for x in self.six_month_periods], - '12_month' : [x.to_dict() for x in self.month_periods] + '12_month' : [x.to_dict() for x in self.year_periods] } def periodsInRange(self, months_per, start, end): From 4adf8ff854fb95fb1b3693f1d73b4a0d9d1e6755 Mon Sep 17 00:00:00 2001 From: fawce Date: Wed, 4 Apr 2012 17:01:49 -0400 Subject: [PATCH 2/2] changes risk report period label to YYYY-MM format --- zipline/finance/risk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipline/finance/risk.py b/zipline/finance/risk.py index ab2d10f3..413383b0 100644 --- a/zipline/finance/risk.py +++ b/zipline/finance/risk.py @@ -123,7 +123,7 @@ class RiskMetrics(): Creates a dictionary representing the state of the risk report. Returns a dict object of the form: """ - period_label = self.end_date.strftime("%B %Y") + period_label = self.end_date.strftime("%Y-%m") return { 'trading_days' : self.trading_days, 'benchmark_volatility' : self.benchmark_volatility,