Skip to content

Price

Bid/Ask Prices

quantflow.utils.price.Price pydantic-model

Bases: BaseModel

Represents the bid/ask price of a security, which can be a spot price, forward price or option price

Fields:

bid pydantic-field

bid

Bid price

ask pydantic-field

ask

Ask price

mid property

mid

Calculate the mid price by averaging the bid and ask prices

spread property

spread

Calculate the bid-ask spread

bp_spread property

bp_spread

Bid-ask spread in basis points, calculated as spread divided by mid price and multiplied by 10000

is_valid

is_valid()

Check if the price is valid, which means the bid is less than or equal to the ask

Source code in quantflow/utils/price.py
def is_valid(self) -> bool:
    """Check if the price is valid, which means the bid is less than
    or equal to the ask"""
    return self.bid <= self.ask

quantflow.utils.price.PriceVolume pydantic-model

Bases: Price

Base class for price with volume and open interest

Fields:

open_interest pydantic-field

open_interest = ZERO

Open interest of the security

volume pydantic-field

volume = ZERO

Volume of the security

bid pydantic-field

bid

Bid price

ask pydantic-field

ask

Ask price

mid property

mid

Calculate the mid price by averaging the bid and ask prices

spread property

spread

Calculate the bid-ask spread

bp_spread property

bp_spread

Bid-ask spread in basis points, calculated as spread divided by mid price and multiplied by 10000

is_valid

is_valid()

Check if the price is valid, which means the bid is less than or equal to the ask

Source code in quantflow/utils/price.py
def is_valid(self) -> bool:
    """Check if the price is valid, which means the bid is less than
    or equal to the ask"""
    return self.bid <= self.ask