James McCool commited on
Commit
0a2d441
·
1 Parent(s): 3c21b7e

Lots of changes to stat specifc loop, added pick6 functionality

Browse files
Files changed (1) hide show
  1. app.py +109 -98
app.py CHANGED
@@ -52,10 +52,11 @@ def init_conn():
52
 
53
  gcservice_account, gcservice_account2, NHL_Data = init_conn()
54
 
55
- prop_table_options = ['SOG', 'points', 'blocked_shots', 'assists']
56
  prop_format = {'L5 Success': '{:.2%}', 'L10_Success': '{:.2%}', 'L20_success': '{:.2%}', 'Matchup Boost': '{:.2%}', 'Trending Over': '{:.2%}', 'Trending Under': '{:.2%}',
57
  'Implied Over': '{:.2%}', 'Implied Under': '{:.2%}', 'Over Edge': '{:.2%}', 'Under Edge': '{:.2%}'}
58
  all_sim_vars = ['NHL_GAME_PLAYER_SHOTS_ON_GOAL', 'NHL_GAME_PLAYER_POINTS', 'NHL_GAME_PLAYER_BLOCKED_SHOTS', 'NHL_GAME_PLAYER_ASSISTS']
 
59
  sim_all_hold = pd.DataFrame(columns=['Player', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
60
 
61
  @st.cache_resource(ttl=300)
@@ -63,7 +64,7 @@ def pull_baselines():
63
  sh = gcservice_account.open_by_url(NHL_Data)
64
  worksheet = sh.worksheet('Prop_Betting_Table')
65
  raw_display = pd.DataFrame(worksheet.get_all_records())
66
- prop_display = raw_display.loc[raw_display['Player'] != ""]
67
  prop_display['Player Blocks'].replace("", np.nan, inplace=True)
68
  prop_display['SOG Edge'].replace("", np.nan, inplace=True)
69
  prop_display['Assist Edge'].replace("", np.nan, inplace=True)
@@ -159,12 +160,16 @@ with tab3:
159
  export_container = st.empty()
160
 
161
  with col1:
162
- game_select_var = st.selectbox('Select prop source', options = ['Draftkings', 'Pick6'])
163
- if game_select_var == 'Draftkings':
164
- prop_df = prop_trends[['Player', 'over_prop', 'over_line', 'under_line', 'prop_type']]
 
 
 
 
 
165
  elif game_select_var == 'Pick6':
166
- prop_df = pick_frame[['Full_name', 'over_prop', 'over_line', 'under_line', 'prop_type']]
167
- prop_df.rename(columns={"Full_name": "Player"}, inplace = True)
168
  st.download_button(
169
  label="Download Prop Source",
170
  data=convert_df_to_csv(prop_df),
@@ -172,61 +177,72 @@ with tab3:
172
  mime='text/csv',
173
  key='prop_source',
174
  )
175
- prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'SOG', 'points', 'blocked_shots', 'assists'])
176
- if prop_type_var == 'All Props':
177
- st.info('please note that the All Props run can take some time, you will see progress as tables show up in the sim area to the right')
 
178
 
179
  if st.button('Simulate Prop Category'):
180
  with col2:
181
  with df_hold_container.container():
182
  if prop_type_var == 'All Props':
183
- for prop in all_sim_vars:
 
 
 
 
 
 
 
 
 
 
 
184
 
