import datetime
from typing import Optional

class PriceSize:
    price: float
    size: float
    def __getitem__(self, key: str) -> float: ...
    def __repr__(self) -> str: ...

class ExchangePrices:
    @property
    def available_to_back(self) -> list[PriceSize]: ...
    @property
    def available_to_lay(self) -> list[PriceSize]: ...
    @property
    def traded_volume(self) -> list[PriceSize]: ...

class StartingPrices:
    @property
    def near_price(self) -> Optional[float | str]: ...
    @property
    def far_price(self) -> Optional[float | str]: ...
    @property
    def actual_sp(self) -> Optional[float | str]: ...
    @property
    def back_stake_taken(self) -> list[PriceSize]: ...
    @property
    def lay_liability_taken(self) -> list[PriceSize]: ...

class MarketDefinitionRunner:
    selection_id: int
    sort_priority: int
    status: str
    handicap: float
    adjustment_factor: Optional[float]
    removal_date: Optional[str]
    name: Optional[str]
    bsp: Optional[float]

class MarketDefinition:
    @property
    def event_id(self) -> Optional[str]: ...
    @property
    def event_type_id(self) -> Optional[str]: ...
    @property
    def event_name(self) -> Optional[str]: ...
    @property
    def market_type(self) -> Optional[str]: ...
    @property
    def country_code(self) -> Optional[str]: ...
    @property
    def venue(self) -> Optional[str]: ...
    @property
    def race_type(self) -> Optional[str]: ...
    @property
    def name(self) -> Optional[str]: ...
    @property
    def timezone(self) -> Optional[str]: ...
    @property
    def betting_type(self) -> Optional[str]: ...
    @property
    def regulators(self) -> list[str]: ...
    @property
    def runners(self) -> list[MarketDefinitionRunner]: ...
    @property
    def market_time(self) -> Optional[datetime.datetime]: ...
    @property
    def open_date(self) -> Optional[datetime.datetime]: ...
    @property
    def suspend_time(self) -> Optional[datetime.datetime]: ...
    @property
    def settled_time(self) -> Optional[datetime.datetime]: ...
    @property
    def bsp_market(self) -> bool: ...
    @property
    def persistence_enabled(self) -> bool: ...
    @property
    def each_way_divisor(self) -> Optional[float]: ...
    @property
    def turn_in_play_enabled(self) -> bool: ...
    @property
    def discount_allowed(self) -> bool: ...
    @property
    def market_base_rate(self) -> float: ...
    @property
    def bet_delay(self) -> int: ...
    @property
    def number_of_winners(self) -> int: ...
    @property
    def number_of_active_runners(self) -> int: ...
    @property
    def bsp_reconciled(self) -> bool: ...
    @property
    def complete(self) -> bool: ...
    @property
    def cross_matching(self) -> bool: ...
    @property
    def in_play(self) -> bool: ...
    @property
    def runners_voidable(self) -> bool: ...
    @property
    def status(self) -> str: ...
    @property
    def version(self) -> int: ...

class Runner:
    selection_id: int
    handicap: float
    adjustment_factor: Optional[float]
    last_price_traded: Optional[float]
    total_matched: float
    @property
    def status(self) -> Optional[str]: ...
    @property
    def removal_date(self) -> Optional[str]: ...
    @property
    def ex(self) -> ExchangePrices: ...
    @property
    def sp(self) -> StartingPrices: ...

class MarketBook:
    streaming_unique_id: Optional[int]
    @property
    def market_id(self) -> str: ...
    @property
    def publish_time(self) -> datetime.datetime: ...
    @property
    def publish_time_epoch(self) -> int: ...
    @property
    def status(self) -> str: ...
    @property
    def bet_delay(self) -> int: ...
    @property
    def bsp_reconciled(self) -> bool: ...
    @property
    def complete(self) -> bool: ...
    @property
    def cross_matching(self) -> bool: ...
    @property
    def inplay(self) -> bool: ...
    @property
    def number_of_active_runners(self) -> int: ...
    @property
    def number_of_runners(self) -> int: ...
    @property
    def number_of_winners(self) -> int: ...
    @property
    def runners_voidable(self) -> bool: ...
    @property
    def total_matched(self) -> float: ...
    @property
    def version(self) -> int: ...
    @property
    def last_match_time(self) -> Optional[int]: ...
    @property
    def market_definition(self) -> Optional[MarketDefinition]: ...
    @property
    def runners(self) -> list[Runner]: ...
    def to_dict(self) -> dict: ...

class PricesIterator:
    def __iter__(self) -> PricesIterator: ...
    def __next__(self) -> MarketBook: ...
    def __len__(self) -> int: ...

def iter_prices_file(path: str) -> PricesIterator: ...
