示例#1
0
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)
示例#2
0
def best_match_cashback(site, minimum_odd, bet, sport="football", freebet=True,
                        combi_max=0, combi_odd=1, rate_cashback=1, date_max=None,
                        time_max=None, date_min=None, time_min=None):
    """
    Retourne le match qui génère le meilleur gain pour une promotion de type
    "Pari remboursé si perdant". Le bonus combi-max, la côte des sélections
    supposées sûres (dans le cadre d'une promotion sur combiné) ainsi que le
    bonus combi-max sont également paramétrables
    """
    odds_function = lambda best_odds, odds_site, i: (best_odds[:i]
                                                     + [combi_odd * 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)
    result_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,
                    result_function, site, sport, date_max, time_max, date_min,
                    time_min)
示例#3
0
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)
    all_odds = filter_dict_minimum_odd(all_odds, minimum_odd_selection, site)
    sportsbetting.ALL_ODDS_COMBINE = {}
    nb_combine = binomial(len(all_odds), nb_matches)
    sportsbetting.PROGRESS = 0

    def compute_all_odds_combine(nb_combine, combine):
        sportsbetting.PROGRESS += 100 / nb_combine
        try:
            sportsbetting.ALL_ODDS_COMBINE[" / ".join([
                match[0] for match in combine
            ])] = cotes_combine_all_sites(*[match[1] for match in combine])
        except KeyError:
            pass

    ThreadPool(4).map(lambda x: compute_all_odds_combine(nb_combine, x),
                      combinations(all_odds.items(), nb_matches))
    sportsbetting.PROGRESS = 0
    odds_function = get_best_odds(one_site)
    profit_function = get_profit(bet, one_site)
    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,
                    combine_opt=True)
示例#5
0
def best_match_under_conditions(site, minimum_odd, bet, sport="football", date_max=None,
                                time_max=None, date_min=None, time_min=None, one_site=False,
                                live=False):
    """
    Retourne le meilleur match sur lequel miser lorsqu'on doit miser une somme
    donnée à une cote donnée. Cette somme peut-être sur seulement une issue
    (one_site=False) ou bien répartie sur plusieurs issues d'un même match
    (one_site=True), auquel cas, chacune des cotes du match doivent respecter le
    critère de cote minimale.
    """
    odds_function = lambda best_odds, odds_site, i: ((best_odds[:i]
                                                      + [odds_site[i] * 0.9 if live else odds_site[
                i]]
                                                      + best_odds[i + 1:]) if not one_site
                                                     else (odds_site[:i]
                                                           + [odds_site[i] * 0.9 if live
                                                              else odds_site[i]]
                                                           + odds_site[i + 1:]))
    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, one_site=one_site)
def best_match_freebet2(site,
                        freebet,
                        sport="football",
                        live=False,
                        date_max=None,
                        time_max=None,
                        date_min=None,
                        time_min=None):
    """
    Retourne le match qui génère le meilleur gain pour un unique freebet placé,
    couvert avec de l'argent réel.
    """
    fact_live = 1 - 0.2 * live
    odds_function = lambda best_odds, odds_site, i: (
        best_odds[:i] + [odds_site[i] * fact_live - 1] + best_odds[i + 1:])
    profit_function = lambda x, i: gain_freebet2(
        x[:i] + [x[i] + 1] + x[i + 1:], freebet, i)
    criteria = lambda odds_to_check, i: True
    display_function = lambda x, i: mises_freebet2(
        x[:i] + [x[i] + 1] + x[i + 1:], freebet, i, True)
    result_function = lambda x, i: mises_freebet2(
        x[:i] + [x[i] + 1] + x[i + 1:], freebet, i, False)
    best_match_base(odds_function,
                    profit_function,
                    criteria,
                    display_function,
                    result_function,
                    site,
                    sport,
                    date_max,
                    time_max,
                    date_min,
                    time_min,
                    freebet=True)
示例#7
0
def best_match_pari_gagnant(site,
                            minimum_odd,
                            bet,
                            sport="football",
                            date_max=None,
                            time_max=None,
                            date_min=None,
                            time_min=None):
    """
    Retourne le meilleur match sur lequel miser lorsqu'on doit gagner un pari à
    une cote donnée sur un site donné.
    """
    odds_function = lambda best_odds, odds_site, i: odds_site
    profit_function = lambda odds_to_check, i: gain2(
        odds_to_check, np.argmax(odds_to_check), bet)
    criteria = lambda odds_to_check, i: all(odd >= minimum_odd
                                            for odd in odds_to_check)
    display_function = lambda best_overall_odds, best_rank: mises2(
        best_overall_odds, bet, np.argmax(best_overall_odds), True)
    result_function = lambda best_overall_odds, best_rank: mises2(
        best_overall_odds, bet, np.argmax(best_overall_odds), False)
    best_match_base(odds_function,
                    profit_function,
                    criteria,
                    display_function,
                    result_function,
                    site,
                    sport,
                    date_max,
                    time_max,
                    date_min,
                    time_min,
                    one_site=True)
