Exemple #1
0
 def event_order_rejected(order) -> OrderRejected:
     return OrderRejected(
         TestStubs.account_id(),
         order.cl_ord_id,
         UNIX_EPOCH,
         "ORDER_REJECTED",
         uuid4(),
         UNIX_EPOCH,
     )
Exemple #2
0
 def event_order_rejected(order) -> OrderRejected:
     return OrderRejected(
         TestStubs.account_id(),
         order.client_order_id,
         0,
         "ORDER_REJECTED",
         uuid4(),
         0,
     )
 def event_order_rejected(order) -> OrderRejected:
     return OrderRejected(
         account_id=TestStubs.account_id(),
         client_order_id=order.client_order_id,
         reason="ORDER_REJECTED",
         ts_rejected_ns=0,
         event_id=uuid4(),
         timestamp_ns=0,
     )
Exemple #4
0
    def test_can_apply_order_rejected_event_to_order(self):
        # Arrange
        order = self.order_factory.market(AUDUSD_FXCM, OrderSide.BUY,
                                          Quantity(100000))

        event = OrderRejected(self.account_id, order.id, UNIX_EPOCH,
                              ValidString('ORDER ID INVALID'),
                              GUID(uuid.uuid4()), UNIX_EPOCH)

        # Act
        order.apply(event)

        # Assert
        self.assertEqual(OrderState.REJECTED, order.state)
        self.assertTrue(order.is_completed)
    def test_order_rejected(self):
        # Arrange
        uuid = uuid4()
        event = OrderRejected(
            account_id=AccountId("SIM", "000"),
            cl_ord_id=ClientOrderId("O-2020872378423"),
            rejected_time=UNIX_EPOCH,
            reason="INSUFFICIENT_MARGIN",
            event_id=uuid,
            event_timestamp=UNIX_EPOCH,
        )

        # Act
        assert f"OrderRejected(account_id=SIM-000, cl_ord_id=O-2020872378423, reason='INSUFFICIENT_MARGIN', event_id={uuid})", str(
            event)  # noqa
        assert f"OrderRejected(account_id=SIM-000, cl_ord_id=O-2020872378423, reason='INSUFFICIENT_MARGIN', event_id={uuid})", repr(
            event)  # noqa
    def test_serialize_and_deserialize_order_rejected_events(self):
        # Arrange
        event = OrderRejected(
            self.account_id,
            ClientOrderId("O-123456"),
            "ORDER_ID_INVALID",
            0,
            uuid4(),
            0,
        )

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

        # Assert
        assert deserialized == event