def event_order_cancelled(order) -> OrderCancelled: return OrderCancelled( TestStubs.account_id(), order.client_order_id, order.venue_order_id, 0, uuid4(), 0, )
def event_order_cancelled(order) -> OrderCancelled: return OrderCancelled( TestStubs.account_id(), order.cl_ord_id, OrderId("1"), UNIX_EPOCH, uuid4(), UNIX_EPOCH, )
def test_can_apply_order_cancelled_event_to_order(self): # Arrange order = self.order_factory.market(AUDUSD_FXCM, OrderSide.BUY, Quantity(100000)) event = OrderCancelled(self.account_id, order.id, UNIX_EPOCH, GUID(uuid.uuid4()), UNIX_EPOCH) # Act order.apply(event) # Assert self.assertEqual(OrderState.CANCELLED, order.state) self.assertTrue(order.is_completed)
def test_serialize_and_deserialize_order_cancelled_events(self): # Arrange event = OrderCancelled( self.account_id, ClientOrderId("O-123456"), OrderId("1"), UNIX_EPOCH, uuid4(), UNIX_EPOCH, ) # Act serialized = self.serializer.serialize(event) deserialized = self.serializer.deserialize(serialized) # Assert self.assertEqual(deserialized, event)
def test_serialize_and_deserialize_order_cancelled_events(self): # Arrange event = OrderCancelled( self.account_id, ClientOrderId("O-123456"), VenueOrderId("1"), 0, uuid4(), 0, ) # Act serialized = self.serializer.serialize(event) deserialized = self.serializer.deserialize(serialized) # Assert assert deserialized == event
def test_order_cancelled(self): # Arrange uuid = uuid4() event = OrderCancelled( account_id=AccountId("SIM", "000"), cl_ord_id=ClientOrderId("O-2020872378423"), order_id=OrderId("123456"), cancelled_time=UNIX_EPOCH, event_id=uuid, event_timestamp=UNIX_EPOCH, ) # Act self.assertEqual(f"OrderCancelled(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, event_id={uuid})", str(event)) self.assertEqual(f"OrderCancelled(account_id=SIM-000, cl_ord_id=O-2020872378423, " f"order_id=123456, event_id={uuid})", repr(event))
def test_order_cancelled(self): # Arrange uuid = uuid4() event = OrderCancelled( account_id=AccountId("SIM", "000"), client_order_id=ClientOrderId("O-2020872378423"), venue_order_id=VenueOrderId("123456"), cancelled_ns=0, event_id=uuid, timestamp_ns=0, ) # Act assert ( f"OrderCancelled(account_id=SIM-000, client_order_id=O-2020872378423, " f"venue_order_id=123456, event_id={uuid})" == str(event)) assert ( f"OrderCancelled(account_id=SIM-000, client_order_id=O-2020872378423, " f"venue_order_id=123456, event_id={uuid})" == repr(event))