Added command-line interface

This commit is contained in:
Daan Koning
2022-11-22 19:47:07 +01:00
parent 6862691b6b
commit 1357b43557

32
main.py
View File

@@ -1,18 +1,40 @@
from logic import * from logic import *
import os import os
from itertools import chain from itertools import chain
import argparse
from dotenv import load_dotenv from dotenv import load_dotenv
from rich import print from rich import print
load_dotenv()
def main(): def main():
key = os.environ.get("API_KEY") load_dotenv()
parser = argparse.ArgumentParser(
prog="Arbitrage Finder",
description="""A simple tool to find sports betting arbitrage opportunities.
The tool fetches the odds from The Odds API (https://the-odds-api.com/) and compares the odds at different
bookmakers to each other in order to determine whether there are profitable and risk-free bets available."""
)
parser.add_argument(
"-k", "--key",
default=os.environ.get("API_KEY"),
help="The API key from The Odds API. If left blank it will default to the value of $API_KEY."
)
parser.add_argument(
"-r", "--region",
choices=["eu", "us", "au", "uk"],
default="eu",
help="The region in which to look for arbitrage opportunities."
)
args = parser.parse_args()
key = args.key
region = args.region
# logic
sports = get_sports(key) sports = get_sports(key)
data = chain.from_iterable(get_data(key, sport) 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)