BUG: Ensure compounded_log_returns set on first dt.

This commit is contained in:
John Ricklefs
2013-10-11 12:13:32 -04:00
parent d177ddd860
commit 9ac180d4bb
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -110,3 +110,9 @@ class TestRisk(unittest.TestCase):
value,
decimal=2,
err_msg="Mismatch at %s" % (dt,))
def test_max_drawdown_calculated(self):
# We don't track max_drawdown by day, so it doesn't make sense to
# generate a full answer key for it. For now, ensure it's just
# "not zero"
self.assertNotEqual(self.cumulative_metrics_06.max_drawdown, 0.0)
+1 -1
View File
@@ -406,7 +406,7 @@ algorithm_returns ({algo_count}) in range {start} : {end} on {dt}"
compound = 0.0
# BUG? Shouldn't this be set to log(1.0 + 0) ?
if len(self.compounded_log_returns[:self.latest_dt]) == 0:
if np.isnan(self.compounded_log_returns[self.latest_dt]):
self.compounded_log_returns[self.latest_dt] = compound
else:
self.compounded_log_returns[self.latest_dt] = \