Skip to main content

Working with the Data

After receiving odds data from Bayes Live Odds you will want to process it in some way. Here are some tips on how to get started with game data processing.

The odds messages that you are receiving from Bayes follow the unified Data Format. More information available here: Bayes Live Odds Message Format. It's best you understand its structure before reading this article.

Python Implementation Tips

After connecting to the RabbitMQ queue and receiving your first message, you will need to parse the outmost data structure of the message, the DataProviderMessage. It contains information that may help you determine early on if you should start processing this message, skip it, or leave it for later. If the message should be processed — unpack the payload from the DataProviderMessage and pass it to the next processing function:

# ...message = get_message() # receive the message from somewhere

def process_data_provider_message(message: dict) -> None:
seq_idx = message['seqIdx']
check_seq_idx(seq_idx)

payload = message['payload']
process_odds_update_message(payload)

The next processing function, process_odds_update_message, deals with OddsUpdate message structure. You can check the OddsUpdate article to learn more about the structure of the messages you'll receive.

def process_odds_update_message(message: dict) -> None:
# Get the tournament, match, title, and team information
metadata = message['metadata']
check_metadata(metadata)

# Get the message date and time.
message_creation_date = message['created_at']
message_updation_date = message['updated_at']

# Get the provider and odds type (prematch, live)
odds_provider = message['provider']
odds_type = message['type']

# Get the markets and their outcomes
markets = message['markets']
process_markets(markets)

Now you have extracted the information on the tournament, match, teams, provider, and odds type.

Use the process_markets function to get information on the markets:

def process_markets(markets: list) -> None:
for market in markets:
market_name = market['marketName']
market_type = market['marketType']

market_specifiers = market['specifiers']

outcomes = market['outcomes']
process_outcomes(outcomes)

Different markets have different types of outcomes. Let's look at the outcomes of a yesno market:

def process_outcomes(outcomes: list) -> None:
for outcome in outcomes:
decimal_odds = outcome['decimalOdd']

# odds for 'yes'
yes_odds = decimal_odds['yes']

# odds for 'no'
no_odds = decimal_odds['no']

# Trading status indicates whether the bets can be placed on that market
trading_status = outcome['tradingStatus']
win_value = outcome['winValue']
target = outcome['target']

Now you have processed markets and their outcomes.