Пример #1
0
    def test_to_dict_returns_expected_dict(self):
        # Arrange
        tick = QuoteTick(
            AUDUSD_SIM.id,
            Price.from_str("1.00000"),
            Price.from_str("1.00001"),
            Quantity.from_int(1),
            Quantity.from_int(1),
            0,
            0,
        )

        # Act
        result = QuoteTick.to_dict(tick)
        print(result)
        # Assert
        assert result == {
            "type": "QuoteTick",
            "instrument_id": "AUD/USD.SIM",
            "bid": "1.00000",
            "ask": "1.00001",
            "bid_size": "1",
            "ask_size": "1",
            "ts_event_ns": 0,
            "ts_recv_ns": 0,
        }
Пример #2
0
    def test_from_dict_returns_expected_tick(self):
        # Arrange
        tick = QuoteTick(
            AUDUSD_SIM.id,
            Price.from_str("1.00000"),
            Price.from_str("1.00001"),
            Quantity.from_int(1),
            Quantity.from_int(1),
            0,
            0,
        )

        # Act
        result = QuoteTick.from_dict(QuoteTick.to_dict(tick))

        # Assert
        assert tick == result