From e752dfacc95f8064ccb69959bd9ff3fc29f9bba3 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Fri, 19 Oct 2012 10:06:05 -0400 Subject: [PATCH] Changes answer key to benchmarks to match fresh data from Yahoo. This answer key needs to be verified with original calculations. Also, we may want to hardcode values in plain text to use for these tests, instead of relying on a full history. --- tests/test_risk.py | 170 +++++++++++++++++++++++---------------------- 1 file changed, 88 insertions(+), 82 deletions(-) diff --git a/tests/test_risk.py b/tests/test_risk.py index f54a33df..c3c2066d 100644 --- a/tests/test_risk.py +++ b/tests/test_risk.py @@ -109,41 +109,41 @@ class Risk(unittest.TestCase): self.assertEqual([round(x.benchmark_period_returns, 4) for x in metrics.month_periods], [0.0255, - 0.0005, - 0.0111, - 0.0122, - -0.0309, - 0.0001, - 0.0051, - 0.0213, - 0.0246, - 0.0315, - 0.0165, - 0.0126]) + 0.0004, + 0.0110, + 0.0057, + -0.0290, + 0.0021, + 0.0061, + 0.0221, + 0.0247, + 0.0324, + 0.0189, + 0.0139]) self.assertEqual([round(x.benchmark_period_returns, 4) for x in metrics.three_month_periods], - [0.0373, - 0.0239, - -0.0083, - -0.0191, - -0.0259, - 0.0266, - 0.0517, - 0.0793, - 0.0743, - 0.0617]) + [0.0372, + 0.0171, + -0.0128, + -0.0214, + -0.0211, + 0.0305, + 0.0537, + 0.0813, + 0.0780, + 0.0666]) self.assertEqual([round(x.benchmark_period_returns, 4) for x in metrics.six_month_periods], - [0.0176, - -0.0027, - 0.0181, - 0.0316, - 0.0514, - 0.1028, - 0.1166]) + [0.015, + -0.0043, + 0.0173, + 0.0311, + 0.0586, + 0.1108, + 0.1239]) self.assertEqual([round(x.benchmark_period_returns, 4) for x in metrics.year_periods], - [0.1362]) + [0.1407]) def test_trading_days_06(self): returns = factory.create_returns_from_range(self.trading_env) @@ -166,7 +166,7 @@ class Risk(unittest.TestCase): 0.047, 0.039, 0.022, - 0.023, + 0.022, 0.021, 0.025, 0.019]) @@ -174,7 +174,7 @@ class Risk(unittest.TestCase): self.assertEqual([round(x.benchmark_volatility, 3) for x in metrics.three_month_periods], [0.047, - 0.042, + 0.043, 0.050, 0.064, 0.070, @@ -515,45 +515,45 @@ class Risk(unittest.TestCase): for x in metrics.month_periods] self.assertEqual(monthly, - [-0.061, - -0.035, - -0.006, - 0.048, + [-0.051, + -0.039, + 0.001, + 0.043, 0.011, - -0.086, - -0.01, - 0.012, - -0.091, - -0.169, -0.075, - 0.008]) + -0.007, + 0.026, + -0.093, + -0.160, + -0.072, + 0.009]) self.assertEqual([round(x.benchmark_period_returns, 3) for x in metrics.three_month_periods], - [-0.099, - 0.005, - 0.052, - -0.032, - -0.085, - -0.084, - -0.089, - -0.236, - -0.301, - -0.226]) + [-0.087, + 0.003, + 0.055, + -0.026, + -0.072, + -0.058, + -0.075, + -0.218, + -0.293, + -0.214]) self.assertEqual([round(x.benchmark_period_returns, 3) for x in metrics.six_month_periods], - [-0.128, - -0.081, - -0.036, - -0.118, - -0.301, - -0.360, - -0.294]) + [-0.110, + -0.069, + -0.006, + -0.099, + -0.274, + -0.334, + -0.273]) self.assertEqual([round(x.benchmark_period_returns, 3) for x in metrics.year_periods], - [-0.385]) + [-0.353]) def test_trading_days_08(self): returns = factory.create_returns_from_range(self.trading_env08) @@ -569,41 +569,47 @@ class Risk(unittest.TestCase): metrics = risk.RiskReport(returns, self.trading_env08) self.assertEqual([round(x.benchmark_volatility, 3) for x in metrics.month_periods], - [0.07, - 0.058, - 0.082, - 0.054, - 0.041, - 0.057, + [0.069, + 0.056, + 0.080, + 0.049, + 0.040, + 0.052, 0.068, - 0.06, - 0.157, - 0.244, - 0.195, - 0.145]) + 0.055, + 0.150, + 0.230, + 0.188, + 0.137]) self.assertEqual([round(x.benchmark_volatility, 3) for x in metrics.three_month_periods], - [0.120, - 0.113, - 0.105, - 0.09, - 0.098, - 0.107, - 0.179, - 0.293, - 0.344, - 0.340]) + [0.118, + 0.108, + 0.101, + 0.083, + 0.094, + 0.102, + 0.172, + 0.277, + 0.328, + 0.323]) self.assertEqual([round(x.benchmark_volatility, 3) for x in metrics.six_month_periods], - [0.15, 0.149, 0.15, 0.2, 0.308, 0.36, 0.383]) + [0.144, + 0.143, + 0.143, + 0.190, + 0.292, + 0.342, + 0.364]) # TODO: ugly, but I can't get the rounded float to match. # maybe we need a different test that checks the # difference between the numbers self.assertEqual([round(x.benchmark_volatility, 3) for x in metrics.year_periods], - [0.41099999999999998]) + [0.391]) def test_treasury_returns_06(self): returns = factory.create_returns_from_range(self.trading_env)