James McCool
commited on
Commit
·
3a20f4f
1
Parent(s):
0543ffc
Add specific replacements feature in 'Manage Portfolio' to enhance player selection options and improve exposure calculations.
Browse files- app.py +3 -2
- global_func/exposure_spread.py +18 -12
app.py
CHANGED
@@ -1517,6 +1517,7 @@ if selected_tab == 'Manage Portfolio':
|
|
1517 |
else:
|
1518 |
exposure_stack_bool = 'No'
|
1519 |
remove_teams_exposure = st.multiselect("Removed/Locked teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
|
|
1520 |
submitted_col, export_col = st.columns(2)
|
1521 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
1522 |
with submitted_col:
|
@@ -1526,7 +1527,7 @@ if selected_tab == 'Manage Portfolio':
|
|
1526 |
if reg_submitted:
|
1527 |
st.session_state['settings_base'] = False
|
1528 |
prior_frame = st.session_state['working_frame'].copy()
|
1529 |
-
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1530 |
|
1531 |
if type_var == 'Classic':
|
1532 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
@@ -1619,7 +1620,7 @@ if selected_tab == 'Manage Portfolio':
|
|
1619 |
elif exp_submitted:
|
1620 |
st.session_state['settings_base'] = False
|
1621 |
prior_frame = st.session_state['export_base'].copy()
|
1622 |
-
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1623 |
|
1624 |
if type_var == 'Classic':
|
1625 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
1517 |
else:
|
1518 |
exposure_stack_bool = 'No'
|
1519 |
remove_teams_exposure = st.multiselect("Removed/Locked teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
1520 |
+
specific_replacements = st.multiselect("Specific Replacements?", options=sorted(list(set(st.session_state['projections_df']['player_names'].unique()))), default=[])
|
1521 |
submitted_col, export_col = st.columns(2)
|
1522 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
1523 |
with submitted_col:
|
|
|
1527 |
if reg_submitted:
|
1528 |
st.session_state['settings_base'] = False
|
1529 |
prior_frame = st.session_state['working_frame'].copy()
|
1530 |
+
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, specific_replacements, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1531 |
|
1532 |
if type_var == 'Classic':
|
1533 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
1620 |
elif exp_submitted:
|
1621 |
st.session_state['settings_base'] = False
|
1622 |
prior_frame = st.session_state['export_base'].copy()
|
1623 |
+
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, exposure_stack_bool, remove_teams_exposure, specific_replacements, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
1624 |
|
1625 |
if type_var == 'Classic':
|
1626 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
global_func/exposure_spread.py
CHANGED
@@ -148,7 +148,7 @@ def check_position_eligibility(sport, column_name, player_positions):
|
|
148 |
# Default fallback - assume exact position match
|
149 |
return column_name in player_positions
|
150 |
|
151 |
-
def exposure_spread(working_frame, exposure_player, exposure_target, exposure_stack_bool, remove_teams, projections_df, sport_var, type_var, salary_max, stacking_sports):
|
152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
153 |
|
154 |
comparable_players = comparable_players.reset_index(drop=True)
|
@@ -215,12 +215,15 @@ def exposure_spread(working_frame, exposure_player, exposure_target, exposure_st
|
|
215 |
if lineups_to_remove > 0:
|
216 |
for row in random_row_indices_insert:
|
217 |
if change_counter < math.ceil(lineups_to_remove):
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
224 |
|
225 |
if exposure_target == 0:
|
226 |
comparable_players = comparable_players[comparable_players['player_names'] != exposure_player]
|
@@ -261,11 +264,14 @@ def exposure_spread(working_frame, exposure_player, exposure_target, exposure_st
|
|
261 |
else:
|
262 |
for row in random_row_indices_replace:
|
263 |
if change_counter < math.ceil(lineups_to_add):
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
|
|
|
|
|
|
269 |
if sport_var in stacking_sports:
|
270 |
if sport_var in stacking_sports:
|
271 |
if working_frame.iloc[row]['Size'] == 5 and comp_team != working_frame.iloc[row]['Stack']:
|
|
|
148 |
# Default fallback - assume exact position match
|
149 |
return column_name in player_positions
|
150 |
|
151 |
+
def exposure_spread(working_frame, exposure_player, exposure_target, exposure_stack_bool, remove_teams, specific_replacements, projections_df, sport_var, type_var, salary_max, stacking_sports):
|
152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
153 |
|
154 |
comparable_players = comparable_players.reset_index(drop=True)
|
|
|
215 |
if lineups_to_remove > 0:
|
216 |
for row in random_row_indices_insert:
|
217 |
if change_counter < math.ceil(lineups_to_remove):
|
218 |
+
if specific_replacements != []:
|
219 |
+
comparable_players = projections_df[projections_df['player_names'].isin(specific_replacements)]
|
220 |
+
else:
|
221 |
+
comparable_players = projections_df[
|
222 |
+
(projections_df['salary'] >= comp_salary_low) &
|
223 |
+
(projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
|
224 |
+
(projections_df['median'] >= comp_projection_low) &
|
225 |
+
(projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
|
226 |
+
]
|
227 |
|
228 |
if exposure_target == 0:
|
229 |
comparable_players = comparable_players[comparable_players['player_names'] != exposure_player]
|
|
|
264 |
else:
|
265 |
for row in random_row_indices_replace:
|
266 |
if change_counter < math.ceil(lineups_to_add):
|
267 |
+
if specific_replacements != []:
|
268 |
+
comparable_players = projections_df[projections_df['player_names'].isin(specific_replacements)]
|
269 |
+
else:
|
270 |
+
comparable_players = projections_df[
|
271 |
+
(projections_df['salary'] >= comp_salary_low) &
|
272 |
+
(projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row])) &
|
273 |
+
(projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
|
274 |
+
]
|
275 |
if sport_var in stacking_sports:
|
276 |
if sport_var in stacking_sports:
|
277 |
if working_frame.iloc[row]['Size'] == 5 and comp_team != working_frame.iloc[row]['Stack']:
|