def best_matches_combine_cashback(site, minimum_odd, bet, sport="football", freebet=True, combi_max=0, rate_cashback=1, nb_matches=2, date_max=None, time_max=None, date_min=None, time_min=None): """ Calcule la répartition des mises lorsqu'un unique combiné est remboursé s'il est perdant """ all_odds = sportsbetting.ODDS[sport] sportsbetting.ALL_ODDS_COMBINE = {} for combine in combinations(all_odds.items(), nb_matches): (sportsbetting .ALL_ODDS_COMBINE[" / " .join([match[0] for match in combine])]) = cotes_combine_all_sites(*[match[1] for match in combine]) odds_function = lambda best_odds, odds_site, i: (best_odds[:i] + [odds_site[i] * (1 + combi_max) - combi_max] + best_odds[i + 1:]) profit_function = lambda odds_to_check, i: gain_pari_rembourse_si_perdant(odds_to_check, bet, i, freebet, rate_cashback) criteria = lambda odds_to_check, i: (odds_to_check[i] + combi_max) / ( 1 + combi_max) >= minimum_odd display_function = lambda x, i: mises_pari_rembourse_si_perdant(x, bet, i, freebet, rate_cashback, True) return_function = lambda x, i: mises_pari_rembourse_si_perdant(x, bet, i, freebet, rate_cashback, False) best_match_base(odds_function, profit_function, criteria, display_function, return_function, site, sport, date_max, time_max, date_min, time_min, True, nb_matches)
def best_matches_combine_cashback_une_selection_perdante(site, cote_minimale_selection, combi_max=0, nb_matches=2, date_max=None, time_max=None, date_min=None, time_min=None): """ Calcule la meilleure combinaison de matches et les mises à jouer pour une promotion du type "Combiné remboursé si une seule selection perdante, sans limite du nombre de paris remboursés" """ sport = "football" bet = 10000 all_odds = sportsbetting.ODDS[sport] sportsbetting.ALL_ODDS_COMBINE = {} for combine in combinations(all_odds.items(), nb_matches): try: if all([odd >= cote_minimale_selection for odds in list(all_odds[match[0]]["odds"][site] for match in combine) for odd in odds]): (sportsbetting .ALL_ODDS_COMBINE[" / " .join([match[0] for match in combine])]) = cotes_combine_all_sites(*[match[1] for match in combine]) except KeyError: pass odds_function = lambda best_odds, odds_site, i: list( map(lambda x: x * (1 + combi_max) - combi_max, odds_site)) profit_function = lambda odds_to_check, i: gain(odds_to_check, bet) - bet criteria = lambda odds_to_check, i: (odds_to_check[i] + combi_max) / (1 + combi_max) >= 1.1 display_function = lambda x, i: mises(x, bet, True) return_function = lambda x, i: mises(x, bet, False) best_match_base(odds_function, profit_function, criteria, display_function, return_function, site, sport, date_max, time_max, date_min, time_min, True, nb_matches, one_site=True, recalcul=True)
def best_matches_combine(site, minimum_odd, bet, sport="football", nb_matches=2, one_site=False, date_max=None, time_max=None, date_min=None, time_min=None, minimum_odd_selection=1.01): """ Retourne les meilleurs matches sur lesquels miser lorsqu'on doit miser une somme donnée à une cote donnée sur un combiné """ all_odds = filter_dict_dates(sportsbetting.ODDS[sport], date_max, time_max, date_min, time_min) sportsbetting.ALL_ODDS_COMBINE = {} for combine in combinations(all_odds.items(), nb_matches): try: if all([ odd >= minimum_odd_selection for odds in list( all_odds[match[0]]["odds"][site] for match in combine) for odd in odds ]): (sportsbetting.ALL_ODDS_COMBINE[" / ".join([ match[0] for match in combine ])]) = cotes_combine_all_sites( *[match[1] for match in combine]) except KeyError: pass odds_function = lambda best_odds, odds_site, i: ( (best_odds[:i] + [odds_site[i]] + best_odds[i + 1:]) if not one_site else odds_site) profit_function = lambda odds_to_check, i: (gain(odds_to_check, bet) - bet if one_site else gain2( odds_to_check, i, bet)) criteria = lambda odds_to_check, i: ( (not one_site and odds_to_check[i] >= minimum_odd) or (one_site and all(odd >= minimum_odd for odd in odds_to_check))) display_function = lambda best_overall_odds, best_rank: ( mises2(best_overall_odds, bet, best_rank, True) if not one_site else mises(best_overall_odds, bet, True)) result_function = lambda best_overall_odds, best_rank: ( mises2(best_overall_odds, bet, best_rank, False) if not one_site else mises(best_overall_odds, bet, False)) best_match_base(odds_function, profit_function, criteria, display_function, result_function, site, sport, date_max, time_max, date_min, time_min, True, nb_matches, one_site=one_site)
def compute_all_odds_combine(nb_combine, combine): sb.PROGRESS += 100/nb_combine try: sb.ALL_ODDS_COMBINE[" / ".join([match[0] for match in combine])] = cotes_combine_all_sites(*[match[1] for match in combine]) except KeyError: pass
def best_matches_freebet_one_site(site, freebet, sport="football", nb_matches=2, minimum_odd=1.1, date_max=None, time_max=None, date_min=None, time_min=None): """ Calcule la répartition des paris gratuits sur un unique site """ all_odds = sportsbetting.ODDS[sport] sportsbetting.ALL_ODDS_COMBINE = {} for combine in combinations(all_odds.items(), nb_matches): (sportsbetting.ALL_ODDS_COMBINE[" / ".join([ match[0] for match in combine ])]) = cotes_combine_all_sites(*[match[1] for match in combine]) odds_function = lambda best_odds, odds_site, i: cotes_freebet(odds_site) profit_function = lambda odds_to_check, i: gain(odds_to_check, freebet ) - freebet criteria = lambda odds_to_check, i: all(odd >= minimum_odd for odd in odds_to_check) display_function = lambda best_overall_odds, best_rank: mises( best_overall_odds, freebet, True) result_function = lambda best_overall_odds, best_rank: mises( best_overall_odds, freebet, False) best_match_base(odds_function, profit_function, criteria, display_function, result_function, site, sport, date_max, time_max, date_min, time_min, True, nb_matches, True, one_site=True)
def best_matches_freebet(main_sites, freebets, sport="football", *matches): """ Compute of best way to bet freebets following the model [[bet, bookmaker], ...] """ second_sites = {freebet[1] for freebet in freebets} if not second_sites: print("Veuillez sélectionner des freebets secondaires") return if matches: new_odds = {} for match in matches: match_name, odds = odds_match(match) new_odds[match_name] = odds else: new_odds = sportsbetting.ODDS[sport] all_odds = {} for match in new_odds: if (not (any([site not in new_odds[match]["odds"].keys() for site in main_sites]) or any([site not in new_odds[match]["odds"].keys() for site in second_sites]))): if new_odds[match]["odds"]: all_odds[match] = new_odds[match] best_rate = 0 nb_matches = 2 n = 3 ** nb_matches nb_freebets = len(freebets) all_odds_combine = {} combis = list(combinations(all_odds.items(), nb_matches)) nb_combis = len(combis) progress = 10 start = time.time() for i, combine in enumerate(combis): # if i == 20: # print("appr. time to wait:", int((time.time()-start)*nb_combis/20), "s") # if i/nb_combis*100 > progress: # print(str(progress)+"%") # progress += 10 match_combine = " / ".join([match[0] for match in combine]) all_odds_combine[match_combine] = cotes_combine_all_sites(*[match[1] for match in combine], freebet=True) main_sites_distribution = [main_sites[0] for _ in range(n)] main_site_odds = copy.deepcopy(all_odds_combine[match_combine]["odds"][main_sites[0]]) for main in main_sites[1:]: potential_odds = all_odds_combine[match_combine]["odds"][main] for j, odd in enumerate(potential_odds): if odd > main_site_odds[j]: main_site_odds[j] = odd main_sites_distribution[j] = main second_odds = {second_site: all_odds_combine[match_combine]["odds"][second_site] for second_site in second_sites} dict_combine_odds = copy.deepcopy(second_odds) for perm in permutations(range(n), nb_freebets): defined_second_sites = [[perm[i], freebet[0], freebet[1]] for i, freebet in enumerate(freebets)] defined_bets_temp = defined_bets(main_site_odds, dict_combine_odds, main_sites_distribution, defined_second_sites) if defined_bets_temp[0] / np.sum(defined_bets_temp[1]) > best_rate: best_rate = defined_bets_temp[0] / np.sum(defined_bets_temp[1]) best_combine = combine best_bets = defined_bets_temp # print("Temps d'exécution =", time.time()-start) best_match_combine = " / ".join([match[0] for match in best_combine]) odds_best_match = copy.deepcopy(all_odds_combine[best_match_combine]) all_sites = main_sites + list(second_sites) for site in all_odds_combine[best_match_combine]["odds"]: if site not in all_sites: del odds_best_match["odds"][site] print(best_match_combine) pprint(odds_best_match, compact=1) print("Taux =", best_rate) print("Gain référence =", best_bets[0]) print("Somme des mises =", np.sum(best_bets[1])) afficher_mises_combine([x[0] for x in best_combine], best_bets[2], best_bets[1], all_odds_combine[best_match_combine]["odds"], "football", uniquement_freebet=True)
def best_match_stakes_to_bet(stakes, nb_matches=1, sport="football", date_max=None, time_max=None): second_sites = {stake[1] for stake in stakes} main_sites = ['betclic', 'betstars', 'bwin', 'france_pari', 'joa', 'netbet', 'parionssport', 'pasinobet', 'pmu', 'unibet', 'winamax', 'zebet'] new_odds = sportsbetting.ODDS[sport] all_odds = {} hour_max, minute_max = 0, 0 if time_max: if time_max[-1] == 'h': hour_max = int(time_max[:-1]) else: hour_max, minute_max = (int(_) for _ in time_max.split('h')) if date_max: day_max, month_max, year_max = (int(_) for _ in date_max.split('/')) datetime_max = datetime.datetime(year_max, month_max, day_max, hour_max, minute_max) else: datetime_max = None for match in new_odds: if (((datetime_max and new_odds[match]["date"] <= datetime_max) or not datetime_max) and not any([site not in new_odds[match]["odds"].keys() for site in second_sites])): if new_odds[match]["odds"]: all_odds[match] = new_odds[match] best_profit = -sum(stake[0] for stake in stakes) n = 3 ** nb_matches nb_stakes = len(stakes) all_odds_combine = {} combis = list(combinations(all_odds.items(), nb_matches)) nb_combis = len(combis) best_combine = None best_bets = None main_site_odds = [] main_sites_distribution = [] progress = 10 start = time.time() sportsbetting.PROGRESS = 0 for i, combine in enumerate(combis): sportsbetting.PROGRESS += 100 / nb_combis # if i == 20: # print("appr. time to wait:", int((time.time()-start)*nb_combis/20), "s") # if i/nb_combis*100 > progress: # print(str(progress)+"%") # progress += 10 match_combine = " / ".join([match[0] for match in combine]) all_odds_combine[match_combine] = cotes_combine_all_sites(*[match[1] for match in combine]) for main0 in main_sites: try: main_sites_distribution = [main0 for _ in range(n)] main_site_odds = copy.deepcopy(all_odds_combine[match_combine]["odds"][main0]) break except KeyError: pass for main in main_sites[:i] + main_sites[i + 1:]: try: potential_odds = all_odds_combine[match_combine]["odds"][main] for j, odd in enumerate(potential_odds): if odd > main_site_odds[j]: main_site_odds[j] = odd main_sites_distribution[j] = main except KeyError: pass second_odds = {second_site: all_odds_combine[match_combine]["odds"][second_site] for second_site in second_sites} dict_combine_odds = copy.deepcopy(second_odds) for perm in permutations(range(n), nb_stakes): valid_perm = True defined_second_sites = [[perm[j], stake[0], stake[1]] for j, stake in enumerate(stakes)] for j, stake in enumerate(stakes): if dict_combine_odds[defined_second_sites[j][2]][defined_second_sites[j][0]] < \ stake[2]: valid_perm = False break if not valid_perm: continue defined_bets_temp = defined_bets(main_site_odds, dict_combine_odds, main_sites_distribution, defined_second_sites) profit = defined_bets_temp[0] - np.sum(defined_bets_temp[1]) if profit > best_profit: best_profit = profit best_combine = combine best_bets = defined_bets_temp # print("Temps d'exécution =", time.time()-start) if best_combine: best_match_combine = " / ".join([match[0] for match in best_combine]) odds_best_match = copy.deepcopy(all_odds_combine[best_match_combine]) all_sites = main_sites + list(second_sites) for site in all_odds_combine[best_match_combine]["odds"]: if site not in all_sites: del odds_best_match["odds"][site] print(best_match_combine) pprint(odds_best_match, compact=1) print("Plus-value =", best_profit) print("Gain référence =", best_bets[0]) print("Somme des mises =", np.sum(best_bets[1])) afficher_mises_combine([x[0] for x in best_combine], best_bets[2], best_bets[1], all_odds_combine[best_match_combine]["odds"], "football") else: print("No match found")
def best_match_stakes_to_bet(stakes, nb_matches=1, sport="football", date_max=None, time_max=None, identical_stakes=False): second_sites = {stake[1] for stake in stakes} main_sites = ['betclic', 'betstars', 'bwin', 'france_pari', 'joa', 'netbet', 'parionssport', 'pasinobet', 'pmu', 'unibet', 'winamax', 'zebet'] all_odds = filter_dict_dates(sb.ODDS[sport], date_max, time_max) best_profit = -sum(stake[0] for stake in stakes) n = get_nb_issues(sport) ** nb_matches nb_stakes = len(stakes) all_odds_combine = {} combis = list(combinations(all_odds.items(), nb_matches)) nb_combis = len(combis) best_combine = None best_bets = None main_site_odds = [] main_sites_distribution = [] sb.PROGRESS = 0 for i, combine in enumerate(combis): sb.PROGRESS += 100 / nb_combis match_combine = " / ".join([match[0] for match in combine]) all_odds_combine[match_combine] = cotes_combine_all_sites(*[match[1] for match in combine]) for main0 in main_sites: try: main_sites_distribution = [main0 for _ in range(n)] main_site_odds = copy.deepcopy(all_odds_combine[match_combine]["odds"][main0]) break except KeyError: pass for main in main_sites[:i] + main_sites[i + 1:]: try: potential_odds = all_odds_combine[match_combine]["odds"][main] for j, odd in enumerate(potential_odds): if odd > main_site_odds[j]: main_site_odds[j] = odd main_sites_distribution[j] = main except KeyError: pass second_odds = {second_site: all_odds_combine[match_combine]["odds"][second_site] for second_site in second_sites if second_site in all_odds_combine[match_combine]["odds"]} if not second_odds: continue dict_combine_odds = copy.deepcopy(second_odds) for perm in permutations(range(n), nb_stakes): valid_perm = True defined_second_sites = [[perm[j], stake[0], stake[1]] for j, stake in enumerate(stakes)] for j, stake in enumerate(stakes): if dict_combine_odds[defined_second_sites[j][2]][defined_second_sites[j][0]] < stake[2]: valid_perm = False break if not valid_perm: if identical_stakes: break continue defined_bets_temp = defined_bets(main_site_odds, dict_combine_odds, main_sites_distribution, defined_second_sites) profit = defined_bets_temp[0] - np.sum(defined_bets_temp[1]) if profit > best_profit: best_profit = profit best_combine = combine best_bets = defined_bets_temp if identical_stakes: break if best_combine: best_match_combine = " / ".join([match[0] for match in best_combine]) odds_best_match = copy.deepcopy(all_odds_combine[best_match_combine]) all_sites = main_sites + list(second_sites) for site in all_odds_combine[best_match_combine]["odds"]: if site not in all_sites: del odds_best_match["odds"][site] print(best_match_combine) pprint(odds_best_match, compact=1) print("Plus-value =", round(best_profit, 2)) print("Gain référence =", round(best_bets[0], 2)) print("Somme des mises =", round(np.sum(best_bets[1]), 2)) afficher_mises_combine([x[0] for x in best_combine], best_bets[2], best_bets[1], all_odds_combine[best_match_combine]["odds"], sport) else: print("No match found")