def test_handle_data_when_running_sends_to_on_data(self): # Arrange actor = MockActor() actor.register_base( trader_id=self.trader_id, msgbus=self.msgbus, cache=self.cache, clock=self.clock, logger=self.logger, ) actor.start() data = NewsEvent( impact=NewsImpact.HIGH, name="Unemployment Rate", currency=USD, ts_event=0, ts_init=0, ) # Act actor.handle_data(data) # Assert assert actor.calls == ["on_start", "on_data"] assert actor.object_storer.get_store()[0] == data
def test_start(self): # Arrange actor = MockActor() actor.register_base( trader_id=self.trader_id, msgbus=self.msgbus, cache=self.cache, clock=self.clock, logger=self.logger, ) # Act actor.start() # Assert assert "on_start" in actor.calls assert actor.state == ComponentState.RUNNING
def test_handle_instrument_when_running_sends_to_on_instrument(self): # Arrange actor = MockActor() actor.register_base( trader_id=self.trader_id, msgbus=self.msgbus, cache=self.cache, clock=self.clock, logger=self.logger, ) actor.start() # Act actor.handle_instrument(AUDUSD_SIM) # Assert assert actor.calls == ["on_start", "on_instrument"] assert actor.object_storer.get_store()[0] == AUDUSD_SIM
def test_handle_quote_tick_when_running_sends_to_on_quote_tick(self): # Arrange actor = MockActor() actor.register_base( trader_id=self.trader_id, msgbus=self.msgbus, cache=self.cache, clock=self.clock, logger=self.logger, ) actor.start() tick = TestDataStubs.quote_tick_5decimal(AUDUSD_SIM.id) # Act actor.handle_quote_tick(tick) # Assert assert actor.calls == ["on_start", "on_quote_tick"] assert actor.object_storer.get_store()[0] == tick
def test_handle_bar_when_running_sends_to_on_bar(self): # Arrange actor = MockActor() actor.register_base( trader_id=self.trader_id, msgbus=self.msgbus, cache=self.cache, clock=self.clock, logger=self.logger, ) actor.start() bar = TestDataStubs.bar_5decimal() # Act actor.handle_bar(bar) # Assert assert actor.calls == ["on_start", "on_bar"] assert actor.object_storer.get_store()[0] == bar