Beispiel #1
0
    def test_extract_volume_with_invalid_price_raises_value_error(self):
        # Arrange
        tick = QuoteTick(
            instrument_id=AUDUSD_SIM.id,
            bid=Price.from_str("1.00000"),
            ask=Price.from_str("1.00001"),
            bid_size=Quantity.from_int(1),
            ask_size=Quantity.from_int(1),
            ts_event=0,
            ts_init=0,
        )

        # Act, Assert
        with pytest.raises(ValueError):
            tick.extract_volume(0)
Beispiel #2
0
    def test_extract_volume_with_various_price_types_returns_expected_values(self):
        # Arrange
        tick = QuoteTick(
            instrument_id=AUDUSD_SIM.id,
            bid=Price.from_str("1.00000"),
            ask=Price.from_str("1.00001"),
            bid_size=Quantity.from_int(500000),
            ask_size=Quantity.from_int(800000),
            ts_event=0,
            ts_init=0,
        )

        # Act
        result1 = tick.extract_volume(PriceType.ASK)
        result2 = tick.extract_volume(PriceType.MID)
        result3 = tick.extract_volume(PriceType.BID)

        # Assert
        assert result1 == Quantity.from_int(800000)
        assert result2 == Quantity.from_int(650000)  # Average size
        assert result3 == Quantity.from_int(500000)