Skip to content

Commit

Permalink
add competition in table
Browse files Browse the repository at this point in the history
  • Loading branch information
pretrehr committed Sep 5, 2021
1 parent a81a659 commit 00c077e
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 40 deletions.
8 changes: 5 additions & 3 deletions sportsbetting/auxiliary_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def afficher_mises_combine(matches, sites, list_mises, cotes, sport="football",
freebet_stakes = [float(stake.split(" (")[0]) for stake in table_stakes if "freebet" in stake]
table = {"Issue": table_teams, "Bookmaker": table_bookmakers, "Cote": table_odds, "Mise": table_stakes, "Total": table_totals}
trj = min(table_totals)/sum(cash_stakes) if is_pari_gagnant else gain(map(lambda x : float(x), table_odds))
infos = {"TRJ" : [str(round(trj*100, 3))+"%"], "Plus-value": [round(profit, 2)]}
infos = {"TRJ" : [str(round(trj*100, 3))+"%"], "Plus-value": [round(profit, 2)], "Compétition":[sb.ODDS[sport].get(match, {}).get("competition", "Indéterminée")]}
if profit and rang_freebet or uniquement_freebet:
del infos["Plus-value"]
infos["Taux de conversion"] = [str(round(profit*100, 2)) + "%"]
Expand Down Expand Up @@ -865,11 +865,13 @@ def calculator(odds, lay, commissions, stake, reference, outcomes, sites):
profit = stake*real_odds[reference]-sum(stakes)
except ZeroDivisionError:
pass
table = {"Site":sites, "Issue": outcomes, "Lay":lay_odds, "Cote": real_odds, "Mise": stakes, "Stake" : backers_stakes, "Total": [round(odd_i*stake_i, 2) for odd_i, stake_i in zip(real_odds, stakes)], "Infos":["TRJ : {}%".format(round(100*trj, 3)), "Plus-value : {}".format(round(profit, 2))]}
table = {"Site":sites, "Issue": outcomes, "Lay":lay_odds, "Cote": real_odds, "Mise": stakes, "Stake" : backers_stakes, "Total": [round(odd_i*stake_i, 2) for odd_i, stake_i in zip(real_odds, stakes)]}
infos = {"TRJ" : [str(round(trj*100, 3))+"%"], "Plus-value": [round(profit, 2)]}
if not any(lay):
del table["Lay"]
del table["Stake"]
text = tabulate.tabulate(table, headers='keys', tablefmt='fancy_grid')
text = "\n".join([tabulate.tabulate(table, headers='keys', tablefmt='fancy_grid'),
tabulate.tabulate(infos, headers='keys', tablefmt='fancy_grid')])
print(text)
if sys.platform.startswith("win"):
copy_to_clipboard(text)
Expand Down
6 changes: 5 additions & 1 deletion sportsbetting/bookmakers/netbet.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,17 @@ def parse_netbet(url):
date = ""
year = " " + str(today.year)
match = ""
competition = ""
date_time = None
valid_match = True
for line in soup.find_all():
if "class" in line.attrs and "nb-link-event" in line["class"] and "href" in line.attrs:
if sport:
valid_match = sport+"/" in line["href"]
link = line["href"]
if "class" in line.attrs and "nb-event_datestart" in line["class"]:
competition = " - ".join(map(lambda x : x.replace("-", " ").title(), link.split("/")[2:4]))
print(competition)
elif "class" in line.attrs and "nb-event_datestart" in line["class"]:
date = list(line.stripped_strings)[0] + year
if "Auj." in date:
date = datetime.datetime.today().strftime("%d/%m %Y")
Expand Down Expand Up @@ -95,6 +98,7 @@ def parse_netbet(url):
match_odds_hash[match]['odds'] = {"netbet": odds}
match_odds_hash[match]['date'] = date_time
match_odds_hash[match]['id'] = {"netbet": link}
match_odds_hash[match]['competition'] = competition
except ValueError: # match live (cotes non disponibles)
pass
return match_odds_hash
2 changes: 1 addition & 1 deletion sportsbetting/interface_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def compute_odds(window, values):
teams.insert(1, "Nul")
totals = [round(stake_i * odd_i, 2) for stake_i, odd_i in zip(stakes, best_odds)]
table = {"Issue": teams, "Bookmaker": bookmakers, "Cote": best_odds, "Mise": stakes, "Total": totals}
infos = {"TRJ" : [str(round(gain(best_odds)*100, 3))+"%"], "Plus-value": [profit]}
infos = {"TRJ" : [str(round(gain(best_odds)*100, 3))+"%"], "Plus-value": [profit], "Compétition":[sb.ODDS[sport].get(match, {}).get("competition", "Indéterminée")]}
text = "\n".join([tabulate.tabulate(table, headers='keys', tablefmt='fancy_grid'),
tabulate.tabulate(infos, headers='keys', tablefmt='fancy_grid')])
window["RESULT_ODDS"].update(text, visible=True)
Expand Down
10 changes: 5 additions & 5 deletions sportsbetting/tests/result_under_condition_1_expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├────────────────┼──────────────┼────────┼────────┼─────────┤
│ Leicester City │ unibet │ 3.9 │ 4.82 │ 18.8 │
╘════════════════╧══════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 96.878% │ -0.61 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 96.878% │ -0.61 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
10 changes: 5 additions & 5 deletions sportsbetting/tests/result_under_condition_2_expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├─────────┼──────────────┼────────┼────────┼─────────┤
│ Crotone │ joa │ 4.3 │ 4.07 │ 17.5 │
╘═════════╧══════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 94.594% │ -1 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 94.594% │ -1 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
10 changes: 5 additions & 5 deletions sportsbetting/tests/result_under_condition_3_expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├─────────────────┼──────────────┼────────┼────────┼─────────┤
│ Betis │ pmu │ 3.6 │ 5.83 │ 20.99 │
╘═════════════════╧══════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 95.014% │ -1.1 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 95.014% │ -1.1 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├─────────┼─────────────┼────────┼────────┼─────────┤
│ Lens │ pmu │ 2.15 │ 4.45 │ 9.57 │
╘═════════╧═════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 95.699% │ -0.43 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 95.699% │ -0.43 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├─────────┼─────────────┼────────┼────────┼─────────┤
│ Valence │ pmu │ 3 │ 5.12 │ 15.36 │
╘═════════╧═════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 96.855% │ -0.5 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 96.855% │ -0.5 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├────────────┼─────────────┼────────┼────────┼─────────┤
│ Granada │ pmu │ 3.5 │ 4.66 │ 16.31 │
╘════════════╧═════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 93.622% │ -1.11 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 93.622% │ -1.11 │ Indéterminée │
╘═════════╧══════════════╧═══════════════
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Répartition des mises (les totaux affichés prennent en compte les éventuels f
├────────────┼─────────────┼────────┼────────┼─────────┤
│ Levante │ pmu │ 2.8 │ 5.09 │ 14.25 │
╘════════════╧═════════════╧════════╧════════╧═════════╛
╒═════════╤══════════════╕
│ TRJ │ Plus-value │
╞═════════╪══════════════╡
│ 92.031% │ -1.23 │
╘═════════╧══════════════╛
╒═════════╤══════════════╤═══════════════
│ TRJ │ Plus-value │ Compétition │
╞═════════╪══════════════╪═══════════════
│ 92.031% │ -1.23 │ Indéterminée │
╘═════════╧══════════════╧═══════════════

0 comments on commit 00c077e

Please sign in to comment.