From 3d5e084b8d5c9e6200e53905b694c757941c637a Mon Sep 17 00:00:00 2001 From: fawce Date: Thu, 5 Jul 2012 16:17:51 -0400 Subject: [PATCH] fixed logic bug in creation of sample date range. added assert. --- tests/test_perf_tracking.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index d979473d..1a77818c 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -16,11 +16,13 @@ class PerformanceTestCase(unittest.TestCase): self.benchmark_returns, self.treasury_curves = \ factory.load_market_data() - random_index = random.randint( - 0, - len(self.treasury_curves) - ) for n in range(100): + + random_index = random.randint( + 0, + len(self.treasury_curves) + ) + self.dt = self.treasury_curves.keys()[random_index] self.end_dt = self.dt + datetime.timedelta(days=365) @@ -29,6 +31,10 @@ class PerformanceTestCase(unittest.TestCase): if self.end_dt <= now: break + assert self.end_dt <= now, """ +failed to find a date suitable daterange after 100 attempts. please double +check treasury and benchmark data in findb, and re-run the test.""" + self.trading_environment = TradingEnvironment( self.benchmark_returns, self.treasury_curves,