def find_perf_players(window, values): if not values["SITES_PERF"]: return if not values["COMPETITION_PERF"]: return sb.SUREBETS, sb.MIDDLES = get_surebets_players_nba(values["SITES_PERF"], values["COMPETITION_PERF"]) middles = sorted(sb.MIDDLES.keys(), key=lambda x:trj_match(sb.MIDDLES[x])[0], reverse=True) surebets = sorted(sb.SUREBETS.keys(), key=lambda x:trj_match(sb.SUREBETS[x])[0], reverse=True) window["MIDDLES_PERF"].update(middles) window["SUREBETS_PERF"].update(surebets)
def find_surebets_interface(window, values): matches = [] sport = values["SPORT_SUREBETS"][0] trj_min = float(values["TRJ_SUREBETS"])/100 for match in sb.ODDS[sport]: if trj_match(sb.ODDS[sport][match])[0] >= trj_min: matches.append(match) matches.sort(key=lambda x :trj_match(sb.ODDS[sport][x])[0], reverse=True) window["MATCHES_SUREBETS"].update(matches) if not matches: window["MESSAGE_SUREBETS"].update("Aucun surebet trouvé") else: window["MESSAGE_SUREBETS"].update("")
def display_middle_info(window, values): if not values["MIDDLES_PERF"]: return player_down_up_market = values["MIDDLES_PERF"][0] if player_down_up_market not in sb.MIDDLES: return player, down_up_market = player_down_up_market.split(" / ") down, up_market = down_up_market.split(" - ") up, market = up_market.split(".5 ") up += ".5 " mean = (float(up) + float(down))/2 proba = 0 for i in range(int(float(down)+1), int(float(up)+1)): proba += scipy.stats.poisson.pmf(i, mean) trj, bookmakers, best_odds = trj_match(sb.MIDDLES[player_down_up_market]) proba = round(proba*100, 3) trj = round(trj*100, 3) odds = sb.MIDDLES[player_down_up_market]["odds"] table = [] for key, value in odds.items(): table.append([key] + list(map(lambda x : str(x).replace("1.01", "- "), value))) table.sort() window["ODDS_PERF"].update(table, visible=True) window["MATCH_PERF"].update(sb.MIDDLES[player_down_up_market]["match"]) window["PLAYER_PERF"].update(player) window["MARKET_PERF"].update(market) window["OUTCOME0_PERF"].update("Over {} @ {} : {}".format(down, best_odds[0], bookmakers[0])) window["OUTCOME1_PERF"].update("Under {} @ {} : {}".format(up, best_odds[1], bookmakers[1])) window["TRJ_PERF"].update("TRJ : {}%".format(trj)) window["PROBA_MIDDLE_PERF"].update("Probabilité de middle : {} %".format(proba)) window["SUM_MIDDLE_PERF"].update("TRJ + proba : {} %".format(trj + proba), text_color="red" if trj+proba>100 else "white")
def odds_match_values_interface(window, values): """ :param window: Fenêtre principale PySimpleGUI :param values: Valeurs de la fenêtre principale :return: Affiche le résultat de la fonction odds_match dans l'interface """ try: match = values["MATCHES_VALUES"][0] sport = values["SPORT_VALUES"][0] old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = io.StringIO() odds_dict = odds_match(match, sport)[1] sys.stdout = old_stdout # Put the old stream back in place odds = odds_dict["odds"] date = odds_dict["date"] if len(list(odds.values())[0]) == 2: for key in odds.keys(): odds[key].insert(1, "- ") table = [] for key, value in odds.items(): table.append([key] + list(map(str, value))) table.sort() window["ODDS_VALUES"].update(table, visible=True) if date: window["DATE_VALUES"].update(date.strftime("%A %d %B %Y %H:%M"), visible=True) else: window["DATE_VALUES"].update(visible=False) window["MATCH_VALUES"].update(match, visible=True) rate, infos_value = get_values(sb.ODDS[sport][match], 0) window["INFOS_VALUE_VALUES"].update("Value max : {}%".format(round(rate*100, 2))) window["INFOS_ODDS_VALUES"].update(" / ".join("{} @ {} (+{}%)".format(bookmaker, odd, round(r*100, 2)) for bookmaker, r, odd in infos_value)) trj = trj_match(sb.ODDS[sport][match])[0] window["INFOS_TRJ_VALUES"].update("TRJ : {}%".format(round(trj*100, 3))) except (IndexError, ValueError) as _: pass
def sort_middle_trj(window, values): if not sb.MIDDLES: return middles = sorted(sb.MIDDLES.keys(), key=lambda x: trj_match(sb.MIDDLES[x])[0], reverse=True) window["MIDDLES_PERF"].update(middles)
def odds_match_surebets_interface(window, values): """ :param window: Fenêtre principale PySimpleGUI :param values: Valeurs de la fenêtre principale :return: Affiche le résultat de la fonction odds_match dans l'interface """ try: match = values["MATCHES_SUREBETS"][0] sport = values["SPORT_SUREBETS"][0] old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = io.StringIO() odds_dict = odds_match(match, sport)[1] sys.stdout = old_stdout # Put the old stream back in place odds = odds_dict["odds"] date = odds_dict["date"] if len(list(odds.values())[0]) == 2: for key in odds.keys(): odds[key].insert(1, "- ") table = [] for key, value in odds.items(): table.append([key] + list(map(str, value))) table.sort() window["ODDS_SUREBETS"].update(table, visible=True) if date: window["DATE_SUREBETS"].update(date.strftime("%A %d %B %Y %H:%M"), visible=True) else: window["DATE_SUREBETS"].update(visible=False) window["MATCH_SUREBETS"].update(match, visible=True) trj = trj_match(sb.ODDS[sport][match]) window["MESSAGE_SUREBETS"].update("TRJ : {}%".format(round(trj*100, 2))) except (IndexError, ValueError) as _: pass
def get_gap_proba(key): gap = key.split(" / ")[1] limit1, limit2 = gap.split()[:3:2] mean = (float(limit1) + float(limit2))/2 proba = 0 for i in range(int(float(limit1)+1), int(float(limit2)+1)): proba += scipy.stats.poisson.pmf(i, mean) return proba + trj_match(sb.MIDDLES[key])[0]
def search_perf(window, values): try: perfs = sorted([ x for x in sb.SUREBETS.keys() if values["SEARCH_PERF"].lower() in x.lower() ], key=lambda x: trj_match(sb.SUREBETS[x])[0], reverse=True) window['SUREBETS_PERF'].update(values=perfs) except KeyError: window['SUREBETS_PERF'].update(values=[])
def find_values_interface(window, values): matches = [] sport = values["SPORT_VALUES"][0] rate_min = float(values["RATE_VALUES"])/100 trj_min = float(values["TRJ_VALUES"])/100 for match in sb.ODDS[sport]: if get_values(sb.ODDS[sport][match], rate_min)[0] >= rate_min and trj_match(sb.ODDS[sport][match])[0] >= trj_min: matches.append(match) matches.sort(key=lambda x :get_values(sb.ODDS[sport][x], rate_min)[0], reverse=True) window["MATCHES_VALUES"].update(matches) if not matches: window["MESSAGE_VALUES"].update("Aucune value trouvée") else: window["MESSAGE_VALUES"].update("")
def compute_odds(window, values): try: sport = values["SPORT_ODDS"][0] stake = float(values["STAKE_ODDS"]) match = values["MATCHES_ODDS"][0] _, bookmakers, best_odds = trj_match(sb.ODDS[sport][match]) except (ValueError, IndexError) as _: return if values["OUTCOME_ODDS_SPLIT_STAKE"]: old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = buffer = io.StringIO() mises(best_odds, stake, True) sys.stdout = old_stdout # Put the old stream back in place what_was_printed = buffer.getvalue() profit = float(what_was_printed.split("\n")[4].split(' = ')[1]) stakes = eval(what_was_printed.split("\n")[5].split(' = ')[1]) else: outcomes = ["1", "2"] if get_nb_outcomes(sport) == 3: outcomes.insert(1, "N") outcome = 0 for i, outcome_i in enumerate(outcomes): if values["OUTCOME_ODDS_"+outcome_i]: outcome = i break old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = buffer = io.StringIO() mises2(best_odds, stake, outcome, True) sys.stdout = old_stdout # Put the old stream back in place what_was_printed = buffer.getvalue() profit = float(what_was_printed.split("\n")[5].split(' = ')[1]) stakes = eval(what_was_printed.split("\n")[6].split(' = ')[1]) teams = match.split(" - ") if get_nb_outcomes(sport) == 3: 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} text = tabulate.tabulate(table, headers='keys', tablefmt='fancy_grid') window["RESULT_ODDS"].update(text + "\nPlus-value : {}".format(profit), visible=True) if sys.platform.startswith("win"): copy_to_clipboard(text)
def odds_match_interface(window, values): """ :param window: Fenêtre principale PySimpleGUI :param values: Valeurs de la fenêtre principale :return: Affiche le résultat de la fonction odds_match dans l'interface """ try: match = values["MATCHES_ODDS"][0] sport = values["SPORT_ODDS"][0] old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = io.StringIO() odds_dict = odds_match(match, sport)[1] sys.stdout = old_stdout # Put the old stream back in place odds = odds_dict["odds"] date = odds_dict["date"] if len(list(odds.values())[0]) == 2: for key in odds.keys(): odds[key].insert(1, "- ") table = [] for key, value in odds.items(): table.append([key] + list(map(str, value))) table.sort() window["ODDS_ODDS"].update(table, visible=True) if date: window["DATE_ODDS"].update(date.strftime("%A %d %B %Y %H:%M"), visible=True) else: window["DATE_ODDS"].update(visible=False) window["MATCH_ODDS"].update(match, visible=True) trj, bookmakers, best_odds = trj_match(sb.ODDS[sport][match]) window["TRJ_ODDS"].update("TRJ : {}%".format(round(trj * 100, 3))) window["INFOS_ODDS"].update(" / ".join( bookmaker + " @ " + str(odd) for bookmaker, odd in zip(bookmakers, best_odds))) window["GOTO_SITE_ODDS"].update(visible=sb.BETA) window["DELETE_SITE_ODDS"].update(visible=True) window["DELETE_MATCH_ODDS"].update(visible=True) except IndexError: pass
def display_surebet_info(window, values): if not values["SUREBETS_PERF"]: return player_limit_market = values["SUREBETS_PERF"][0] if player_limit_market not in sb.SUREBETS: return player, limit_market = player_limit_market.split(" / ") limit, market = limit_market.split(".5 ") limit += ".5 " trj, bookmakers, best_odds = trj_match(sb.SUREBETS[player_limit_market]) odds = sb.SUREBETS[player_limit_market]["odds"] table = [] for key, value in odds.items(): table.append([key] + list(map(lambda x : str(x).replace("1.01", "- "), value))) table.sort() window["ODDS_PERF"].update(table, visible=True) window["MATCH_PERF"].update(sb.SUREBETS[player_limit_market]["match"]) window["PLAYER_PERF"].update(player) window["MARKET_PERF"].update(market) window["OUTCOME0_PERF"].update("Over {} @ {} : {}".format(limit, best_odds[0], bookmakers[0])) window["OUTCOME1_PERF"].update("Under {} @ {} : {}".format(limit, best_odds[1], bookmakers[1]), visible=best_odds[1]>1.01) window["TRJ_PERF"].update("TRJ : {}%".format(round(trj*100, 3)), visible=best_odds[1]>1.01) window["PROBA_MIDDLE_PERF"].update("") window["SUM_MIDDLE_PERF"].update("")
def get_gap_length(key): gap = key.split(" / ")[1] limit1, limit2 = gap.split()[:3:2] return float(limit2)-float(limit1), trj_match(sb.MIDDLES[key])[0]