示例#8
0
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)
示例#9
0
def best_match_cotes_boostees(site, gain_max, sport="football", date_max=None, time_max=None,
                              date_min=None, time_min=None):
    odds_function = lambda best_odds, odds_site, i: odds_site
    profit_function = lambda odds_to_check, i: gain_gains_nets_boostes(odds_to_check, gain_max,
                                                                       False)
    criteria = lambda odds_to_check, i: odds_to_check[i] >= 1.5
    display_function = lambda odds_to_check, i: mises_gains_nets_boostes(odds_to_check, gain_max,
                                                                         False, True)
    result_function = lambda odds_to_check, i: mises_gains_nets_boostes(odds_to_check, gain_max,
                                                                        False, False)
    best_match_base(odds_function, profit_function, criteria, display_function, result_function,
                    site, sport, date_max, time_max, date_min, time_min)
示例#10
0
def best_match_gain_cote(site, bet, sport="football", date_max=None, time_max=None, date_min=None,
                         time_min=None):
    """
    Retourne le match sur lequel miser pour optimiser une promotion du type "gain de la cote gagnée"
    """
    odds_function = get_best_odds(False)
    profit_function = lambda odds_to_check, i: gain_promo_gain_cote(odds_to_check, bet, i)
    criteria = lambda odds_to_check, i: True
    display_function = lambda best_overall_odds, best_rank: mises_promo_gain_cote(best_overall_odds,
                                                                                  bet, best_rank,
                                                                                  True)
    result_function = lambda best_overall_odds, best_rank: mises_promo_gain_cote(best_overall_odds,
                                                                                 bet, best_rank,
                                                                                 False)
    best_match_base(odds_function, profit_function, criteria, display_function, result_function,
                    site, sport, date_max, time_max, date_min, time_min)
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)
示例#12
0
def best_match_defi_rembourse_ou_gagnant(site,
                                         minimum_odd,
                                         stake,
                                         sport,
                                         date_max=None,
                                         time_max=None,
                                         date_min=None,
                                         time_min=None):
    odds_function = get_best_odds(False)
    profit_function = lambda best_overall_odds, best_rank: gain_defi_rembourse_ou_gagnant(
        best_overall_odds, stake, best_rank, True)
    profit_function = lambda odds_to_check, i: gain_defi_rembourse_ou_gagnant(
        odds_to_check, stake, i)
    criteria = lambda odds_to_check, i: odds_to_check[i] >= minimum_odd
    display_function = lambda best_overall_odds, best_rank: mises_defi_rembourse_ou_gagnant(
        best_overall_odds, stake, best_rank, True)
    result_function = lambda best_overall_odds, best_rank: mises_defi_rembourse_ou_gagnant(
        best_overall_odds, stake, best_rank, False)
    best_match_base(odds_function, profit_function, criteria, display_function,
                    result_function, site, sport, date_max, time_max, date_min,
                    time_min)
示例#13
0
def best_matches_combine2(site,
                          minimum_odd,
                          bet,
                          sport,
                          minimum_odd_selection,
                          date_max=None,
                          time_max=None,
                          date_min=None,
                          time_min=None):
    nb_matches = 2
    all_odds = filter_dict_dates(sb.ODDS[sport], date_max, time_max, date_min,
                                 time_min)
    all_odds = filter_dict_minimum_odd(all_odds, minimum_odd_selection, site)
    odds_combine_opt = [{} for _ in range(6)]
    nb_combine = binomial(len(all_odds), nb_matches)
    sb.PROGRESS = 0
    combis = cotes_combine_optimise([[1 for _ in range(3)]
                                     for i in range(nb_matches)])[1]
    print(combis)

    def compute_all_odds_combine_optimise(nb_combine, combine,
                                          odds_combine_opt):
        sb.PROGRESS += 100 / nb_combine
        try:
            cotes_combination = cotes_combine_reduit_all_sites(
                *[match[1] for match in combine])
            for i in range(6):
                odds_combine_opt[i][" / ".join([match[0] for match in combine
                                                ])] = cotes_combination[i]


#                 combis[i] = cotes_combination[i][1]
        except KeyError:
            pass

    ThreadPool(4).map(
        lambda x: compute_all_odds_combine_optimise(nb_combine, x,
                                                    odds_combine_opt),
        combinations(all_odds.items(), nb_matches))
    sb.PROGRESS = 0
    odds_function = get_best_odds(False)
    profit_function = get_profit(bet, False)
    criteria = lambda odds_to_check, i: all(odd >= minimum_odd
                                            for odd in odds_to_check)
    for i, combination in enumerate(combis):
        sb.ALL_ODDS_COMBINE = odds_combine_opt[i]
        #         display_function = lambda odds_to_check, i: mises_combine_optimise(odds_to_check, combination, bet, minimum_odd, True)
        #         result_function = lambda odds_to_check, i: mises_combine_optimise(odds_to_check, combination, bet, minimum_odd, False)
        display_function = lambda best_overall_odds, best_rank: mises2(
            best_overall_odds, bet, best_rank, True)
        result_function = lambda best_overall_odds, best_rank: mises2(
            best_overall_odds, bet, best_rank, 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,
                        combine_opt=True)