Skip to content

Odds Bet365

Odds Bet 365 Class Documentation

Bases: Odds

Represents a specialized Odds entry sourced from Bet365 data.

Inherits from the base Odds class but overrides the odds loading logic to handle Bet365-specific formatting for money line, spread, and teaser odds.

Attributes:

Name Type Description
odds_json dict

Raw JSON data for the odds entry.

espn_instance PYESPN

The ESPN API instance used for lookups.

event_instance Event

The event this odds entry is associated with.

gameodds_instance GameOdds

The parent odds grouping instance.

team Team

The team this odds instance is associated with.

money_line float or None

Bet365 money line value.

spread_odds float or None

Bet365 spread value.

teaser_odds float or None

Bet365 spread handicap value.

Source code in pyespn/classes/betting.py
class OddsBet365(Odds):
    """
    Represents a specialized Odds entry sourced from Bet365 data.

    Inherits from the base `Odds` class but overrides the odds loading logic
    to handle Bet365-specific formatting for money line, spread, and teaser odds.

    Attributes:
        odds_json (dict): Raw JSON data for the odds entry.
        espn_instance (PYESPN): The ESPN API instance used for lookups.
        event_instance (Event): The event this odds entry is associated with.
        gameodds_instance (GameOdds): The parent odds grouping instance.
        team (Team): The team this odds instance is associated with.
        money_line (float or None): Bet365 money line value.
        spread_odds (float or None): Bet365 spread value.
        teaser_odds (float or None): Bet365 spread handicap value.
    """

    def __init__(self, odds_json, espn_instance, event_instance, gameodds_instance, team):
        """
        Initializes an OddsBet365 instance with Bet365-specific odds data.

        Args:
            odds_json (dict): JSON data containing Bet365 odds.
            espn_instance (PYESPN): Parent API instance.
            event_instance (Event): The event associated with these odds.
            gameodds_instance (GameOdds): The odds group this entry belongs to.
            team (Team): The team associated with this Bet365 odds entry.
        """
        super().__init__(odds_json=odds_json,
                         espn_instance=espn_instance,
                         event_instance=event_instance,
                         gameodds_instance=gameodds_instance)
        self.team = team

    def __repr__(self) -> str:
        """
        Returns a string representation of the OddsBet365 instance.

        Returns:
            str: A string identifying the team and provider.
        """
        return f"<Odds365 | {self.team.name}>"

    def _load_odds_json(self):
        """
        Parses the Bet365 odds JSON and sets betting attributes.

        Extracts values for money line, spread, and teaser (spread handicap)
        odds by identifying the appropriate keys using keyword matching.
        """
        try:
            for key, value in self.odds_json.items():
                if 'moneyline' in str(key).lower():
                    self.money_line = value.get('value')
                if 'spread' in str(key).lower() and 'spreadhandicap' not in str(key).lower():
                    self.spread_odds = value.get('value')
                if 'spreadhandicap' in str(key).lower():
                    self.teaser_odds = value.get('value')
        except AttributeError:
            pass

__init__(odds_json, espn_instance, event_instance, gameodds_instance, team)

Initializes an OddsBet365 instance with Bet365-specific odds data.

Parameters:

Name Type Description Default
odds_json dict

JSON data containing Bet365 odds.

required
espn_instance PYESPN

Parent API instance.

required
event_instance Event

The event associated with these odds.

required
gameodds_instance GameOdds

The odds group this entry belongs to.

required
team Team

The team associated with this Bet365 odds entry.

required
Source code in pyespn/classes/betting.py
def __init__(self, odds_json, espn_instance, event_instance, gameodds_instance, team):
    """
    Initializes an OddsBet365 instance with Bet365-specific odds data.

    Args:
        odds_json (dict): JSON data containing Bet365 odds.
        espn_instance (PYESPN): Parent API instance.
        event_instance (Event): The event associated with these odds.
        gameodds_instance (GameOdds): The odds group this entry belongs to.
        team (Team): The team associated with this Bet365 odds entry.
    """
    super().__init__(odds_json=odds_json,
                     espn_instance=espn_instance,
                     event_instance=event_instance,
                     gameodds_instance=gameodds_instance)
    self.team = team

__repr__()

Returns a string representation of the OddsBet365 instance.

Returns:

Name Type Description
str str

A string identifying the team and provider.

Source code in pyespn/classes/betting.py
def __repr__(self) -> str:
    """
    Returns a string representation of the OddsBet365 instance.

    Returns:
        str: A string identifying the team and provider.
    """
    return f"<Odds365 | {self.team.name}>"