from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import pandas as pd from math import sqrt #fav_club_df = pd.read_excel('survey/fav_club.xlsx') #fav_club_df.phone_num = fav_club_df.phone_num.astype(str) bookkeeper_odds_df = pd.read_excel('kenya_survey/bookkeeper_odds.xlsx') teams_df = pd.read_excel('kenya_survey/PRESCREENER DATA 01012021.xlsx') teams_df["Phone number"] = teams_df["Phone number"].astype(str) teams_df['phone_num'] = teams_df["Phone number"].str[3:] teams_df['phone_num'] = teams_df.phone_num.str.pad(10, side="left", fillchar="0") class Introduction(Page): form_model = 'player' form_fields = ['declaration', 'Introduction_time'] class TestWedge(Page): form_model = 'player' form_fields = ['wedge'] class RejectSurvey(Page): form_model = 'player' def is_displayed(self): return self.player.declaration == 0 class PhoneNum(Page): form_model = 'player' form_fields = ['phone_num', 'PhoneNum_time'] def error_message(self, values): if sum([p.phone_num == values['phone_num'] for p in self.group.get_players() if p.completed == 1]) > 0: return "Sorry, this phone number has already been used to complete this survey once" # def before_next_page(self): # self.participant.vars['team'] = teams_df['Which Premier League Club do you support the most (favourite team)? Please select one club or select None.'] class Kwa_Treat(Page): form_model = 'player' form_fields = ['matchbet_1_win', 'matchbet_1_draw', 'matchbet_1_lose', 'matchbet_1_sum', 'KwaTreat_time'] def vars_for_template(self): return dict( supp_team = teams_df.loc[teams_df['phone_num'] == self.player.phone_num, "Which Premier League Club do you support the most (favourite team)? Please select one club or select None."].iloc[0], ) class Description_page(Page): form_model = 'player' form_fields = ['Description_page_time'] class FavClub(Page): form_model = 'player' form_fields = ['fav_club_none', 'fav_club_mufc', 'fav_club_lpool', 'fav_club_nufc', 'fav_club_ars', 'fav_club_sfc', 'fav_club_lei', 'fav_club_efc', 'fav_club_avfc', 'fav_club_cpfc', 'fav_club_cfc', 'fav_club_sufc', 'fav_club_spurs', 'fav_club_whu', 'FavClub_time'] def is_displayed(self): return (self.player.phone_num not in fav_club_df['phone_num'].values.tolist()) def vars_for_template(self): return dict( home_team1=bookkeeper_odds_df['match1_home_team'].iloc[0], away_team1=bookkeeper_odds_df['match1_away_team'].iloc[0], home_team2=bookkeeper_odds_df['match2_home_team'].iloc[0], away_team2=bookkeeper_odds_df['match2_away_team'].iloc[0], home_team3=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team3=bookkeeper_odds_df['match3_away_team'].iloc[0], home_team4=bookkeeper_odds_df['match4_home_team'].iloc[0], away_team4=bookkeeper_odds_df['match4_away_team'].iloc[0], phone_num_isin_r1 = 1 if self.player.phone_num in fav_club_df['phone_num'].values.tolist() else 0, ) class BettingBehavior(Page): form_model = 'player' form_fields = ['num_matches_watched', 'bet_freq', 'BettingBehavior_time'] class MatchBeliefs_a(Page): form_model = 'player' form_fields = ['match_1_win', 'match_1_draw', 'match_1_lose', 'match_1_sum', 'MatchBeliefs_a_time'] def vars_for_template(self): return dict( home_team1=bookkeeper_odds_df['match1_home_team'].iloc[0], away_team1=bookkeeper_odds_df['match1_away_team'].iloc[0], home_team1_abbv=bookkeeper_odds_df['match1_home_team_abbv'].iloc[0], away_team1_abbv=bookkeeper_odds_df['match1_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_1_win', 'match_1_draw', 'match_1_lose']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_b(Page): form_model = 'player' form_fields = ['match_2_win', 'match_2_draw', 'match_2_lose', 'match_2_sum', 'MatchBeliefs_b_time'] def vars_for_template(self): return dict( home_team2=bookkeeper_odds_df['match2_home_team'].iloc[0], away_team2=bookkeeper_odds_df['match2_away_team'].iloc[0], home_team2_abbv=bookkeeper_odds_df['match2_home_team_abbv'].iloc[0], away_team2_abbv=bookkeeper_odds_df['match2_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_2_win', 'match_2_draw', 'match_2_lose']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_c(Page): form_model = 'player' form_fields = ['match_3_win', 'match_3_draw', 'match_3_lose', 'match_3_sum', 'MatchBeliefs_c_time'] def vars_for_template(self): # if self.player.benchmark_treat == "Watford vs ManU": # home_team3=bookkeeper_odds_df['match4_home_team'].iloc[0], # away_team3=bookkeeper_odds_df['match4_away_team'].iloc[0], # home_team3_abbv=bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], # away_team3_abbv=bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] # else: # home_team3 = bookkeeper_odds_df['match3_home_team'].iloc[0], # away_team3 = bookkeeper_odds_df['match3_away_team'].iloc[0], # home_team3_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], # away_team3_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] # return dict( # home_team3=home_team3[0], # away_team3=away_team3[0], # home_team3_abbv=home_team3_abbv[0], # away_team3_abbv=away_team3_abbv # ) return dict( home_team3=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team3=bookkeeper_odds_df['match3_away_team'].iloc[0], home_team3_abbv=bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team3_abbv=bookkeeper_odds_df['match3_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_3_win', 'match_3_draw', 'match_3_lose']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_c_post(Page): form_model = 'player' form_fields = ['match_3_win_post', 'match_3_draw_post', 'match_3_lose_post', 'match_3_sum_post', 'MatchBeliefs_c_post_time'] def vars_for_template(self): if self.player.benchmark_treat == "Watford vs ManU": home_team3=bookkeeper_odds_df['match4_home_team'].iloc[0], away_team3=bookkeeper_odds_df['match4_away_team'].iloc[0], home_team3_abbv=bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team3_abbv=bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] else: home_team3 = bookkeeper_odds_df['match3_home_team'].iloc[0], away_team3 = bookkeeper_odds_df['match3_away_team'].iloc[0], home_team3_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team3_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] return dict( home_team3=home_team3[0], away_team3=away_team3[0], home_team3_abbv=home_team3_abbv[0], away_team3_abbv=away_team3_abbv ) def error_message(self, values): for field_name in ['match_3_win_post', 'match_3_draw_post', 'match_3_lose_post']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_d(Page): form_model = 'player' form_fields = ['match_4_win', 'match_4_draw', 'match_4_lose', 'match_4_sum', 'MatchBeliefs_d_time'] def vars_for_template(self): # if self.player.benchmark_treat == "Watford vs ManU": # home_team4=bookkeeper_odds_df['match3_home_team'].iloc[0], # away_team4=bookkeeper_odds_df['match3_away_team'].iloc[0], # home_team4_abbv=bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], # away_team4_abbv=bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] # else: # home_team4 = bookkeeper_odds_df['match4_home_team'].iloc[0], # away_team4 = bookkeeper_odds_df['match4_away_team'].iloc[0], # home_team4_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], # away_team4_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] # return dict( # home_team4=home_team4[0], # away_team4=away_team4[0], # home_team4_abbv=home_team4_abbv[0], # away_team4_abbv=away_team4_abbv # ) return dict( home_team4=bookkeeper_odds_df['match4_home_team'].iloc[0], away_team4=bookkeeper_odds_df['match4_away_team'].iloc[0], home_team4_abbv=bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team4_abbv=bookkeeper_odds_df['match4_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_4_win', 'match_4_draw', 'match_4_lose']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_d_post(Page): form_model = 'player' form_fields = ['match_4_win_post', 'match_4_draw_post', 'match_4_lose_post', 'match_4_sum_post', 'MatchBeliefs_d_post_time'] def vars_for_template(self): if self.player.benchmark_treat == "Watford vs ManU": home_team4=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team4=bookkeeper_odds_df['match3_away_team'].iloc[0], home_team4_abbv=bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team4_abbv=bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] else: home_team4 = bookkeeper_odds_df['match4_home_team'].iloc[0], away_team4 = bookkeeper_odds_df['match4_away_team'].iloc[0], home_team4_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team4_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] return dict( home_team4=home_team4[0], away_team4=away_team4[0], home_team4_abbv=home_team4_abbv[0], away_team4_abbv=away_team4_abbv ) def error_message(self, values): for field_name in ['match_4_win_post', 'match_4_draw_post', 'match_4_lose_post']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class MatchBeliefs_e(Page): form_model = 'player' form_fields = ['match_5_win', 'match_5_draw', 'match_5_lose', 'match_5_sum', 'MatchBeliefs_e_time'] def vars_for_template(self): return dict( home_team5=bookkeeper_odds_df['match5_home_team'].iloc[0], away_team5=bookkeeper_odds_df['match5_away_team'].iloc[0], home_team5_abbv=bookkeeper_odds_df['match5_home_team_abbv'].iloc[0], away_team5_abbv=bookkeeper_odds_df['match5_away_team_abbv'].iloc[0], ) def error_message(self, values): for field_name in ['match_5_win', 'match_5_draw', 'match_5_lose']: if values[field_name] > 98 or values[field_name] == 0: return 'Please do not select 100 or 0 as options' class BetIntro(Page): form_model = 'player' form_fields = ['BetIntro_time'] class BetPrimer(Page): form_model = 'player' form_fields = ['bet_primer1', 'bet_primer2', 'BetPrimer_time'] class BetPrimer_correct(Page): form_model = 'player' form_fields = ['BetPrimer_correct_time'] def is_displayed(self): return self.player.bet_primer1 == 0 and self.player.bet_primer2 == 100 class BetPrimer_wrong(Page): form_model = 'player' form_fields = ['BetPrimer_wrong_time'] def is_displayed(self): return self.player.bet_primer1 != 0 or self.player.bet_primer2 != 100 class Benchmark_Treat(Page): form_model = 'player' form_fields = ['Benchmark_Treat_time'] def vars_for_template(self): if self.player.benchmark_treat == "Watford vs ManU": home_team = bookkeeper_odds_df['match3_home_team'].iloc[0], away_team = bookkeeper_odds_df['match3_away_team'].iloc[0], home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] else: home_team = bookkeeper_odds_df['match4_home_team'].iloc[0], away_team = bookkeeper_odds_df['match4_away_team'].iloc[0], home_team_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] bm_home = bookkeeper_odds_df['match4_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match4_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match4_away_team_odds'].iloc[0] scaling_factor = 1/bm_home + 1/bm_draw + 1/bm_away prob_homewin = 1 / (bm_home * scaling_factor) prob_draw = 1 / (bm_draw * scaling_factor) prob_awaywin = 1 / (bm_away * scaling_factor) return dict( prob_homewin=round(prob_homewin*100), prob_draw=round(prob_draw*100), prob_awaywin=round(prob_awaywin*100), home_team_abbv = home_team_abbv[0], away_team_abbv = away_team_abbv, home_team = home_team[0], away_team = away_team[0], ) class MatchBet_a(Page): form_model = 'player' form_fields = ['matchbet_1_win', 'matchbet_1_draw', 'matchbet_1_lose', 'matchbet_1_sum', 'matchbet_1_winodds', 'matchbet_1_drawodds', 'matchbet_1_loseodds', 'match_1_watch', 'match_1_desiredresult', #'match_1_affectresult', 'MatchBet_a_time'] def vars_for_template(self): bm_home = bookkeeper_odds_df['match1_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match1_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match1_away_team_odds'].iloc[0] wedge = self.player.wedge1 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) # elif wedge <0: # probability_wedge = -1*(sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*wedge + bm_away - (bm_home*wedge) + bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = bookkeeper_odds_df['match1_home_team_abbv'].iloc[0], home_team_odds = home_team_odds, away_team_abbv = bookkeeper_odds_df['match1_away_team_abbv'].iloc[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team=bookkeeper_odds_df['match1_home_team'].iloc[0], away_team=bookkeeper_odds_df['match1_away_team'].iloc[0], # probability_wedge = probability_wedge, # wedge=wedge, # bm_home=bm_home, # bm_draw=bm_draw, # bm_away=bm_away ) class MatchBet_b(Page): form_model = 'player' form_fields = ['matchbet_2_win', 'matchbet_2_draw', 'matchbet_2_lose', 'matchbet_2_sum', 'matchbet_2_winodds', 'matchbet_2_drawodds', 'matchbet_2_loseodds', 'match_2_watch', 'match_2_desiredresult', #'match_2_affectresult', 'MatchBet_b_time'] def vars_for_template(self): bm_home = bookkeeper_odds_df['match2_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match2_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match2_away_team_odds'].iloc[0] wedge = self.player.wedge2 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = bookkeeper_odds_df['match2_home_team_abbv'].iloc[0], home_team_odds = home_team_odds, away_team_abbv = bookkeeper_odds_df['match2_away_team_abbv'].iloc[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team=bookkeeper_odds_df['match2_home_team'].iloc[0], away_team=bookkeeper_odds_df['match2_away_team'].iloc[0], ) class MatchBet_c(Page): form_model = 'player' form_fields = ['matchbet_3_win', 'matchbet_3_draw', 'matchbet_3_lose', 'matchbet_3_sum', 'matchbet_3_winodds', 'matchbet_3_drawodds', 'matchbet_3_loseodds', 'match_3_watch', 'match_3_desiredresult', #'match_3_affectresult', 'MatchBet_c_time'] def vars_for_template(self): # if self.player.benchmark_treat == "Watford vs ManU": # home_team = bookkeeper_odds_df['match4_home_team'].iloc[0], # away_team = bookkeeper_odds_df['match4_away_team'].iloc[0], # home_team_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], # away_team_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] # bm_home = bookkeeper_odds_df['match4_home_team_odds'].iloc[0] # bm_draw = bookkeeper_odds_df['match4_draw_odds'].iloc[0] # bm_away = bookkeeper_odds_df['match4_away_team_odds'].iloc[0] # wedge = self.player.wedge3 # else: # home_team = bookkeeper_odds_df['match3_home_team'].iloc[0], # away_team = bookkeeper_odds_df['match3_away_team'].iloc[0], # home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], # away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] # bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] # bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] # bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] # wedge = self.player.wedge3 home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0], home_team = bookkeeper_odds_df['match3_home_team'].iloc[0], away_team = bookkeeper_odds_df['match3_away_team'].iloc[0], bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] wedge = self.player.wedge3 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = home_team_abbv[0], home_team_odds = home_team_odds, away_team_abbv = away_team_abbv[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team = home_team[0], away_team = away_team[0], ) class MatchBet_d(Page): form_model = 'player' form_fields = ['matchbet_4_win', 'matchbet_4_draw', 'matchbet_4_lose', 'matchbet_4_sum', 'matchbet_4_winodds', 'matchbet_4_drawodds', 'matchbet_4_loseodds', 'match_4_watch', 'match_4_desiredresult', #'match_4_affectresult', 'MatchBet_d_time', 'completed'] def vars_for_template(self): # if self.player.benchmark_treat == "Watford vs ManU": # home_team = bookkeeper_odds_df['match3_home_team'].iloc[0], # away_team = bookkeeper_odds_df['match3_away_team'].iloc[0], # home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], # away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] # bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] # bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] # bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] # wedge = self.player.wedge3 # else: # home_team = bookkeeper_odds_df['match4_home_team'].iloc[0], # away_team = bookkeeper_odds_df['match4_away_team'].iloc[0], # home_team_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], # away_team_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] # bm_home = bookkeeper_odds_df['match4_home_team_odds'].iloc[0] # bm_draw = bookkeeper_odds_df['match4_draw_odds'].iloc[0] # bm_away = bookkeeper_odds_df['match4_away_team_odds'].iloc[0] # wedge = self.player.wedge4 home_team_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0], away_team_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0], home_team = bookkeeper_odds_df['match4_home_team'].iloc[0], away_team = bookkeeper_odds_df['match4_away_team'].iloc[0], bm_home = bookkeeper_odds_df['match4_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match4_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match4_away_team_odds'].iloc[0] wedge = self.player.wedge4 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = home_team_abbv[0], home_team_odds = home_team_odds, away_team_abbv = away_team_abbv[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team = home_team[0], away_team = away_team[0], ) class MatchBet_e(Page): form_model = 'player' form_fields = ['matchbet_5_win', 'matchbet_5_draw', 'matchbet_5_lose', 'matchbet_5_sum', 'matchbet_5_winodds', 'matchbet_5_drawodds', 'matchbet_5_loseodds', 'match_5_watch', 'match_5_desiredresult', 'MatchBet_e_time'] def vars_for_template(self): bm_home = bookkeeper_odds_df['match5_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match5_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match5_away_team_odds'].iloc[0] wedge = self.player.wedge5 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = bookkeeper_odds_df['match5_home_team_abbv'].iloc[0], home_team_odds = home_team_odds, away_team_abbv = bookkeeper_odds_df['match5_away_team_abbv'].iloc[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team=bookkeeper_odds_df['match5_home_team'].iloc[0], away_team=bookkeeper_odds_df['match5_away_team'].iloc[0], ) class MatchBet_e_old2(Page): form_model = 'player' form_fields = ['matchbet_5_win', 'matchbet_5_draw', 'matchbet_5_lose', 'matchbet_5_sum', 'matchbet_5_winodds', 'matchbet_5_drawodds', 'matchbet_5_loseodds', 'MatchBet_e_time', 'completed'] def vars_for_template(self): subj_prob_homewin = 50 subj_prob_draw = 20 subj_prob_awaywin = 30 bm_home = 2.45 bm_draw = 3.3 bm_away = 2.9 wedge = self.player.wedge5 if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = "Home", home_team_odds = home_team_odds, away_team_abbv = "Away", away_team_odds = away_team_odds, draw_odds = bm_draw, home_team ="Home Team", away_team ="Away Team", subj_prob_homewin = subj_prob_homewin, subj_prob_draw = subj_prob_draw, subj_prob_awaywin = subj_prob_awaywin ) class MatchBet_d_old(Page): form_model = 'player' form_fields = ['matchbet_3a_win', 'matchbet_3a_draw', 'matchbet_3a_lose', 'matchbet_3a_sum', 'matchbet_3a_winodds', 'matchbet_3a_drawodds', 'matchbet_3a_loseodds', 'MatchBet_d_time'] def vars_for_template(self): bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] wedge = self.player.wedge3a if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], home_team_odds = home_team_odds, away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team=bookkeeper_odds_df['match3_away_team'].iloc[0], ) class MatchBet_e_old(Page): form_model = 'player' form_fields = ['matchbet_3b_win', 'matchbet_3b_draw', 'matchbet_3b_lose', 'matchbet_3b_sum', 'matchbet_3b_winodds', 'matchbet_3b_drawodds', 'matchbet_3b_loseodds', 'MatchBet_e_time'] def vars_for_template(self): bm_home = bookkeeper_odds_df['match3_home_team_odds'].iloc[0] bm_draw = bookkeeper_odds_df['match3_draw_odds'].iloc[0] bm_away = bookkeeper_odds_df['match3_away_team_odds'].iloc[0] wedge = self.player.wedge3b if wedge != 0: probability_wedge = (sqrt((4*bm_away*bm_home*(wedge**2)) + (bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home)**2) + bm_away*(-wedge) - bm_away + (bm_home*wedge) - bm_home) / (2 * bm_away * bm_home * wedge) else: probability_wedge = 0 home_team_odds = round(1 / ((1/bm_home) + probability_wedge), 2) away_team_odds = round(1 / ((1/bm_away) - probability_wedge), 2) return dict( home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0], home_team_odds = home_team_odds, away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0], away_team_odds = away_team_odds, draw_odds = bm_draw, home_team=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team=bookkeeper_odds_df['match3_away_team'].iloc[0], ) class MatchBet_a_Change(Page): form_model = 'player' form_fields = ['matchbet_1_change_win', 'matchbet_1_change_draw', 'matchbet_1_change_lose', 'matchbet_1_change_sum', 'match_1_changechoice', 'MatchBet_a_change_time'] def vars_for_template(self): home_team_abbv = bookkeeper_odds_df['match1_home_team_abbv'].iloc[0] away_team_abbv = bookkeeper_odds_df['match1_away_team_abbv'].iloc[0] win_prob = self.player.match_1_win lose_prob = self.player.match_1_lose draw_prob = self.player.match_1_draw win_payout_subj = round(self.player.match_1_win / 100 * self.player.matchbet_1_winodds, 2) lose_payout_subj = round(self.player.match_1_lose / 100 * self.player.matchbet_1_loseodds, 2) draw_payout_subj = round(self.player.match_1_draw / 100 * self.player.matchbet_1_drawodds, 2) bm_probhome = 1/bookkeeper_odds_df['match1_home_team_odds'].iloc[0] bm_probdraw = 1/bookkeeper_odds_df['match1_draw_odds'].iloc[0] bm_probaway = 1/bookkeeper_odds_df['match1_away_team_odds'].iloc[0] scaling_factor = bm_probhome + bm_probdraw + bm_probaway win_prob_bm = int(round(100*bm_probhome/scaling_factor)) lose_prob_bm = int(round(100*bm_probaway/scaling_factor)) draw_prob_bm = int(round(100*bm_probdraw/scaling_factor)) if self.player.wedge1 == 0: win_payout_bm = 1 lose_payout_bm = 1 draw_payout_bm = 1 else: win_payout_bm = round(win_prob_bm / 100 * self.player.matchbet_1_winodds, 2) lose_payout_bm = round(lose_prob_bm / 100 * self.player.matchbet_1_loseodds, 2) draw_payout_bm = round(draw_prob_bm / 100 * self.player.matchbet_1_drawodds, 2) return dict( home_team=bookkeeper_odds_df['match1_home_team'].iloc[0], away_team=bookkeeper_odds_df['match1_away_team'].iloc[0], home_team_abbv=home_team_abbv, away_team_abbv=away_team_abbv, home_team_odds=self.player.matchbet_1_winodds, draw_odds=self.player.matchbet_1_drawodds, away_team_odds=self.player.matchbet_1_loseodds, win_bet=self.player.matchbet_1_win, draw_bet=self.player.matchbet_1_draw, lose_bet=self.player.matchbet_1_lose, win_prob=win_prob, draw_prob=draw_prob, lose_prob=lose_prob, win_payout_subj=win_payout_subj, draw_payout_subj=draw_payout_subj, lose_payout_subj=lose_payout_subj, win_prob_bm=win_prob_bm, draw_prob_bm=draw_prob_bm, lose_prob_bm=lose_prob_bm, win_payout_bm=win_payout_bm, draw_payout_bm=draw_payout_bm, lose_payout_bm=lose_payout_bm, max_option_subj="a home win by " + home_team_abbv if win_payout_subj == max(win_payout_subj, lose_payout_subj, draw_payout_subj) else "an away win by " + away_team_abbv if lose_payout_subj == max( win_payout_subj, lose_payout_subj, draw_payout_subj) else "a draw", max_option_bm="a home win by " + home_team_abbv if win_payout_bm == max(win_payout_bm, lose_payout_bm, draw_payout_bm) else "an away win by " + away_team_abbv if lose_payout_bm == max( win_payout_bm, lose_payout_bm, draw_payout_bm) else "a draw" ) def error_message(self, values): if values['match_1_changechoice'] == "Yes" and values['matchbet_1_change_sum'] != 100: return 'Please enter your updated bets' if values['match_1_changechoice'] == "No" and values['matchbet_1_change_sum'] != 0: return 'Please enter 0 for all the tokens or leave them blank if you do not wish to change your previous bets' class MatchBet_b_Change(Page): form_model = 'player' form_fields = ['matchbet_2_change_win', 'matchbet_2_change_draw', 'matchbet_2_change_lose', 'matchbet_2_change_sum', 'match_2_changechoice', 'MatchBet_b_change_time'] def vars_for_template(self): home_team_abbv = bookkeeper_odds_df['match2_home_team_abbv'].iloc[0] away_team_abbv = bookkeeper_odds_df['match2_away_team_abbv'].iloc[0] win_prob = self.player.match_2_win lose_prob = self.player.match_2_lose draw_prob = self.player.match_2_draw win_payout_subj = round(self.player.match_2_win / 100 * self.player.matchbet_2_winodds, 2) lose_payout_subj = round(self.player.match_2_lose / 100 * self.player.matchbet_2_loseodds, 2) draw_payout_subj = round(self.player.match_2_draw / 100 * self.player.matchbet_2_drawodds, 2) bm_probhome = 1 / bookkeeper_odds_df['match2_home_team_odds'].iloc[0] bm_probdraw = 1 / bookkeeper_odds_df['match2_draw_odds'].iloc[0] bm_probaway = 1 / bookkeeper_odds_df['match2_away_team_odds'].iloc[0] scaling_factor = bm_probhome + bm_probdraw + bm_probaway win_prob_bm = int(round(100 * bm_probhome / scaling_factor)) lose_prob_bm = int(round(100 * bm_probaway / scaling_factor)) draw_prob_bm = int(round(100 * bm_probdraw / scaling_factor)) if self.player.wedge2 == 0: win_payout_bm = 1 lose_payout_bm = 1 draw_payout_bm = 1 else: win_payout_bm = round(win_prob_bm / 100 * self.player.matchbet_2_winodds, 2) lose_payout_bm = round(lose_prob_bm / 100 * self.player.matchbet_2_loseodds, 2) draw_payout_bm = round(draw_prob_bm / 100 * self.player.matchbet_2_drawodds, 2) return dict( home_team=bookkeeper_odds_df['match2_home_team'].iloc[0], away_team=bookkeeper_odds_df['match2_away_team'].iloc[0], home_team_abbv=home_team_abbv, away_team_abbv=away_team_abbv, home_team_odds=self.player.matchbet_2_winodds, draw_odds=self.player.matchbet_2_drawodds, away_team_odds=self.player.matchbet_2_loseodds, win_bet=self.player.matchbet_2_win, draw_bet=self.player.matchbet_2_draw, lose_bet=self.player.matchbet_2_lose, win_prob=win_prob, draw_prob=draw_prob, lose_prob=lose_prob, win_payout_subj=win_payout_subj, draw_payout_subj=draw_payout_subj, lose_payout_subj=lose_payout_subj, win_prob_bm=win_prob_bm, draw_prob_bm=draw_prob_bm, lose_prob_bm=lose_prob_bm, win_payout_bm=win_payout_bm, draw_payout_bm=draw_payout_bm, lose_payout_bm=lose_payout_bm, max_option_subj="a home win by " + home_team_abbv if win_payout_subj == max(win_payout_subj, lose_payout_subj, draw_payout_subj) else "an away win by " + away_team_abbv if lose_payout_subj == max( win_payout_subj, lose_payout_subj, draw_payout_subj) else "a draw", max_option_bm="a home win by " + home_team_abbv if win_payout_bm == max(win_payout_bm, lose_payout_bm, draw_payout_bm) else "an away win by " + away_team_abbv if lose_payout_bm == max( win_payout_bm, lose_payout_bm, draw_payout_bm) else "a draw" ) def error_message(self, values): if values['match_2_changechoice'] == "Yes" and values['matchbet_2_change_sum'] != 100: return 'Please enter your updated bets' if values['match_2_changechoice'] == "No" and values['matchbet_2_change_sum'] != 0: return 'Please enter 0 for all the tokens or leave them blank if you do not wish to change your previous bets' class MatchBet_c_Change(Page): form_model = 'player' form_fields = ['matchbet_3_change_win', 'matchbet_3_change_draw', 'matchbet_3_change_lose', 'matchbet_3_change_sum', 'match_3_changechoice', 'MatchBet_c_change_time'] def vars_for_template(self): home_team_abbv = bookkeeper_odds_df['match3_home_team_abbv'].iloc[0] away_team_abbv = bookkeeper_odds_df['match3_away_team_abbv'].iloc[0] win_prob = self.player.match_3_win lose_prob = self.player.match_3_lose draw_prob = self.player.match_3_draw win_payout_subj = round(self.player.match_3_win / 100 * self.player.matchbet_3_winodds, 2) lose_payout_subj = round(self.player.match_3_lose / 100 * self.player.matchbet_3_loseodds, 2) draw_payout_subj = round(self.player.match_3_draw / 100 * self.player.matchbet_3_drawodds, 2) bm_probhome = 1 / bookkeeper_odds_df['match3_home_team_odds'].iloc[0] bm_probdraw = 1 / bookkeeper_odds_df['match3_draw_odds'].iloc[0] bm_probaway = 1 / bookkeeper_odds_df['match3_away_team_odds'].iloc[0] scaling_factor = bm_probhome + bm_probdraw + bm_probaway win_prob_bm = int(round(100 * bm_probhome / scaling_factor)) lose_prob_bm = int(round(100 * bm_probaway / scaling_factor)) draw_prob_bm = int(round(100 * bm_probdraw / scaling_factor)) if self.player.wedge3 == 0: win_payout_bm = 1 lose_payout_bm = 1 draw_payout_bm = 1 else: win_payout_bm = round(win_prob_bm / 100 * self.player.matchbet_3_winodds, 2) lose_payout_bm = round(lose_prob_bm / 100 * self.player.matchbet_3_loseodds, 2) draw_payout_bm = round(draw_prob_bm / 100 * self.player.matchbet_3_drawodds, 2) return dict( home_team=bookkeeper_odds_df['match3_home_team'].iloc[0], away_team=bookkeeper_odds_df['match3_away_team'].iloc[0], home_team_abbv=home_team_abbv, away_team_abbv=away_team_abbv, home_team_odds=self.player.matchbet_3_winodds, draw_odds=self.player.matchbet_3_drawodds, away_team_odds=self.player.matchbet_3_loseodds, win_bet=self.player.matchbet_3_win, draw_bet=self.player.matchbet_3_draw, lose_bet=self.player.matchbet_3_lose, win_prob=win_prob, draw_prob=draw_prob, lose_prob=lose_prob, win_payout_subj=win_payout_subj, draw_payout_subj=draw_payout_subj, lose_payout_subj=lose_payout_subj, win_prob_bm=win_prob_bm, draw_prob_bm=draw_prob_bm, lose_prob_bm=lose_prob_bm, win_payout_bm=win_payout_bm, draw_payout_bm=draw_payout_bm, lose_payout_bm=lose_payout_bm, max_option_subj="a home win by " + home_team_abbv if win_payout_subj == max(win_payout_subj, lose_payout_subj, draw_payout_subj) else "an away win by " + away_team_abbv if lose_payout_subj == max( win_payout_subj, lose_payout_subj, draw_payout_subj) else "a draw", max_option_bm="a home win by " + home_team_abbv if win_payout_bm == max(win_payout_bm, lose_payout_bm, draw_payout_bm) else "an away win by " + away_team_abbv if lose_payout_bm == max( win_payout_bm, lose_payout_bm, draw_payout_bm) else "a draw" ) def error_message(self, values): if values['match_3_changechoice'] == "Yes" and values['matchbet_3_change_sum'] != 100: return 'Please enter your updated bets' if values['match_3_changechoice'] == "No" and values['matchbet_3_change_sum'] != 0: return 'Please enter 0 for all the tokens or leave them blank if you do not wish to change your previous bets' class MatchBet_d_Change(Page): form_model = 'player' form_fields = ['matchbet_4_change_win', 'matchbet_4_change_draw', 'matchbet_4_change_lose', 'matchbet_4_change_sum', 'match_4_changechoice', 'MatchBet_d_change_time'] def vars_for_template(self): home_team_abbv = bookkeeper_odds_df['match4_home_team_abbv'].iloc[0] away_team_abbv = bookkeeper_odds_df['match4_away_team_abbv'].iloc[0] win_prob = self.player.match_4_win lose_prob = self.player.match_4_lose draw_prob = self.player.match_4_draw win_payout_subj = round(self.player.match_4_win / 100 * self.player.matchbet_4_winodds, 2) lose_payout_subj = round(self.player.match_4_lose / 100 * self.player.matchbet_4_loseodds, 2) draw_payout_subj = round(self.player.match_4_draw / 100 * self.player.matchbet_4_drawodds, 2) bm_probhome = 1 / bookkeeper_odds_df['match4_home_team_odds'].iloc[0] bm_probdraw = 1 / bookkeeper_odds_df['match4_draw_odds'].iloc[0] bm_probaway = 1 / bookkeeper_odds_df['match4_away_team_odds'].iloc[0] scaling_factor = bm_probhome + bm_probdraw + bm_probaway win_prob_bm = int(round(100 * bm_probhome / scaling_factor)) lose_prob_bm = int(round(100 * bm_probaway / scaling_factor)) draw_prob_bm = int(round(100 * bm_probdraw / scaling_factor)) if self.player.wedge4 == 0: win_payout_bm = 1 lose_payout_bm = 1 draw_payout_bm = 1 else: win_payout_bm = round(win_prob_bm / 100 * self.player.matchbet_4_winodds, 2) lose_payout_bm = round(lose_prob_bm / 100 * self.player.matchbet_4_loseodds, 2) draw_payout_bm = round(draw_prob_bm / 100 * self.player.matchbet_4_drawodds, 2) return dict( home_team=bookkeeper_odds_df['match4_home_team'].iloc[0], away_team=bookkeeper_odds_df['match4_away_team'].iloc[0], home_team_abbv=home_team_abbv, away_team_abbv=away_team_abbv, home_team_odds=self.player.matchbet_4_winodds, draw_odds=self.player.matchbet_4_drawodds, away_team_odds=self.player.matchbet_4_loseodds, win_bet=self.player.matchbet_4_win, draw_bet=self.player.matchbet_4_draw, lose_bet=self.player.matchbet_4_lose, win_prob=win_prob, draw_prob=draw_prob, lose_prob=lose_prob, win_payout_subj=win_payout_subj, draw_payout_subj=draw_payout_subj, lose_payout_subj=lose_payout_subj, win_prob_bm=win_prob_bm, draw_prob_bm=draw_prob_bm, lose_prob_bm=lose_prob_bm, win_payout_bm=win_payout_bm, draw_payout_bm=draw_payout_bm, lose_payout_bm=lose_payout_bm, max_option_subj="a home win by " + home_team_abbv if win_payout_subj == max(win_payout_subj, lose_payout_subj, draw_payout_subj) else "an away win by " + away_team_abbv if lose_payout_subj == max( win_payout_subj, lose_payout_subj, draw_payout_subj) else "a draw", max_option_bm="a home win by " + home_team_abbv if win_payout_bm == max(win_payout_bm, lose_payout_bm, draw_payout_bm) else "an away win by " + away_team_abbv if lose_payout_bm == max( win_payout_bm, lose_payout_bm, draw_payout_bm) else "a draw" ) def error_message(self, values): if values['match_4_changechoice'] == "Yes" and values['matchbet_4_change_sum'] != 100: return 'Please enter your updated bets' if values['match_4_changechoice'] == "No" and values['matchbet_4_change_sum'] != 0: return 'Please enter 0 for all the tokens or leave them blank if you do not wish to change your previous bets' class AppropriateBet(Page): form_model = 'player' form_fields = ['appbet_0', 'appbet_1', 'appbet_10', 'appbet_25', 'appbet_50', 'appbet_75', 'appbet_100', 'page14_time'] class PotentialBonus(Page): form_model = 'player' form_fields = ['PotentialBonus_time'] def vars_for_template(self): if self.player.payout_matchnum == 1: home_team = bookkeeper_odds_df['match1_home_team'].iloc[0] away_team = bookkeeper_odds_df['match1_away_team'].iloc[0] home_team_winodds = self.player.matchbet_1_winodds home_team_loseodds = self.player.matchbet_1_loseodds draw_odds = self.player.matchbet_1_drawodds # win_bet = self.player.matchbet_1_win # lose_bet = self.player.matchbet_1_lose # draw_bet = self.player.matchbet_1_draw # win_payoff = round(self.player.matchbet_1_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_1_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_1_draw * draw_odds, 2) win_bet = self.player.matchbet_1_change_win lose_bet = self.player.matchbet_1_change_lose draw_bet = self.player.matchbet_1_change_draw win_payoff = round(self.player.matchbet_1_change_win * home_team_winodds, 2) lose_payoff = round(self.player.matchbet_1_change_lose * home_team_loseodds, 2) draw_payoff = round(self.player.matchbet_1_change_draw * draw_odds, 2) elif self.player.payout_matchnum == 2: home_team = bookkeeper_odds_df['match2_home_team'].iloc[0] away_team = bookkeeper_odds_df['match2_away_team'].iloc[0] home_team_winodds = self.player.matchbet_2_winodds home_team_loseodds = self.player.matchbet_2_loseodds draw_odds = self.player.matchbet_2_drawodds # win_bet = self.player.matchbet_2_win # lose_bet = self.player.matchbet_2_lose # draw_bet = self.player.matchbet_2_draw # win_payoff = round(self.player.matchbet_2_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_2_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_2_draw * draw_odds, 2) win_bet = self.player.matchbet_2_change_win lose_bet = self.player.matchbet_2_change_lose draw_bet = self.player.matchbet_2_change_draw win_payoff = round(self.player.matchbet_2_change_win * home_team_winodds, 2) lose_payoff = round(self.player.matchbet_2_change_lose * home_team_loseodds, 2) draw_payoff = round(self.player.matchbet_2_change_draw * draw_odds, 2) elif self.player.payout_matchnum == 3: # if self.player.benchmark_treat == "Watford vs ManU": # home_team = bookkeeper_odds_df['match4_home_team'].iloc[0] # away_team = bookkeeper_odds_df['match4_away_team'].iloc[0] # else: # home_team = bookkeeper_odds_df['match3_home_team'].iloc[0] # away_team = bookkeeper_odds_df['match3_away_team'].iloc[0] home_team = bookkeeper_odds_df['match3_home_team'].iloc[0] away_team = bookkeeper_odds_df['match3_away_team'].iloc[0] home_team_winodds = self.player.matchbet_3_winodds home_team_loseodds = self.player.matchbet_3_loseodds draw_odds = self.player.matchbet_3_drawodds # win_bet = self.player.matchbet_3_win # lose_bet = self.player.matchbet_3_lose # draw_bet = self.player.matchbet_3_draw # win_payoff = round(self.player.matchbet_3_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_3_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_3_draw * draw_odds, 2) win_bet = self.player.matchbet_3_change_win lose_bet = self.player.matchbet_3_change_lose draw_bet = self.player.matchbet_3_change_draw win_payoff = round(self.player.matchbet_3_change_win * home_team_winodds, 2) lose_payoff = round(self.player.matchbet_3_change_lose * home_team_loseodds, 2) draw_payoff = round(self.player.matchbet_3_change_draw * draw_odds, 2) elif self.player.payout_matchnum == 4: # if self.player.benchmark_treat == "Watford vs ManU": # home_team = bookkeeper_odds_df['match3_home_team'].iloc[0] # away_team = bookkeeper_odds_df['match3_away_team'].iloc[0] # else: # home_team = bookkeeper_odds_df['match4_home_team'].iloc[0] # away_team = bookkeeper_odds_df['match4_away_team'].iloc[0] home_team = bookkeeper_odds_df['match4_home_team'].iloc[0] away_team = bookkeeper_odds_df['match4_away_team'].iloc[0] home_team_winodds = self.player.matchbet_4_winodds home_team_loseodds = self.player.matchbet_4_loseodds draw_odds = self.player.matchbet_4_drawodds # win_bet = self.player.matchbet_4_win # lose_bet = self.player.matchbet_4_lose # draw_bet = self.player.matchbet_4_draw # win_payoff = round(self.player.matchbet_4_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_4_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_4_draw * draw_odds, 2) win_bet = self.player.matchbet_4_change_win lose_bet = self.player.matchbet_4_change_lose draw_bet = self.player.matchbet_4_change_draw win_payoff = round(self.player.matchbet_4_change_win * home_team_winodds, 2) lose_payoff = round(self.player.matchbet_4_change_lose * home_team_loseodds, 2) draw_payoff = round(self.player.matchbet_4_change_draw * draw_odds, 2) elif self.player.payout_matchnum == 5: home_team = bookkeeper_odds_df['match5_home_team'].iloc[0] away_team = bookkeeper_odds_df['match5_away_team'].iloc[0] home_team_winodds = self.player.matchbet_5_winodds home_team_loseodds = self.player.matchbet_5_loseodds draw_odds = self.player.matchbet_5_drawodds win_bet = self.player.matchbet_5_win lose_bet = self.player.matchbet_5_lose draw_bet = self.player.matchbet_5_draw win_payoff = round(self.player.matchbet_5_win * home_team_winodds, 2) lose_payoff = round(self.player.matchbet_5_lose * home_team_loseodds, 2) draw_payoff = round(self.player.matchbet_5_draw * draw_odds, 2) # elif self.player.payout_matchnum == 5: # home_team = "Unnamed Home Team" # away_team = "Unnamed Away Team" # home_team_winodds = self.player.matchbet_5_winodds # home_team_loseodds = self.player.matchbet_5_loseodds # draw_odds = 3.3 # win_bet = self.player.matchbet_5_win # lose_bet = self.player.matchbet_5_lose # draw_bet = self.player.matchbet_5_draw # win_payoff = round(self.player.matchbet_5_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_5_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_5_draw * draw_odds, 2) # elif self.player.payout_matchnum == 5: # home_team = bookkeeper_odds_df['match3_home_team'].iloc[0] # away_team = bookkeeper_odds_df['match3_away_team'].iloc[0] # home_team_winodds = self.player.matchbet_3b_winodds # home_team_loseodds = self.player.matchbet_3b_loseodds # draw_odds = bookkeeper_odds_df['match3_draw_odds'].iloc[0] # win_bet = self.player.matchbet_3b_win # lose_bet = self.player.matchbet_3b_lose # draw_bet = self.player.matchbet_3b_draw # win_payoff = round(self.player.matchbet_3b_win * home_team_winodds, 2) # lose_payoff = round(self.player.matchbet_3b_lose * home_team_loseodds, 2) # draw_payoff = round(self.player.matchbet_3b_draw * draw_odds, 2) return dict( home_team = home_team, away_team = away_team, home_team_winodds = home_team_winodds, home_team_loseodds = home_team_loseodds, draw_odds = draw_odds, win_bet = win_bet, lose_bet = lose_bet, draw_bet = draw_bet, win_payoff = win_payoff, lose_payoff = lose_payoff, draw_payoff = draw_payoff ) class ThankYou(Page): form_model = 'player' form_fields = [] page_sequence = [Introduction, RejectSurvey, PhoneNum, Kwa_Treat, # MatchBeliefs_a, # MatchBeliefs_b, # MatchBeliefs_c, # MatchBeliefs_d, # MatchBeliefs_e, # BetIntro, # BetPrimer, # BetPrimer_correct, # BetPrimer_wrong, # MatchBet_a, # MatchBet_b, # MatchBeliefs_c_post, # MatchBet_c, # Benchmark_Treat, # MatchBeliefs_d_post, # MatchBet_d, #Description_page, # MatchBet_e, # MatchBetPriceList, # MatchBet_a_Change, # MatchBet_b_Change, # MatchBet_c_Change, # MatchBet_d_Change, # PotentialBonus, # ThankYou ]