コード例 #1
0
    def test_from_dict_returns_expected_tick(self):
        # Arrange
        snapshot = OrderBookSnapshot(
            instrument_id=AUDUSD,
            level=BookLevel.L2,
            bids=[[1010, 2], [1009, 1]],
            asks=[[1020, 2], [1021, 1]],
            ts_event_ns=0,
            ts_recv_ns=0,
        )

        # Act
        result = OrderBookSnapshot.from_dict(
            OrderBookSnapshot.to_dict(snapshot))

        # Assert
        assert result == snapshot
コード例 #2
0
    def test_to_dict_returns_expected_dict(self):
        # Arrange
        snapshot = OrderBookSnapshot(
            instrument_id=AUDUSD,
            level=BookLevel.L2,
            bids=[[1010, 2], [1009, 1]],
            asks=[[1020, 2], [1021, 1]],
            ts_event_ns=0,
            ts_recv_ns=0,
        )

        # Act
        result = OrderBookSnapshot.to_dict(snapshot)

        # Assert
        assert result == {
            "type": "OrderBookSnapshot",
            "instrument_id": "AUD/USD.SIM",
            "level": "L2",
            "bids": "[[1010, 2], [1009, 1]]",
            "asks": "[[1020, 2], [1021, 1]]",
            "ts_event_ns": 0,
            "ts_recv_ns": 0,
        }