Refactor: main.py is more legible

This commit is contained in:
Daan Koning
2023-01-23 13:09:12 +01:00
parent e19e2896a2
commit ed08cf73a2
2 changed files with 14 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
from typing import Iterable, Generator
import time
import requests
from itertools import chain
try:
from tqdm import tqdm
@@ -91,4 +92,14 @@ def process_data(matches: Iterable, include_started_matches: bool = True) -> Gen
"league": league,
"best_outcome_odds": best_odd_per_outcome,
"total_implied_odds": total_implied_odds,
}
}
def get_arbitrage_opportunities(key: str, region: str, cutoff: float):
sports = get_sports(key)
data = chain.from_iterable(get_data(key, sport, region=region) for sport in sports)
data = filter(lambda x: x != "message", data)
results = process_data(data)
arbitrage_opportunities = filter(lambda x: 0 < x["total_implied_odds"] < 1-cutoff, results)
return arbitrage_opportunities