Beispiel #1
0
    def test_can_apply_order_cancel_reject_event_to_order(self):
        # Arrange
        order = self.order_factory.market(AUDUSD_FXCM, OrderSide.BUY,
                                          Quantity(100000))

        event = OrderCancelReject(self.account_id, order.id, UNIX_EPOCH,
                                  ValidString('REJECT_RESPONSE'),
                                  ValidString('ORDER DOES NOT EXIST'),
                                  GUID(uuid.uuid4()), UNIX_EPOCH)

        # Act
        order.apply(event)

        # Assert
        self.assertEqual(OrderState.INITIALIZED, order.state)
    def test_serialize_and_deserialize_order_cancel_reject_events(self):
        # Arrange
        event = OrderCancelReject(
            self.account_id,
            ClientOrderId("O-123456"),
            UNIX_EPOCH,
            "RESPONSE",
            "ORDER_DOES_NOT_EXIST",
            uuid4(),
            UNIX_EPOCH,
        )

        # Act
        serialized = self.serializer.serialize(event)
        deserialized = self.serializer.deserialize(serialized)

        # Assert
        self.assertEqual(deserialized, event)
Beispiel #3
0
    def test_order_cancel_reject(self):
        # Arrange
        uuid = uuid4()
        event = OrderCancelReject(
            account_id=AccountId("SIM", "000"),
            cl_ord_id=ClientOrderId("O-2020872378423"),
            order_id=OrderId("123456"),
            rejected_time=UNIX_EPOCH,
            response_to="O-2020872378423",
            reason="ORDER_DOES_NOT_EXIST",
            event_id=uuid,
            event_timestamp=UNIX_EPOCH,
        )

        # Act
        self.assertEqual(f"OrderCancelReject(account_id=SIM-000, cl_ord_id=O-2020872378423, "
                         f"response_to=O-2020872378423, reason='ORDER_DOES_NOT_EXIST', "
                         f"event_id={uuid})", str(event))
        self.assertEqual(f"OrderCancelReject(account_id=SIM-000, cl_ord_id=O-2020872378423, "
                         f"response_to=O-2020872378423, reason='ORDER_DOES_NOT_EXIST', "
                         f"event_id={uuid})", repr(event))