From 7ecf544d15919800fa28a7641f09cad27608d952 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 7 Feb 2014 21:31:33 -0500 Subject: [PATCH] BUG: Fix repr for cumulative risk metrics. The __repr__ for RiskMetricsCumulative was referring to an older structure of the class, causing an exception when printed. Convert to printing the last values in the metrics DataFrame. --- zipline/finance/risk/cumulative.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/zipline/finance/risk/cumulative.py b/zipline/finance/risk/cumulative.py index 47a12bb4..4c832543 100644 --- a/zipline/finance/risk/cumulative.py +++ b/zipline/finance/risk/cumulative.py @@ -365,25 +365,8 @@ algorithm_returns ({algo_count}) in range {start} : {end} on {dt}" def __repr__(self): statements = [] - metrics = [ - "algorithm_period_returns", - "benchmark_period_returns", - "excess_returns", - "trading_days", - "benchmark_volatility", - "algorithm_volatility", - "sharpe", - "sortino", - "information", - "beta", - "alpha", - "max_drawdown", - "algorithm_returns", - "benchmark_returns", - ] - - for metric in metrics: - value = getattr(self, metric) + for metric in self.METRIC_NAMES: + value = getattr(self.metrics, metric)[-1] if isinstance(value, list): if len(value) == 0: value = np.nan