Skip to content

Markets & Odds

pyrf provides types for working with betting lines, odds formats, and bookmaker margins.

Market Types

from pyrf.market import Market

Market.TOTAL_GOAL   # Over/Under total goals
Market.ASIAN_HCAP   # Asian Handicap
Market.MATCH_RSLT   # Match Result (1X2)

Betting Lines

Lines are validated to quarter-point precision (0.25 increments):

from pyrf.market import QuotedLine

line = QuotedLine(value=2.5)
line.is_half_line()      # True
line.is_quarter_line()   # False

line = QuotedLine(value=0.75)
line.is_quarter_line()   # True
line.neighbours()        # adjacent lines

Odds and Probabilities

from pyrf.market import DecimalOdds

odds = DecimalOdds(value=1.90)
odds.implied_probability()  # ~0.526

# Create from probability
odds = DecimalOdds.from_probability(0.55)

Building Quotes

A Quote represents both sides of a bet:

from pyrf.market import Quote, Market

quote = Quote.build(
    market=Market.TOTAL_GOAL,
    line=2.5,
    over_odds=1.90,
    under_odds=2.00,
)

# Inspect the margin
quote.implied_margin()  # bookmaker's edge

# Strip margin for fair odds
fair = quote.margin_strip()

# Set a specific margin
adjusted = quote.margin_set(0.05)  # 5% margin

API Reference

See the full API Reference.