BUG: Symbol look-up now uses the sim_params.period_end as a look-up date

This commit is contained in:
jfkirk
2015-07-14 16:18:55 -04:00
committed by Stewart Douglas
parent de09433fd4
commit cf41373f8f
2 changed files with 7 additions and 6 deletions
+5 -5
View File
@@ -331,27 +331,27 @@ class TestMiscellaneousAPI(TestCase):
algo = TradingAlgorithm(asset_metadata=metadata)
# Test before either PLAY existed
algo.datetime = pd.Timestamp('2001-12-01', tz='UTC')
algo.sim_params.period_end = pd.Timestamp('2001-12-01', tz='UTC')
with self.assertRaises(SymbolNotFound):
algo.symbol('PLAY')
with self.assertRaises(SymbolNotFound):
algo.symbols('PLAY')
# Test when first PLAY exists
algo.datetime = pd.Timestamp('2002-12-01', tz='UTC')
algo.sim_params.period_end = pd.Timestamp('2002-12-01', tz='UTC')
list_result = algo.symbols('PLAY')
self.assertEqual(0, list_result[0])
# Test after first PLAY ends
algo.datetime = pd.Timestamp('2004-12-01', tz='UTC')
algo.sim_params.period_end = pd.Timestamp('2004-12-01', tz='UTC')
self.assertEqual(0, algo.symbol('PLAY'))
# Test after second PLAY begins
algo.datetime = pd.Timestamp('2005-12-01', tz='UTC')
algo.sim_params.period_end = pd.Timestamp('2005-12-01', tz='UTC')
self.assertEqual(1, algo.symbol('PLAY'))
# Test after second PLAY ends
algo.datetime = pd.Timestamp('2006-12-01', tz='UTC')
algo.sim_params.period_end = pd.Timestamp('2006-12-01', tz='UTC')
self.assertEqual(1, algo.symbol('PLAY'))
list_result = algo.symbols('PLAY')
self.assertEqual(1, list_result[0])
+2 -1
View File
@@ -695,7 +695,8 @@ class TradingAlgorithm(object):
"""
return self.asset_finder.lookup_symbol_resolve_multiple(
symbol_str,
as_of_date=self.datetime)
as_of_date=self.sim_params.period_end
)
@api_method
def symbols(self, *args):