ó
    Uðüi…  ã                  ó@   • S r SSKJr  SSKJr  SSKJr   " S S5      rg)zãOdds comparison client for comparing model probabilities vs market odds.

Fetches market odds from supported bookmakers and compares them
against the TipSharks rating engine's win/place probabilities to
identify discrepancies.
é    )Úannotations)ÚDecimal)ÚAnyc                  ó€   • \ rS rSrSr  S
     SS jjr    SS jr S     SS jjr      SS jrSS jr	S	r
g)ÚOddsComparisonClienté   z¢Compares model probabilities against market odds.

Supports multiple bookmaker APIs and provides normalized odds
in both decimal and implied probability formats.
Nc                ó*   • Xl         X l        0 U l        g)zÁInitialize the odds comparison client.

Args:
    bookmaker: Target bookmaker identifier (e.g., "tab_nz",
        "bet365", "sportsbet").
    api_key: Optional API key for bookmaker odds feed.
N)Ú	bookmakerÚapi_keyÚ_odds_cache)Úselfr
   r   s      ÚA/root/tipsharks/tipsharks-elo-api/packages/betting/odds_client.pyÚ__init__ÚOddsComparisonClient.__init__   s   € ð #ŒØŒØ+-ˆÕó    c              ƒ  ó   #   • [         e7f)a>  Fetch current market odds for all runners in a race.

Args:
    race_id: The race ID.

Returns:
    List of odds dicts with keys:
    - runner_name: str
    - win_odds_decimal: Decimal
    - win_probability: float (1 / odds, adjusted for margin)
    - place_odds: Decimal | None
    - last_updated: str (ISO datetime)
©ÚNotImplementedError)r   Úrace_ids     r   Úget_race_oddsÚ"OddsComparisonClient.get_race_odds%   s   é € ô" "Ð!ùs   ‚	c                ól   • U(       a  [        [        S5      U-  5      $ [        [        S5      U-  5      $ )zÔConvert decimal odds to implied probability.

Args:
    decimal_odds: Decimal odds (e.g., 3.50).
    margin_adjust: If True, apply a basic overround adjustment.

Returns:
    Implied probability between 0 and 1.
Ú1)Úfloatr   )r   Údecimal_oddsÚmargin_adjusts      r   Úimplied_probabilityÚ(OddsComparisonClient.implied_probability8   s/   € ö Üœ ›¨Ñ4Ó5Ð5Ü”W˜S“\ LÑ0Ó1Ð1r   c                ó   • [         e)a°  Compare model probabilities to market-implied probabilities.

Args:
    model_predictions: Dict of starter_id -> win_probability.
    market_odds: List of market odds dicts from get_race_odds.

Returns:
    List of comparison dicts with keys:
    - starter_id: int | None
    - runner_name: str
    - model_prob: float
    - market_prob: float
    - edge: float (model - market, positive = value)
    - kelly_fraction: float | None
r   )r   Úmodel_predictionsÚmarket_oddss      r   Úcompare_to_modelÚ%OddsComparisonClient.compare_to_modelJ   s
   € ô( "Ð!r   c              ƒ  ó@   #   • U R                   R                  5         g7f)zClear the internal odds cache.N)r   Úclear)r   s    r   Úclear_cacheÚ OddsComparisonClient.clear_cache`   s   é € à×Ñ×ÑÕ ùs   ‚)r   r   r
   )Útab_nzN)r
   Ústrr   z
str | NoneÚreturnÚNone)r   Úintr*   úlist[dict[str, Any]])T)r   r   r   Úboolr*   r   )r    zdict[int, float]r!   r-   r*   r-   )r*   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r"   r&   Ú__static_attributes__© r   r   r   r      s“   † ñð "Ø"ð.àð.ð ð.ð 
õ	.ð "àð"ð 
ô"ð, #ð2àð2ð ð2ð 
õ	2ð$"à+ð"ð *ð"ð 
ô	"÷,!r   r   N)r3   Ú
__future__r   Údecimalr   Útypingr   r   r5   r   r   Ú<module>r9      s!   ðñõ #å Ý ÷T!ò T!r   