Refactor: main.py is more legible
This commit is contained in:
13
logic.py
13
logic.py
@@ -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
|
||||
Reference in New Issue
Block a user