Exemplo n.º 1
0
    def test_add_order_state_report(self):
        # Arrange
        report = ExecutionMassStatus(
            client_id=ClientId("IB"),
            account_id=TestStubs.account_id(),
            timestamp_ns=0,
        )

        venue_order_id = VenueOrderId("1")
        order_report = OrderStatusReport(
            client_order_id=ClientOrderId("O-123456"),
            venue_order_id=venue_order_id,
            order_state=OrderState.REJECTED,
            filled_qty=Quantity.zero(),
            timestamp_ns=0,
        )

        # Act
        report.add_order_report(order_report)

        # Assert
        assert report.order_reports()[venue_order_id] == order_report
        assert (
            repr(report) ==
            "ExecutionMassStatus(client_id=IB, account_id=SIM-000, timestamp_ns=0, order_reports={VenueOrderId('1'): OrderStatusReport(client_order_id=O-123456, venue_order_id=1, order_state=REJECTED, filled_qty=0, timestamp_ns=0)}, exec_reports={}, position_reports={})"  # noqa
        )
        assert (
            repr(order_report) ==
            "OrderStatusReport(client_order_id=O-123456, venue_order_id=1, order_state=REJECTED, filled_qty=0, timestamp_ns=0)"  # noqa
        )
    def test_instantiate_report(self):
        # Arrange
        client = "IB"
        account_id = TestStubs.account_id()

        # Act
        report = ExecutionMassStatus(
            client=client,
            account_id=account_id,
            timestamp_ns=0,
        )

        # Assert
        assert report.client == client
        assert report.account_id == account_id
        assert report.timestamp_ns == 0
        assert report.order_reports() == {}
        assert report.position_reports() == {}
    def test_add_order_state_report(self):
        # Arrange
        report = ExecutionMassStatus(
            client="IB",
            account_id=TestStubs.account_id(),
            timestamp_ns=0,
        )

        venue_order_id = VenueOrderId("1")
        order_report = OrderStatusReport(
            client_order_id=ClientOrderId("O-123456"),
            venue_order_id=venue_order_id,
            order_state=OrderState.REJECTED,
            filled_qty=Quantity(0),
            timestamp_ns=0,
        )

        # Act
        report.add_order_report(order_report)

        # Assert
        assert report.order_reports()[venue_order_id] == order_report
Exemplo n.º 4
0
    def test_instantiate_execution_mass_status_report(self):
        # Arrange
        client_id = ClientId("IB")
        account_id = TestStubs.account_id()

        # Act
        report = ExecutionMassStatus(
            client_id=client_id,
            account_id=account_id,
            timestamp_ns=0,
        )

        # Assert
        assert report.client_id == client_id
        assert report.account_id == account_id
        assert report.timestamp_ns == 0
        assert report.order_reports() == {}
        assert report.position_reports() == {}
        assert (
            repr(report) ==
            "ExecutionMassStatus(client_id=IB, account_id=SIM-000, timestamp_ns=0, order_reports={}, exec_reports={}, position_reports={})"  # noqa
        )  # noqa