BUG: DAY_END action not emitted during minute emission

Refactor AlgorithmSimulator so that DAY_END is emitted for both
minute and daily emission, and that handling of end-of-minute
and end-of-day are separated
This commit is contained in:
Andrew Liang
2016-04-29 17:57:06 -04:00
committed by Jean Bredeche
parent a068eb374a
commit 7641247b41
5 changed files with 57 additions and 56 deletions
+13 -6
View File
@@ -2571,7 +2571,7 @@ class TestOrderCancelation(WithDataPortal,
)
def prep_algo(self, cancelation_string, data_frequency="minute",
amount=1000):
amount=1000, minute_emission=False):
code = self.code.format(cancelation_string, amount)
algo = TradingAlgorithm(
script=code,
@@ -2580,21 +2580,28 @@ class TestOrderCancelation(WithDataPortal,
period_start=self.sim_params.period_start,
period_end=self.sim_params.period_end,
env=self.env,
data_frequency=data_frequency
data_frequency=data_frequency,
emission_rate='minute' if minute_emission else 'daily'
)
)
return algo
@parameterized.expand([
(1,), (-1,),
])
def test_eod_order_cancel_minute(self, direction):
@parameter_space(
direction=[1, -1],
minute_emission=[True, False]
)
def test_eod_order_cancel_minute(self, direction, minute_emission):
"""
Test that EOD order cancel works in minute mode for both shorts and
longs, and both daily emission and minute emission
"""
# order 1000 shares of asset1. the volume is only 1 share per bar,
# so the order should be cancelled at the end of the day.
algo = self.prep_algo(
"set_cancel_policy(cancel_policy.EODCancel())",
amount=np.copysign(1000, direction),
minute_emission=minute_emission
)
log_catcher = TestHandler()