Add cutoff param
This commit is contained in:
@@ -17,7 +17,7 @@ Next, ensure you have an API key from The Odds API and simply run:
|
||||
python main.py --key <YOUR_API_KEY>
|
||||
|
||||
## Usage
|
||||
The tool offers four optional command line arguments.
|
||||
The tool offers five optional command line arguments.
|
||||
|
||||
### API key
|
||||
In order to set the API key to use either the `-k` or `--key` arguments. If neither of these are used the script will read the value of `$API_KEY`. `.env` files are also supported and automatically loaded.
|
||||
@@ -28,5 +28,8 @@ Different parts of the world have different bookmakers. To reflect this the `-r`
|
||||
### Unformatted
|
||||
Using the `-u` or `--unformatted` flags will remove the pretty printing and simply dump the json which contains the arbs to the console directly. Use this if you intend to extend upon the script in some way, for regular usage the formatted print is significantly better.
|
||||
|
||||
### Cutoff
|
||||
The `-c` or `--cutoff` allow you to set a minimum profit margin. Should be set as a percentage, so `-c 10` means a 10% profit margin. Defaults to 0 (i.e. any profitable arb will be displayed).
|
||||
|
||||
### Help
|
||||
The `-h` or `--help` flags will show a short help message with documentation.
|
||||
|
||||
9
main.py
9
main.py
@@ -33,18 +33,25 @@ def main():
|
||||
action="store_true",
|
||||
help="If set, turn output into the json dump from the opportunities."
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--cutoff",
|
||||
type=float,
|
||||
default=0,
|
||||
help="The minimum profit margin required for an arb to be displayed. Inputted as a percentage."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
key = args.key
|
||||
region = args.region
|
||||
print_unformatted = args.unformatted
|
||||
cutoff = args.cutoff/100
|
||||
|
||||
# logic
|
||||
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: x["total_implied_odds"] < 1, results)
|
||||
arbitrage_opportunities = filter(lambda x: x["total_implied_odds"] < 1-cutoff, results)
|
||||
|
||||
if print_unformatted:
|
||||
for arb in arbitrage_opportunities:
|
||||
|
||||
Reference in New Issue
Block a user