def event_order_accepted(order) -> OrderAccepted: return OrderAccepted( TestStubs.account_id(), order.cl_ord_id, OrderId("1"), UNIX_EPOCH, uuid4(), UNIX_EPOCH, )
def event_order_accepted(order, venue_order_id=None) -> OrderAccepted: if venue_order_id is None: venue_order_id = VenueOrderId("1") return OrderAccepted( TestStubs.account_id(), order.client_order_id, venue_order_id, 0, uuid4(), 0, )
def event_order_accepted(order, order_id=None) -> OrderAccepted: if order_id is None: order_id = OrderId("1") return OrderAccepted( TestStubs.account_id(), order.cl_ord_id, order_id, UNIX_EPOCH, uuid4(), UNIX_EPOCH, )
def event_order_accepted(order, venue_order_id=None) -> OrderAccepted: if venue_order_id is None: venue_order_id = VenueOrderId("1") return OrderAccepted( account_id=TestStubs.account_id(), client_order_id=order.client_order_id, venue_order_id=venue_order_id, ts_accepted_ns=0, event_id=uuid4(), timestamp_ns=0, )
def test_can_apply_order_accepted_event_to_order(self): # Arrange order = self.order_factory.market(AUDUSD_FXCM, OrderSide.BUY, Quantity(100000)) event = OrderAccepted(self.account_id, order.id, OrderIdBroker('B' + order.id.value), Label('E'), UNIX_EPOCH, GUID(uuid.uuid4()), UNIX_EPOCH) # Act order.apply(event) # Assert self.assertEqual(OrderState.ACCEPTED, order.state) self.assertFalse(order.is_completed)
def test_serialize_and_deserialize_order_accepted_events(self): # Arrange event = OrderAccepted( self.account_id, ClientOrderId("O-123456"), VenueOrderId("B-123456"), 0, uuid4(), 0, ) # Act serialized = self.serializer.serialize(event) deserialized = self.serializer.deserialize(serialized) # Assert assert deserialized == event
def test_serialize_and_deserialize_order_accepted_events(self): # Arrange event = OrderAccepted( self.account_id, ClientOrderId("O-123456"), OrderId("B-123456"), UNIX_EPOCH, uuid4(), UNIX_EPOCH, ) # Act serialized = self.serializer.serialize(event) deserialized = self.serializer.deserialize(serialized) # Assert self.assertEqual(deserialized, event)
def test_order_accepted(self): # Arrange uuid = uuid4() event = OrderAccepted( account_id=AccountId("SIM", "000"), cl_ord_id=ClientOrderId("O-2020872378423"), order_id=OrderId("123456"), accepted_time=UNIX_EPOCH, event_id=uuid, event_timestamp=UNIX_EPOCH, ) # Act self.assertEqual( f"OrderAccepted(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id={123456}, id={uuid})", str(event)) # noqa self.assertEqual( f"OrderAccepted(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id={123456}, id={uuid})", repr(event)) # noqa
def test_order_accepted(self, order_id=None): if order_id is None: order_id = OrderId("123456") # Arrange uuid = uuid4() event = OrderAccepted( account_id=AccountId("SIM", "000"), cl_ord_id=ClientOrderId("O-2020872378423"), order_id=order_id, accepted_time=UNIX_EPOCH, event_id=uuid, event_timestamp=UNIX_EPOCH, ) # Act assert f"OrderAccepted(account_id=SIM-000, cl_ord_id=O-2020872378423, order_id={123456}, event_id={uuid})", str( event) # noqa assert f"OrderAccepted(account_id=SIM-000, cl_ord_id=O-2020872378423, order_id={123456}, event_id={uuid})", repr( event) # noqa
def test_order_accepted(self, venue_order_id=None): if venue_order_id is None: venue_order_id = VenueOrderId("123456") # Arrange uuid = uuid4() event = OrderAccepted( account_id=AccountId("SIM", "000"), client_order_id=ClientOrderId("O-2020872378423"), venue_order_id=venue_order_id, accepted_ns=0, event_id=uuid, timestamp_ns=0, ) # Act assert f"OrderAccepted(account_id=SIM-000, client_order_id=O-2020872378423, venue_order_id={123456}, event_id={uuid})", str( event) # noqa assert f"OrderAccepted(account_id=SIM-000, client_order_id=O-2020872378423, venue_order_id={123456}, event_id={uuid})", repr( event) # noqa