mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 07:53:46 +08:00
fixed catastrophic bug in load_from_directory
and added a new test case was not iterating over lookup date directory names, and therefore mising all by one list of stocks. discovered because of differing sort orders between my local machine, other devs, and travis ci.
This commit is contained in:
@@ -94,6 +94,7 @@ class SecurityListTestCase(TestCase):
|
||||
|
||||
self.assertIn("BZQ", rl.leveraged_etf_list)
|
||||
self.assertIn("URTY", rl.leveraged_etf_list)
|
||||
self.assertIn("JFT", rl.leveraged_etf_list)
|
||||
|
||||
# assert that a sample of allowed stocks are not in restricted
|
||||
# AAPL
|
||||
@@ -178,6 +179,26 @@ class SecurityListTestCase(TestCase):
|
||||
|
||||
self.check_algo_exception(algo, ctx, 0)
|
||||
|
||||
# repeat with a symbol from a different lookup date
|
||||
|
||||
trade_history = factory.create_trade_history(
|
||||
'JFT',
|
||||
[10.0, 10.0, 11.0, 11.0],
|
||||
[100, 100, 100, 300],
|
||||
timedelta(days=1),
|
||||
sim_params
|
||||
)
|
||||
self.source = SpecificEquityTrades(event_list=trade_history)
|
||||
|
||||
self.df_source, self.df = \
|
||||
factory.create_test_df_source(sim_params)
|
||||
|
||||
algo = RestrictedAlgoWithoutCheck(sid='JFT', sim_params=sim_params)
|
||||
with self.assertRaises(TradingControlViolation) as ctx:
|
||||
algo.run(self.source)
|
||||
|
||||
self.check_algo_exception(algo, ctx, 0)
|
||||
|
||||
def test_algo_with_rl_violation_on_knowledge_date(self):
|
||||
|
||||
sim_params = factory.create_simulation_parameters(
|
||||
|
||||
@@ -127,8 +127,8 @@ def load_from_directory(list_name):
|
||||
tzinfo=pytz.utc)
|
||||
data[kd] = {}
|
||||
kd_path = os.path.join(dir_path, kd_name)
|
||||
for ld_name in listdir(os.path.join(dir_path, kd_name)):
|
||||
ld = datetime.strptime(kd_name, DATE_FORMAT).replace(
|
||||
for ld_name in listdir(kd_path):
|
||||
ld = datetime.strptime(ld_name, DATE_FORMAT).replace(
|
||||
tzinfo=pytz.utc)
|
||||
data[kd][ld] = {}
|
||||
ld_path = os.path.join(kd_path, ld_name)
|
||||
|
||||
Reference in New Issue
Block a user