def test_order_denied(self):
        # Arrange
        uuid = uuid4()
        event = OrderDenied(
            cl_ord_id=ClientOrderId("O-2020872378423"),
            reason="SINGLE_ORDER_RISK_EXCEEDED",
            event_id=uuid,
            event_timestamp=UNIX_EPOCH,
        )

        # Act
        assert f"OrderDenied(cl_ord_id=O-2020872378423, reason='SINGLE_ORDER_RISK_EXCEEDED', event_id={uuid})", str(
            event)
        assert f"OrderDenied(cl_ord_id=O-2020872378423, reason='SINGLE_ORDER_RISK_EXCEEDED', event_id={uuid})", repr(
            event)
    def test_serialize_and_deserialize_order_denied_events(self):
        # Arrange
        event = OrderDenied(
            ClientOrderId("O-123456"),
            "Exceeds risk for FX",
            uuid4(),
            0,
        )

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

        # Assert
        assert deserialized == event
    def test_order_denied(self):
        # Arrange
        uuid = uuid4()
        event = OrderDenied(
            client_order_id=ClientOrderId("O-2020872378423"),
            reason="SINGLE_ORDER_RISK_EXCEEDED",
            event_id=uuid,
            timestamp_ns=0,
        )

        # Act
        assert f"OrderDenied(client_order_id=O-2020872378423, reason=SINGLE_ORDER_RISK_EXCEEDED, event_id={uuid})", (
            str(event))
        assert f"OrderDenied(client_order_id=O-2020872378423, reason=SINGLE_ORDER_RISK_EXCEEDED, event_id={uuid})", (
            repr(event))
Exemple #4
0
    def test_apply_order_denied_event(self):
        # Arrange
        order = self.order_factory.market(
            AUDUSD_SIM.symbol,
            OrderSide.BUY,
            Quantity(100000),
        )

        denied = OrderDenied(
            order.cl_ord_id,
            "SOME_REASON",
            uuid4(),
            UNIX_EPOCH,
        )

        # Act
        order.apply(denied)

        # Assert
        self.assertEqual(OrderState.DENIED, order.state)
        self.assertEqual(2, order.event_count)
        self.assertEqual(denied, order.last_event)
        self.assertTrue(order.is_completed)