Basic tqdm functionality
This commit is contained in:
6
logic.py
6
logic.py
@@ -2,6 +2,11 @@ from typing import Iterable, Generator
|
|||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
try:
|
||||||
|
from tqdm import tqdm
|
||||||
|
except ImportError:
|
||||||
|
tqdm = lambda *args, **kwargs: args[0]
|
||||||
|
|
||||||
BASE_URL = "api.the-odds-api.com/v4"
|
BASE_URL = "api.the-odds-api.com/v4"
|
||||||
PROTOCOL = "https://"
|
PROTOCOL = "https://"
|
||||||
|
|
||||||
@@ -59,6 +64,7 @@ def get_data(key: str, sport: str, region: str = "eu"):
|
|||||||
def process_data(matches: Iterable, include_started_matches: bool = True) -> Generator[dict, None, None]:
|
def process_data(matches: Iterable, include_started_matches: bool = True) -> Generator[dict, None, None]:
|
||||||
"""Extracts all matches that are available and calculates some things about them, such as the time to start and
|
"""Extracts all matches that are available and calculates some things about them, such as the time to start and
|
||||||
the best available implied odds."""
|
the best available implied odds."""
|
||||||
|
matches = tqdm(matches, desc="Checking all matches", leave=False, unit=" matches")
|
||||||
for match in matches:
|
for match in matches:
|
||||||
start_time = int(match["commence_time"])
|
start_time = int(match["commence_time"])
|
||||||
if not include_started_matches and start_time < time.time():
|
if not include_started_matches and start_time < time.time():
|
||||||
|
|||||||
2
main.py
2
main.py
@@ -51,7 +51,7 @@ def main():
|
|||||||
data = chain.from_iterable(get_data(key, sport, region=region) for sport in sports)
|
data = chain.from_iterable(get_data(key, sport, region=region) for sport in sports)
|
||||||
data = filter(lambda x: x != "message", data)
|
data = filter(lambda x: x != "message", data)
|
||||||
results = process_data(data)
|
results = process_data(data)
|
||||||
arbitrage_opportunities = filter(lambda x: x["total_implied_odds"] < 1-cutoff, results)
|
arbitrage_opportunities = filter(lambda x: 0 < x["total_implied_odds"] < 1-cutoff, results)
|
||||||
|
|
||||||
if print_unformatted:
|
if print_unformatted:
|
||||||
print(list(arbitrage_opportunities))
|
print(list(arbitrage_opportunities))
|
||||||
|
|||||||
Reference in New Issue
Block a user