185
- if game_select_var == 'Draftkings':
186
- prop_df_raw = prop_trends[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
187
- elif game_select_var == 'Pick6':
188
- prop_df_raw = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
189
- prop_df_raw.rename(columns={"Full_name": "Player"}, inplace = True)
190
-
191
- for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
192
- prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
193
- prop_df = prop_df.loc[prop_df['prop_type'] == prop]
194
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
195
  prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
196
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
197
- st.table(prop_df)
198
  prop_df['Over'] = 1 / prop_df['over_line']
199
  prop_df['Under'] = 1 / prop_df['under_line']
200
- df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
201
-
202
- prop_dict = dict(zip(df.Player, df.Prop))
203
- book_dict = dict(zip(df.Player, df.book))
204
- over_dict = dict(zip(df.Player, df.Over))
205
- under_dict = dict(zip(df.Player, df.Under))
 
 
 
 
 
 
 
 
206
 
207
  total_sims = 1000
208
 
209
  df.replace("", 0, inplace=True)
210
 
211
- if prop == 'NHL_GAME_PLAYER_POINTS':
212
  df['Median'] = df['Player TP']
213
- elif prop == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL':
214
  df['Median'] = df['Player SOG']
215
- elif prop == 'NHL_GAME_PLAYER_ASSISTS':
216
  df['Median'] = df['Player Assists']
217
- elif prop == 'NHL_GAME_PLAYER_BLOCKED_SHOTS':
218
  df['Median'] = df['Player Blocks']
219
 
220
- flex_file = df
221
  flex_file['Floor'] = (flex_file['Median'] * .15)
222
  flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
223
  flex_file['STD'] = (flex_file['Median']/3)
224
  flex_file['Prop'] = flex_file['Player'].map(prop_dict)
225
  flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
226
 
227
- hold_file = flex_file
228
- overall_file = flex_file
229
- prop_file = flex_file
230
 
231
  overall_players = overall_file[['Player']]
232
 
@@ -259,7 +275,7 @@ with tab3:
259
  players_only['Book'] = players_only['Player'].map(book_dict)
260
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
261
  players_only['prop_threshold'] = .10
262
- players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
263
  players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
264
  players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
265
  players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
@@ -275,87 +291,79 @@ with tab3:
275
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
276
 
277
  final_outcomes = sim_all_hold
 
278
 
279
  elif prop_type_var != 'All Props':
280
 
281
- if game_select_var == 'Draftkings':
 
 
282
  prop_df_raw = prop_trends[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
283
  elif game_select_var == 'Pick6':
284
- prop_df_raw = pick_frame[['Full_name', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
285
- prop_df_raw.rename(columns={"Full_name": "Player"}, inplace = True)
286
 
287
- for books in ['FANDUEL', 'DRAFTKINGS', 'BET365', 'CONSENSUS']:
288
- prop_df = prop_df_raw.loc[prop_df_raw['book'] == books]
289
- if prop_type_var == "SOG":
290
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL']
291
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
292
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
293
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
294
- st.table(prop_df)
295
- prop_df['Over'] = 1 / prop_df['over_line']
296
- prop_df['Under'] = 1 / prop_df['under_line']
297
- prop = 'SOG'
298
- df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
299
- elif prop_type_var == "points":
300
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_POINTS']
301
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
302
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
303
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
304
- st.table(prop_df)
305
- prop_df['Over'] = 1 / prop_df['over_line']
306
- prop_df['Under'] = 1 / prop_df['under_line']
307
- prop = 'points'
308
- df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
309
- elif prop_type_var == "assists":
310
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_ASSISTS']
311
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
312
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
313
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
314
- st.table(prop_df)
315
- prop_df['Over'] = 1 / prop_df['over_line']
316
- prop_df['Under'] = 1 / prop_df['under_line']
317
- prop = 'assists'
318
- df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
319
- elif prop_type_var == "blocked_shots":
320
- prop_df = prop_df.loc[prop_df['prop_type'] == 'NHL_GAME_PLAYER_BLOCKED_SHOTS']
321
- prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
322
- prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
323
- prop_df = prop_df.loc[prop_df['Prop'] != 0]
324
- st.table(prop_df)
325
- prop_df['Over'] = 1 / prop_df['over_line']
326
- prop_df['Under'] = 1 / prop_df['under_line']
327
- prop = 'blocked_shots'
328
- df = pd.merge(prop_display, prop_df, how='left', left_on=['Player'], right_on = ['Player'])
329
-
330
- st.table(df)
331
- prop_dict = dict(zip(df.Player, df.Prop))
332
- book_dict = dict(zip(df.Player, df.book))
333
- over_dict = dict(zip(df.Player, df.Over))
334
- under_dict = dict(zip(df.Player, df.Under))
335
 
336
  total_sims = 1000
337
 
338
  df.replace("", 0, inplace=True)
339
 
340
- if prop == 'points':
341
  df['Median'] = df['Player TP']
342
- elif prop == 'SOG':
343
  df['Median'] = df['Player SOG']
344
- elif prop == 'assists':
345
  df['Median'] = df['Player Assists']
346
- elif prop == 'blocked_shots':
347
  df['Median'] = df['Player Blocks']
348
 
349
- flex_file = df
350
  flex_file['Floor'] = (flex_file['Median'] * .15)
351
  flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
352
  flex_file['STD'] = (flex_file['Median']/3)
353
  flex_file['Prop'] = flex_file['Player'].map(prop_dict)
354
  flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
355
 
356
- hold_file = flex_file
357
- overall_file = flex_file
358
- prop_file = flex_file
359
 
360
  overall_players = overall_file[['Player']]
361
 
@@ -388,7 +396,7 @@ with tab3:
388
  players_only['Book'] = players_only['Player'].map(book_dict)
389
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
390
  players_only['prop_threshold'] = .10
391
- players_only = players_only.loc[players_only['Mean_Outcome'] > 0]
392
  players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
393
  players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
394
  players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
@@ -403,8 +411,11 @@ with tab3:
403
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
404
 
405
  final_outcomes = sim_all_hold
 
406
 
407
  final_outcomes = final_outcomes[final_outcomes['Prop'] > 0]
 
 
408
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
409
 
410
  with df_hold_container:
 
52
 
53
  gcservice_account, gcservice_account2, NHL_Data = init_conn()
54
 
55
+ all_sim_vars = ['NHL_GAME_PLAYER_SHOTS_ON_GOAL', 'NHL_GAME_PLAYER_POINTS', 'NHL_GAME_PLAYER_BLOCKED_SHOTS', 'NHL_GAME_PLAYER_ASSISTS']
56
  prop_format = {'L5 Success': '{:.2%}', 'L10_Success': '{:.2%}', 'L20_success': '{:.2%}', 'Matchup Boost': '{:.2%}', 'Trending Over': '{:.2%}', 'Trending Under': '{:.2%}',
57
  'Implied Over': '{:.2%}', 'Implied Under': '{:.2%}', 'Over Edge': '{:.2%}', 'Under Edge': '{:.2%}'}
58
  all_sim_vars = ['NHL_GAME_PLAYER_SHOTS_ON_GOAL', 'NHL_GAME_PLAYER_POINTS', 'NHL_GAME_PLAYER_BLOCKED_SHOTS', 'NHL_GAME_PLAYER_ASSISTS']
59
+ pick6_sim_vars = ['Points', 'Shots on Goal', 'Assists', 'Blocks']
60
  sim_all_hold = pd.DataFrame(columns=['Player', 'Prop type', 'Prop', 'Mean_Outcome', 'Imp Over', 'Over%', 'Imp Under', 'Under%', 'Bet?', 'Edge'])
61
 
62
  @st.cache_resource(ttl=300)
 
64
  sh = gcservice_account.open_by_url(NHL_Data)
65
  worksheet = sh.worksheet('Prop_Betting_Table')
66
  raw_display = pd.DataFrame(worksheet.get_all_records())
67
+ prop_display = raw_display[raw_display['Player'] != ""]
68
  prop_display['Player Blocks'].replace("", np.nan, inplace=True)
69
  prop_display['SOG Edge'].replace("", np.nan, inplace=True)
70
  prop_display['Assist Edge'].replace("", np.nan, inplace=True)
 
160
  export_container = st.empty()
161
 
162
  with col1:
163
+ game_select_var = st.selectbox('Select prop source', options = ['Aggregate', 'Pick6'])
164
+ book_select_var = st.selectbox('Select book', options = ['ALL', 'BET_365', 'DRAFTKINGS', 'FANDUEL', 'MGM', 'UNIBET', 'WILLIAM_HILL'])
165
+ if book_select_var == 'ALL':
166
+ book_selections = ['BET_365', 'DRAFTKINGS', 'FANDUEL', 'MGM', 'UNIBET', 'WILLIAM_HILL']
167
+ else:
168
+ book_selections = [book_select_var]
169
+ if game_select_var == 'Aggregate':
170
+ prop_df = prop_trends[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
171
  elif game_select_var == 'Pick6':
172
+ prop_df = pick_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
 
173
  st.download_button(
174
  label="Download Prop Source",
175
  data=convert_df_to_csv(prop_df),
 
177
  mime='text/csv',
178
  key='prop_source',
179
  )
180
+ if game_select_var == 'Aggregate':
181
+ prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'NBA_GAME_PLAYER_POINTS', 'NBA_GAME_PLAYER_REBOUNDS', 'NBA_GAME_PLAYER_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS', 'NBA_GAME_PLAYER_POINTS_ASSISTS', 'NBA_GAME_PLAYER_REBOUNDS_ASSISTS'])
182
+ elif game_select_var == 'Pick6':
183
+ prop_type_var = st.selectbox('Select prop category', options = ['All Props', 'Points', 'Rebounds', 'Assists', 'Points + Assists + Rebounds', 'Points + Assists', 'Points + Rebounds', 'Assists + Rebounds'])
184
 
185
  if st.button('Simulate Prop Category'):
186
  with col2:
187
  with df_hold_container.container():
188
  if prop_type_var == 'All Props':
189
+
190
+ if game_select_var == 'Aggregate':
191
+ prop_df_raw = prop_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
192
+ sim_vars = ['NBA_GAME_PLAYER_POINTS', 'NBA_GAME_PLAYER_REBOUNDS', 'NBA_GAME_PLAYER_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS_ASSISTS', 'NBA_GAME_PLAYER_POINTS_REBOUNDS', 'NBA_GAME_PLAYER_POINTS_ASSISTS', 'NBA_GAME_PLAYER_REBOUNDS_ASSISTS']
193
+ elif game_select_var == 'Pick6':
194
+ prop_df_raw = pick_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
195
+ sim_vars = ['Points', 'Rebounds', 'Assists', 'Points + Assists + Rebounds', 'Points + Assists', 'Points + Rebounds', 'Assists + Rebounds']
196
+
197
+ player_df = prop_display.copy()
198
+
199
+ for prop in sim_vars:
200
+ prop_df = prop_df_raw[prop_df_raw['prop_type'] == prop]
201
 
202
+ for books in book_selections:
203
+ prop_df = prop_df[prop_df['book'] == books]
204
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
 
 
 
 
 
 
 
205
  prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
 
 
206
  prop_df['Over'] = 1 / prop_df['over_line']
207
  prop_df['Under'] = 1 / prop_df['under_line']
208
+
209
+ prop_dict = dict(zip(prop_df.Player, prop_df.Prop))
210
+ prop_type_dict = dict(zip(prop_df.Player, prop_df.prop_type))
211
+ book_dict = dict(zip(prop_df.Player, prop_df.book))
212
+ over_dict = dict(zip(prop_df.Player, prop_df.Over))
213
+ under_dict = dict(zip(prop_df.Player, prop_df.Under))
214
+
215
+ player_df['book'] = player_df['Player'].map(book_dict)
216
+ player_df['Prop'] = player_df['Player'].map(prop_dict)
217
+ player_df['prop_type'] = player_df['Player'].map(prop_type_dict)
218
+
219
+ df = player_df.reset_index(drop=True)
220
+
221
+ team_dict = dict(zip(df.Player, df.Team))
222
 
223
  total_sims = 1000
224
 
225
  df.replace("", 0, inplace=True)
226
 
227
+ if prop == 'NHL_GAME_PLAYER_POINTS' or prop == 'Points':
228
  df['Median'] = df['Player TP']
229
+ elif prop == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL' or prop == 'Shots on Goal':
230
  df['Median'] = df['Player SOG']
231
+ elif prop == 'NHL_GAME_PLAYER_ASSISTS' or prop == 'Assists':
232
  df['Median'] = df['Player Assists']
233
+ elif prop == 'NHL_GAME_PLAYER_BLOCKED_SHOTS' or prop == 'Blocks':
234
  df['Median'] = df['Player Blocks']
235
 
236
+ flex_file = df.copy()
237
  flex_file['Floor'] = (flex_file['Median'] * .15)
238
  flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
239
  flex_file['STD'] = (flex_file['Median']/3)
240
  flex_file['Prop'] = flex_file['Player'].map(prop_dict)
241
  flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
242
 
243
+ hold_file = flex_file.copy()
244
+ overall_file = flex_file.copy()
245
+ prop_file = flex_file.copy()
246
 
247
  overall_players = overall_file[['Player']]
248
 
 
275
  players_only['Book'] = players_only['Player'].map(book_dict)
276
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
277
  players_only['prop_threshold'] = .10
278
+ players_only = players_only[players_only['Mean_Outcome'] > 0]
279
  players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
280
  players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
281
  players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
 
291
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
292
 
293
  final_outcomes = sim_all_hold
294
+ st.write(f'finished {prop}')
295
 
296
  elif prop_type_var != 'All Props':
297
 
298
+ player_df = prop_display.copy()
299
+
300
+ if game_select_var == 'Aggregate':
301
  prop_df_raw = prop_trends[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
302
  elif game_select_var == 'Pick6':
303
+ prop_df_raw = pick_frame[['Player', 'book', 'over_prop', 'over_line', 'under_line', 'prop_type']]
 
304
 
305
+ for books in book_selections:
306
+ prop_df = prop_df_raw[prop_df_raw['book'] == books]
307
+
308
+ if prop_type_var == "NHL_GAME_PLAYER_SHOTS_ON_GOAL":
309
+ prop_df = prop_df[prop_df['prop_type'] == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL']
310
+ elif prop_type_var == 'Shots on Goal':
311
+ prop_df = prop_df[prop_df['prop_type'] == 'Player SOG']
312
+ elif prop_type_var == "NHL_GAME_PLAYER_POINTS":
313
+ prop_df = prop_df[prop_df['prop_type'] == 'NHL_GAME_PLAYER_POINTS']
314
+ elif prop_type_var == "Points":
315
+ prop_df = prop_df[prop_df['prop_type'] == 'Player TP']
316
+ elif prop_type_var == "NHL_GAME_PLAYER_ASSISTS":
317
+ prop_df = prop_df[prop_df['prop_type'] == 'NHL_GAME_PLAYER_ASSISTS']
318
+ elif prop_type_var == "Assists":
319
+ prop_df = prop_df[prop_df['prop_type'] == 'Player Assists']
320
+ elif prop_type_var == "NHL_GAME_PLAYER_BLOCKED_SHOTS":
321
+ prop_df = prop_df[prop_df['prop_type'] == 'NHL_GAME_PLAYER_BLOCKED_SHOTS']
322
+ elif prop_type_var == "Blocks":
323
+ prop_df = prop_df[prop_df['prop_type'] == 'Player Blocks']
324
+
325
+ prop_df = prop_df[['Player', 'book', 'over_prop', 'over_line', 'under_line']]
326
+ prop_df.rename(columns={"over_prop": "Prop"}, inplace = True)
327
+ prop_df['Over'] = 1 / prop_df['over_line']
328
+ prop_df['Under'] = 1 / prop_df['under_line']
329
+
330
+ prop_dict = dict(zip(prop_df.Player, prop_df.Prop))
331
+ prop_type_dict = dict(zip(prop_df.Player, prop_df.prop_type))
332
+ book_dict = dict(zip(prop_df.Player, prop_df.book))
333
+ over_dict = dict(zip(prop_df.Player, prop_df.Over))
334
+ under_dict = dict(zip(prop_df.Player, prop_df.Under))
335
+
336
+ player_df['book'] = player_df['Player'].map(book_dict)
337
+ player_df['Prop'] = player_df['Player'].map(prop_dict)
338
+ player_df['prop_type'] = player_df['Player'].map(prop_type_dict)
339
+
340
+ df = player_df.reset_index(drop=True)
341
+
342
+ team_dict = dict(zip(df.Player, df.Team))
 
 
 
 
 
 
 
 
 
 
343
 
344
  total_sims = 1000
345
 
346
  df.replace("", 0, inplace=True)
347
 
348
+ if prop_type_var == 'NHL_GAME_PLAYER_POINTS' or prop_type_var == 'Points':
349
  df['Median'] = df['Player TP']
350
+ elif prop_type_var == 'NHL_GAME_PLAYER_SHOTS_ON_GOAL' or prop_type_var == 'Shots on Goal':
351
  df['Median'] = df['Player SOG']
352
+ elif prop_type_var == 'NHL_GAME_PLAYER_ASSISTS' or prop_type_var == 'Assists':
353
  df['Median'] = df['Player Assists']
354
+ elif prop_type_var == 'NHL_GAME_PLAYER_BLOCKED_SHOTS' or prop_type_var == 'Blocks':
355
  df['Median'] = df['Player Blocks']
356
 
357
+ flex_file = df.copy()
358
  flex_file['Floor'] = (flex_file['Median'] * .15)
359
  flex_file['Ceiling'] = flex_file['Median'] + (flex_file['Median'] * 1)
360
  flex_file['STD'] = (flex_file['Median']/3)
361
  flex_file['Prop'] = flex_file['Player'].map(prop_dict)
362
  flex_file = flex_file[['Player', 'book', 'Prop', 'Floor', 'Median', 'Ceiling', 'STD']]
363
 
364
+ hold_file = flex_file.copy()
365
+ overall_file = flex_file.copy()
366
+ prop_file = flex_file.copy()
367
 
368
  overall_players = overall_file[['Player']]
369
 
 
396
  players_only['Book'] = players_only['Player'].map(book_dict)
397
  players_only['Prop_avg'] = players_only['Prop'].mean() / 100
398
  players_only['prop_threshold'] = .10
399
+ players_only = players_only[players_only['Mean_Outcome'] > 0]
400
  players_only['Over_diff'] = players_only['Over%'] - players_only['Imp Over']
401
  players_only['Under_diff'] = players_only['Under%'] - players_only['Imp Under']
402
  players_only['Bet_check'] = np.where(players_only['Over_diff'] > players_only['Under_diff'], players_only['Over_diff'] , players_only['Under_diff'])
 
411
  sim_all_hold = pd.concat([sim_all_hold, leg_outcomes], ignore_index=True)
412
 
413
  final_outcomes = sim_all_hold
414
+ st.write(f'finished {prop_type_var}')
415
 
416
  final_outcomes = final_outcomes[final_outcomes['Prop'] > 0]
417
+ if game_select_var == 'Pick6':
418
+ final_outcomes = final_outcomes.drop_duplicates(subset=['Player', 'Prop Type'])
419
  final_outcomes = final_outcomes.sort_values(by='Edge', ascending=False)
420
 
421
  with df_hold_container: