示例#1
0
    def test_checks_should_trigger(self):
        class CountingRule(Always):
            count = 0

            def should_trigger(self, dt):
                CountingRule.count += 1
                return True

        for r in [CountingRule] * 5:
            self.em.add_event(Event(r()))

        self.em.handle_data(None, None, datetime.datetime.now())
        assert CountingRule.count == 5
示例#2
0
    def test_checks_should_trigger(self):
        class CountingRule(Always):
            count = 0

            def should_trigger(self, dt):
                CountingRule.count += 1
                return True

        for r in [CountingRule] * 5:
            self.em.add_event(
                Event(r(), lambda context, data: None, check_args=False))

        self.em.handle_data(None, None, datetime.datetime.now())

        self.assertEqual(CountingRule.count, 5)
示例#3
0
    def test_checks_should_trigger(self):
        class CountingRule(Always):
            count = 0

            def should_trigger(self, dt, env):
                CountingRule.count += 1
                return True

        for r in [CountingRule] * 5:
            self.em.add_event(Event(r(), lambda context, data: None))

        mock_algo_class = namedtuple('FakeAlgo', ['trading_environment'])
        mock_algo = mock_algo_class(trading_environment="fake_env")
        self.em.handle_data(mock_algo, None, datetime.datetime.now())

        self.assertEqual(CountingRule.count, 5)
示例#4
0
 def setUp(self):
     self.em = EventManager()
     self.event1 = Event(Always(), lambda context, data: None)
     self.event2 = Event(Always(), lambda context, data: None)
示例#5
0
 def setUp(self):
     self.em = EventManager()
     self.event1 = Event(Always())
     self.event2 = Event(Always())
示例#6
0
def set_event_manager(request):
    request.cls.em = EventManager()
    request.cls.event1 = Event(Always())
    request.cls.event2 = Event(Always())