def test_NDaysBeforeLastTradingDayOfMonth(self, n): cal = get_calendar('NYSE') rule = NDaysBeforeLastTradingDayOfMonth(n) rule.cal = cal should_trigger = rule.should_trigger for n_days_before, d in enumerate(reversed(self.sept_days)): for m in self.nyse_cal.trading_minutes_for_day(d): if should_trigger(m): self.assertEqual(n_days_before, n) else: self.assertNotEqual(n_days_before, n)
def test_NDaysBeforeLastTradingDayOfMonth(self, n): cal = get_calendar('NYSE') rule = NDaysBeforeLastTradingDayOfMonth(n) rule.cal = cal should_trigger = rule.should_trigger for n_days_before, session in enumerate(reversed(self.oct_sessions)): for m in self.nyse_cal.minutes_for_session(session): if should_trigger(m): self.assertEqual(n_days_before, n) else: self.assertNotEqual(n_days_before, n)
def test_NDaysBeforeLastTradingDayOfMonth(self): for n in range(MAX_MONTH_RANGE): rule = NDaysBeforeLastTradingDayOfMonth(n) rule.cal = self.cal should_trigger = rule.should_trigger sessions = reversed(self.oct_sessions) for n_days_before, session in enumerate(sessions): for m in self.cal.minutes_for_session(session)[0:10]: if should_trigger(m): self.assertEqual(n_days_before, n) else: self.assertNotEqual(n_days_before, n)
def test_NDaysBeforeLastTradingDayOfMonth(self, n): should_trigger = NDaysBeforeLastTradingDayOfMonth(n).should_trigger for n_days_before, d in enumerate(reversed(self.sept_days)): for m in self.env.market_minutes_for_day(d): if should_trigger(m): self.assertEqual(n_days_before, n) else: self.assertNotEqual(n_days_before, n)