Esempio n. 1
0
    def test_extract_price_with_invalid_price_raises_value_error(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, Assert
        with pytest.raises(ValueError):
            tick.extract_price(0)
Esempio n. 2
0
    def test_extract_price_with_various_price_types_returns_expected_values(self):
        # Arrange
        tick = QuoteTick(
            AUDUSD_FXCM,
            Price("1.00000"),
            Price("1.00001"),
            Quantity(1),
            Quantity(1),
            UNIX_EPOCH,
        )

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

        # Assert
        self.assertEqual(Price("1.00001"), result1)
        self.assertEqual(Price("1.000005"), result2)
        self.assertEqual(Price("1.00000"), result3)
Esempio n. 3
0
    def test_extract_price_with_various_price_types_returns_expected_values(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
        result1 = tick.extract_price(PriceType.ASK)
        result2 = tick.extract_price(PriceType.MID)
        result3 = tick.extract_price(PriceType.BID)

        # Assert
        assert result1 == Price.from_str("1.00001")
        assert result2 == Price.from_str("1.000005")
        assert result3 == Price.from_str("1.00000")