The Result Extraction Algorithm is the core component responsible for determining match outcomes in the MbetterClient betting system. It ensures fair play while maintaining system profitability through sophisticated redistribution controls and CAP (Controlled Redistribution) logic.
## Algorithm Flow
### Phase 1: Initialization and Data Collection
#### Step 1.1: Input Validation
-**Inputs**: `fixture_id`, `match_id`
-**Validation**: Ensure match exists and has pending bets
-**Initialization**: Set `selected_result = None`, `extraction_winning_outcome_names = []`
"""Update bet results for UNDER/OVER and selected result with win amount calculation"""
try:
logger.info(f"DEBUG _update_bet_results: Starting for match {match_id}, selected_result='{selected_result}'")
logger.info(f"DEBUG _update_bet_results: Starting for match {match_id}, selected_result='{selected_result}', extraction_winning_outcome_names={extraction_winning_outcome_names}")
# Initialize variables to avoid UnboundLocalError
extraction_winning_outcome_names=[]
# Initialize match variable to avoid UnboundLocalError
match=None
# Get coefficient for the selected result
...
...
@@ -3221,8 +3335,8 @@ class GamesThread(ThreadedComponent):
# Check if there are any active fixtures (matches in non-terminal states)
session=self.db_manager.get_session()
try:
# Get today's date
today=datetime.now().date()
# Get today's date in UTC (consistent with database)