Spaces:
Sleeping
Sleeping
Delete CSGO_Contest_Sims-main
Browse files
CSGO_Contest_Sims-main/app.py
DELETED
@@ -1,1096 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
st.set_page_config(layout="wide")
|
3 |
-
|
4 |
-
for name in dir():
|
5 |
-
if not name.startswith('_'):
|
6 |
-
del globals()[name]
|
7 |
-
|
8 |
-
import numpy as np
|
9 |
-
import pandas as pd
|
10 |
-
import streamlit as st
|
11 |
-
import gspread
|
12 |
-
|
13 |
-
@st.cache_resource
|
14 |
-
def init_conn():
|
15 |
-
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
16 |
-
"https://www.googleapis.com/auth/drive"]
|
17 |
-
|
18 |
-
credentials = {
|
19 |
-
"type": "service_account",
|
20 |
-
"project_id": "sheets-api-connect-378620",
|
21 |
-
"private_key_id": "1005124050c80d085e2c5b344345715978dd9cc9",
|
22 |
-
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtKa01beXwc88R\nnPZVQTNPVQuBnbwoOfc66gW3547ja/UEyIGAF112dt/VqHprRafkKGmlg55jqJNt\na4zceLKV+wTm7vBu7lDISTJfGzCf2TrxQYNqwMKE2LOjI69dBM8u4Dcb4k0wcp9v\ntW1ZzLVVuwTvmrg7JBHjiSaB+x5wxm/r3FOiJDXdlAgFlytzqgcyeZMJVKKBQHyJ\njEGg/1720A0numuOCt71w/2G0bDmijuj1e6tH32MwRWcvRNZ19K9ssyDz2S9p68s\nYDhIxX69OWxwScTIHLY6J2t8txf/XMivL/636fPlDADvBEVTdlT606n8CcKUVQeq\npUVdG+lfAgMBAAECggEAP38SUA7B69eTfRpo658ycOs3Amr0JW4H/bb1rNeAul0K\nZhwd/HnU4E07y81xQmey5kN5ZeNrD5EvqkZvSyMJHV0EEahZStwhjCfnDB/cxyix\nZ+kFhv4y9eK+kFpUAhBy5nX6T0O+2T6WvzAwbmbVsZ+X8kJy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bgbzdyrE768=\n-----END PRIVATE KEY-----\n",
|
23 |
-
"client_email": "gspread-connection@sheets-api-connect-378620.iam.gserviceaccount.com",
|
24 |
-
"client_id": "106625872877651920064",
|
25 |
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
26 |
-
"token_uri": "https://oauth2.googleapis.com/token",
|
27 |
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
28 |
-
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40sheets-api-connect-378620.iam.gserviceaccount.com"
|
29 |
-
}
|
30 |
-
|
31 |
-
gc = gspread.service_account_from_dict(credentials)
|
32 |
-
return gc
|
33 |
-
|
34 |
-
gc = init_conn()
|
35 |
-
|
36 |
-
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
37 |
-
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
38 |
-
|
39 |
-
player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '20+%': '{:.2%}', '2x%': '{:.2%}', '3x%': '{:.2%}',
|
40 |
-
'4x%': '{:.2%}','GPP%': '{:.2%}'}
|
41 |
-
|
42 |
-
freq_format = {'Proj Own': '{:.2%}', 'Exposure': '{:.2%}', 'Edge': '{:.2%}'}
|
43 |
-
|
44 |
-
@st.cache_resource(ttl=300)
|
45 |
-
def load_dk_player_projections():
|
46 |
-
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1205205406')
|
47 |
-
worksheet = sh.worksheet('CSGO_ROO')
|
48 |
-
load_display = pd.DataFrame(worksheet.get_all_records())
|
49 |
-
load_display['Own'] = load_display['Own'] * 100
|
50 |
-
load_display = load_display[load_display['Own'] > 0 ]
|
51 |
-
load_display['Floor'] = load_display['Median'] * .25
|
52 |
-
load_display['Ceiling'] = load_display['Median'] + (load_display['Median'] * .75)
|
53 |
-
load_display.replace('', np.nan, inplace=True)
|
54 |
-
raw_display = load_display.dropna(subset=['Median'])
|
55 |
-
|
56 |
-
return raw_display
|
57 |
-
|
58 |
-
@st.cache_resource(ttl=300)
|
59 |
-
def load_fd_player_projections():
|
60 |
-
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1205205406')
|
61 |
-
worksheet = sh.worksheet('CSGO_ROO')
|
62 |
-
load_display = pd.DataFrame(worksheet.get_all_records())
|
63 |
-
|
64 |
-
load_display['Own'] = load_display['Own'] * 100
|
65 |
-
load_display = load_display[load_display['Own'] > 0 ]
|
66 |
-
load_display['Floor'] = load_display['Median'] * .25
|
67 |
-
load_display['Ceiling'] = load_display['Median'] + (load_display['Median'] * .75)
|
68 |
-
load_display.replace('', np.nan, inplace=True)
|
69 |
-
raw_display = load_display.dropna(subset=['Median'])
|
70 |
-
|
71 |
-
return raw_display
|
72 |
-
|
73 |
-
@st.cache_data
|
74 |
-
def convert_df_to_csv(df):
|
75 |
-
return df.to_csv().encode('utf-8')
|
76 |
-
|
77 |
-
def run_seed_frame(seed_depth1, Strength_var, strength_grow, Teams_used, Total_Runs):
|
78 |
-
RunsVar = 1
|
79 |
-
seed_depth_def = seed_depth1
|
80 |
-
Strength_var_def = Strength_var
|
81 |
-
strength_grow_def = strength_grow
|
82 |
-
Teams_used_def = Teams_used
|
83 |
-
Total_Runs_def = Total_Runs
|
84 |
-
while RunsVar <= seed_depth_def:
|
85 |
-
if RunsVar <= 3:
|
86 |
-
FieldStrength = Strength_var_def
|
87 |
-
RandomPortfolio, maps_dict = get_correlated_portfolio_for_sim(Total_Runs_def * .1)
|
88 |
-
FinalPortfolio = RandomPortfolio
|
89 |
-
FinalPortfolio2, maps_dict2 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1)
|
90 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio2], axis=0)
|
91 |
-
maps_dict.update(maps_dict2)
|
92 |
-
del FinalPortfolio2
|
93 |
-
del maps_dict2
|
94 |
-
elif RunsVar > 3 and RunsVar <= 4:
|
95 |
-
FieldStrength += (strength_grow_def + ((30 - len(Teams_used_def)) * .001))
|
96 |
-
FinalPortfolio3, maps_dict3 = get_correlated_portfolio_for_sim(Total_Runs_def * .1)
|
97 |
-
FinalPortfolio4, maps_dict4 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1)
|
98 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio3], axis=0)
|
99 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio4], axis=0)
|
100 |
-
FinalPortfolio = FinalPortfolio.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
101 |
-
maps_dict.update(maps_dict3)
|
102 |
-
maps_dict.update(maps_dict4)
|
103 |
-
del FinalPortfolio3
|
104 |
-
del maps_dict3
|
105 |
-
del FinalPortfolio4
|
106 |
-
del maps_dict4
|
107 |
-
elif RunsVar > 4:
|
108 |
-
FieldStrength = 1
|
109 |
-
FinalPortfolio3, maps_dict3 = get_correlated_portfolio_for_sim(Total_Runs_def * .1)
|
110 |
-
FinalPortfolio4, maps_dict4 = get_uncorrelated_portfolio_for_sim(Total_Runs_def * .1)
|
111 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio3], axis=0)
|
112 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio4], axis=0)
|
113 |
-
FinalPortfolio = FinalPortfolio.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
114 |
-
maps_dict.update(maps_dict3)
|
115 |
-
maps_dict.update(maps_dict4)
|
116 |
-
del FinalPortfolio3
|
117 |
-
del maps_dict3
|
118 |
-
del FinalPortfolio4
|
119 |
-
del maps_dict4
|
120 |
-
RunsVar += 1
|
121 |
-
|
122 |
-
return FinalPortfolio, maps_dict
|
123 |
-
|
124 |
-
def create_overall_dfs(pos_players, table_name, dict_name, pos):
|
125 |
-
pos_players = pos_players.sort_values(by='Value', ascending=False)
|
126 |
-
table_name_raw = pos_players.reset_index(drop=True)
|
127 |
-
overall_table_name = table_name_raw.head(round(len(table_name_raw)))
|
128 |
-
overall_table_name = overall_table_name.assign(Var = range(0,len(overall_table_name)))
|
129 |
-
overall_dict_name = pd.Series(overall_table_name.Player.values, index=overall_table_name.Var).to_dict()
|
130 |
-
|
131 |
-
del pos_players
|
132 |
-
del table_name_raw
|
133 |
-
|
134 |
-
return overall_table_name, overall_dict_name
|
135 |
-
|
136 |
-
|
137 |
-
def get_overall_merged_df():
|
138 |
-
ref_dict = {
|
139 |
-
'pos':['FLEX'],
|
140 |
-
'pos_dfs':['FLEX_Table'],
|
141 |
-
'pos_dicts':['flex_dict']
|
142 |
-
}
|
143 |
-
|
144 |
-
for i in range(0,1):
|
145 |
-
ref_dict['pos_dfs'][i], ref_dict['pos_dicts'][i] =\
|
146 |
-
create_overall_dfs(pos_players, ref_dict['pos_dfs'][i], ref_dict['pos_dicts'][i], ref_dict['pos'][i])
|
147 |
-
|
148 |
-
df_out = pd.concat(ref_dict['pos_dfs'], ignore_index=True)
|
149 |
-
|
150 |
-
return df_out, ref_dict
|
151 |
-
|
152 |
-
def create_random_portfolio(Total_Sample_Size):
|
153 |
-
|
154 |
-
O_merge, full_pos_player_dict = get_overall_merged_df()
|
155 |
-
Overall_Merge = O_merge[['Var', 'Player', 'Team', 'Salary', 'Median', 'Own']].copy()
|
156 |
-
|
157 |
-
# Calculate Floor, Ceiling, and STDev directly
|
158 |
-
Overall_Merge['Floor'] = Overall_Merge['Median'] * .25
|
159 |
-
Overall_Merge['Ceiling'] = Overall_Merge['Median'] + Overall_Merge['Floor']
|
160 |
-
Overall_Merge['STDev'] = Overall_Merge['Median'] / 4
|
161 |
-
|
162 |
-
# Calculate the flex range and generate unique range list
|
163 |
-
flex_range_var = len(Overall_Merge)
|
164 |
-
ranges_dict = {'flex_range': flex_range_var}
|
165 |
-
ranges_dict['flex_Uniques'] = list(range(0, flex_range_var))
|
166 |
-
|
167 |
-
# Generate random portfolios
|
168 |
-
rng = np.random.default_rng()
|
169 |
-
all_choices = rng.choice(flex_range_var, size=(Total_Sample_Size, 6))
|
170 |
-
|
171 |
-
# Create RandomPortfolio DataFrame
|
172 |
-
RandomPortfolio = pd.DataFrame(all_choices, columns=['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5'])
|
173 |
-
RandomPortfolio['User/Field'] = 0
|
174 |
-
|
175 |
-
return RandomPortfolio, maps_dict, ranges_dict, full_pos_player_dict
|
176 |
-
|
177 |
-
def get_correlated_portfolio_for_sim(Total_Sample_Size):
|
178 |
-
|
179 |
-
sizesplit = round(Total_Sample_Size * .50)
|
180 |
-
|
181 |
-
RandomPortfolio, maps_dict, ranges_dict, full_pos_player_dict = create_random_portfolio(sizesplit)
|
182 |
-
|
183 |
-
RandomPortfolio['CPT'] = pd.Series(list(RandomPortfolio['CPT'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
184 |
-
RandomPortfolio['FLEX1'] = pd.Series(list(RandomPortfolio['FLEX1'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
185 |
-
RandomPortfolio['FLEX2'] = pd.Series(list(RandomPortfolio['FLEX2'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
186 |
-
RandomPortfolio['FLEX3'] = pd.Series(list(RandomPortfolio['FLEX3'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
187 |
-
RandomPortfolio['FLEX4'] = pd.Series(list(RandomPortfolio['FLEX4'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
188 |
-
RandomPortfolio['FLEX5'] = pd.Series(list(RandomPortfolio['FLEX5'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
189 |
-
RandomPortfolio['plyr_list'] = RandomPortfolio[RandomPortfolio.columns.values.tolist()].values.tolist()
|
190 |
-
RandomPortfolio['plyr_count'] = RandomPortfolio['plyr_list'].apply(lambda x: len(set(x)))
|
191 |
-
RandomPortfolio = RandomPortfolio[RandomPortfolio['plyr_count'] == 7].drop(columns=['plyr_list','plyr_count']).\
|
192 |
-
reset_index(drop=True)
|
193 |
-
|
194 |
-
del sizesplit
|
195 |
-
del full_pos_player_dict
|
196 |
-
del ranges_dict
|
197 |
-
|
198 |
-
RandomPortfolio['CPTs'] = RandomPortfolio['CPT'].map(maps_dict['Salary_map']).astype(np.int32) * 1.5
|
199 |
-
RandomPortfolio['FLEX1s'] = RandomPortfolio['FLEX1'].map(maps_dict['Salary_map']).astype(np.int32)
|
200 |
-
RandomPortfolio['FLEX2s'] = RandomPortfolio['FLEX2'].map(maps_dict['Salary_map']).astype(np.int32)
|
201 |
-
RandomPortfolio['FLEX3s'] = RandomPortfolio['FLEX3'].map(maps_dict['Salary_map']).astype(np.int32)
|
202 |
-
RandomPortfolio['FLEX4s'] = RandomPortfolio['FLEX4'].map(maps_dict['Salary_map']).astype(np.int32)
|
203 |
-
RandomPortfolio['FLEX5s'] = RandomPortfolio['FLEX5'].map(maps_dict['Salary_map']).astype(np.int32)
|
204 |
-
|
205 |
-
RandomPortfolio['CPTp'] = RandomPortfolio['CPT'].map(maps_dict['Projection_map']).astype(np.float16) * 1.5
|
206 |
-
RandomPortfolio['FLEX1p'] = RandomPortfolio['FLEX1'].map(maps_dict['Projection_map']).astype(np.float16)
|
207 |
-
RandomPortfolio['FLEX2p'] = RandomPortfolio['FLEX2'].map(maps_dict['Projection_map']).astype(np.float16)
|
208 |
-
RandomPortfolio['FLEX3p'] = RandomPortfolio['FLEX3'].map(maps_dict['Projection_map']).astype(np.float16)
|
209 |
-
RandomPortfolio['FLEX4p'] = RandomPortfolio['FLEX4'].map(maps_dict['Projection_map']).astype(np.float16)
|
210 |
-
RandomPortfolio['FLEX5p'] = RandomPortfolio['FLEX5'].map(maps_dict['Projection_map']).astype(np.float16)
|
211 |
-
|
212 |
-
RandomPortfolio['CPTo'] = RandomPortfolio['CPT'].map(maps_dict['Own_map']).astype(np.float16) / 4
|
213 |
-
RandomPortfolio['FLEX1o'] = RandomPortfolio['FLEX1'].map(maps_dict['Own_map']).astype(np.float16)
|
214 |
-
RandomPortfolio['FLEX2o'] = RandomPortfolio['FLEX2'].map(maps_dict['Own_map']).astype(np.float16)
|
215 |
-
RandomPortfolio['FLEX3o'] = RandomPortfolio['FLEX3'].map(maps_dict['Own_map']).astype(np.float16)
|
216 |
-
RandomPortfolio['FLEX4o'] = RandomPortfolio['FLEX4'].map(maps_dict['Own_map']).astype(np.float16)
|
217 |
-
RandomPortfolio['FLEX5o'] = RandomPortfolio['FLEX5'].map(maps_dict['Own_map']).astype(np.float16)
|
218 |
-
|
219 |
-
portHeaderList = RandomPortfolio.columns.values.tolist()
|
220 |
-
portHeaderList.append('Salary')
|
221 |
-
portHeaderList.append('Projection')
|
222 |
-
portHeaderList.append('Own')
|
223 |
-
|
224 |
-
RandomPortArray = RandomPortfolio.to_numpy()
|
225 |
-
del RandomPortfolio
|
226 |
-
|
227 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,7:13].astype(int))]
|
228 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,13:19].astype(np.double))]
|
229 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,19:25].astype(np.double))]
|
230 |
-
|
231 |
-
RandomPortArrayOut = np.delete(RandomPortArray, np.s_[7:25], axis=1)
|
232 |
-
RandomPortfolioDF = pd.DataFrame(RandomPortArrayOut, columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'User/Field', 'Salary', 'Projection', 'Own'])
|
233 |
-
RandomPortfolioDF = RandomPortfolioDF.sort_values(by=Sim_function, ascending=False)
|
234 |
-
del RandomPortArray
|
235 |
-
del RandomPortArrayOut
|
236 |
-
# st.table(RandomPortfolioDF.head(50))
|
237 |
-
|
238 |
-
if insert_port == 1:
|
239 |
-
CleanPortfolio['Salary'] = sum([CleanPortfolio['CPT'].map(maps_dict['Salary_map']) * 1.5,
|
240 |
-
CleanPortfolio['FLEX1'].map(maps_dict['Salary_map']),
|
241 |
-
CleanPortfolio['FLEX2'].map(maps_dict['Salary_map']),
|
242 |
-
CleanPortfolio['FLEX3'].map(maps_dict['Salary_map']),
|
243 |
-
CleanPortfolio['FLEX4'].map(maps_dict['Salary_map']),
|
244 |
-
CleanPortfolio['FLEX5'].map(maps_dict['Salary_map'])
|
245 |
-
]).astype(np.int16)
|
246 |
-
if insert_port == 1:
|
247 |
-
CleanPortfolio['Projection'] = sum([CleanPortfolio['CPT'].map(maps_dict['Projection_map']) * 1.5,
|
248 |
-
CleanPortfolio['FLEX1'].map(maps_dict['Projection_map']),
|
249 |
-
CleanPortfolio['FLEX2'].map(maps_dict['Projection_map']),
|
250 |
-
CleanPortfolio['FLEX3'].map(maps_dict['Projection_map']),
|
251 |
-
CleanPortfolio['FLEX4'].map(maps_dict['Projection_map']),
|
252 |
-
CleanPortfolio['FLEX5'].map(maps_dict['Projection_map'])
|
253 |
-
]).astype(np.float16)
|
254 |
-
if insert_port == 1:
|
255 |
-
CleanPortfolio['Own'] = sum([CleanPortfolio['CPT'].map(maps_dict['own_map']) / 4,
|
256 |
-
CleanPortfolio['FLEX1'].map(maps_dict['own_map']),
|
257 |
-
CleanPortfolio['FLEX2'].map(maps_dict['own_map']),
|
258 |
-
CleanPortfolio['FLEX3'].map(maps_dict['own_map']),
|
259 |
-
CleanPortfolio['FLEX4'].map(maps_dict['own_map']),
|
260 |
-
CleanPortfolio['FLEX5'].map(maps_dict['own_map'])
|
261 |
-
]).astype(np.float16)
|
262 |
-
|
263 |
-
if site_var1 == 'Draftkings':
|
264 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] <= 50000].reset_index(drop=True)
|
265 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] >= 49500 - (FieldStrength * 1000)].reset_index(drop=True)
|
266 |
-
elif site_var1 == 'Fanduel':
|
267 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] <= 60000].reset_index(drop=True)
|
268 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] >= 59500 - (FieldStrength * 1000)].reset_index(drop=True)
|
269 |
-
|
270 |
-
RandomPortfolio = RandomPortfolioDF.sort_values(by=Sim_function, ascending=False)
|
271 |
-
|
272 |
-
RandomPortfolio = RandomPortfolio[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'User/Field', 'Salary', 'Projection', 'Own']]
|
273 |
-
|
274 |
-
return RandomPortfolio, maps_dict
|
275 |
-
|
276 |
-
def get_uncorrelated_portfolio_for_sim(Total_Sample_Size):
|
277 |
-
|
278 |
-
sizesplit = round(Total_Sample_Size * .50)
|
279 |
-
|
280 |
-
RandomPortfolio, maps_dict, ranges_dict, full_pos_player_dict = create_random_portfolio(sizesplit)
|
281 |
-
|
282 |
-
RandomPortfolio['CPT'] = pd.Series(list(RandomPortfolio['CPT'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
283 |
-
RandomPortfolio['FLEX1'] = pd.Series(list(RandomPortfolio['FLEX1'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
284 |
-
RandomPortfolio['FLEX2'] = pd.Series(list(RandomPortfolio['FLEX2'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
285 |
-
RandomPortfolio['FLEX3'] = pd.Series(list(RandomPortfolio['FLEX3'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
286 |
-
RandomPortfolio['FLEX4'] = pd.Series(list(RandomPortfolio['FLEX4'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
287 |
-
RandomPortfolio['FLEX5'] = pd.Series(list(RandomPortfolio['FLEX5'].map(full_pos_player_dict['pos_dicts'][0])), dtype="string[pyarrow]")
|
288 |
-
RandomPortfolio['plyr_list'] = RandomPortfolio[RandomPortfolio.columns.values.tolist()].values.tolist()
|
289 |
-
RandomPortfolio['plyr_count'] = RandomPortfolio['plyr_list'].apply(lambda x: len(set(x)))
|
290 |
-
RandomPortfolio = RandomPortfolio[RandomPortfolio['plyr_count'] == 7].drop(columns=['plyr_list','plyr_count']).\
|
291 |
-
reset_index(drop=True)
|
292 |
-
|
293 |
-
del sizesplit
|
294 |
-
del full_pos_player_dict
|
295 |
-
del ranges_dict
|
296 |
-
|
297 |
-
RandomPortfolio['CPTs'] = RandomPortfolio['CPT'].map(maps_dict['Salary_map']).astype(np.int32) * 1.5
|
298 |
-
RandomPortfolio['FLEX1s'] = RandomPortfolio['FLEX1'].map(maps_dict['Salary_map']).astype(np.int32)
|
299 |
-
RandomPortfolio['FLEX2s'] = RandomPortfolio['FLEX2'].map(maps_dict['Salary_map']).astype(np.int32)
|
300 |
-
RandomPortfolio['FLEX3s'] = RandomPortfolio['FLEX3'].map(maps_dict['Salary_map']).astype(np.int32)
|
301 |
-
RandomPortfolio['FLEX4s'] = RandomPortfolio['FLEX4'].map(maps_dict['Salary_map']).astype(np.int32)
|
302 |
-
RandomPortfolio['FLEX5s'] = RandomPortfolio['FLEX5'].map(maps_dict['Salary_map']).astype(np.int32)
|
303 |
-
|
304 |
-
RandomPortfolio['CPTp'] = RandomPortfolio['CPT'].map(maps_dict['Projection_map']).astype(np.float16) * 1.5
|
305 |
-
RandomPortfolio['FLEX1p'] = RandomPortfolio['FLEX1'].map(maps_dict['Projection_map']).astype(np.float16)
|
306 |
-
RandomPortfolio['FLEX2p'] = RandomPortfolio['FLEX2'].map(maps_dict['Projection_map']).astype(np.float16)
|
307 |
-
RandomPortfolio['FLEX3p'] = RandomPortfolio['FLEX3'].map(maps_dict['Projection_map']).astype(np.float16)
|
308 |
-
RandomPortfolio['FLEX4p'] = RandomPortfolio['FLEX4'].map(maps_dict['Projection_map']).astype(np.float16)
|
309 |
-
RandomPortfolio['FLEX5p'] = RandomPortfolio['FLEX5'].map(maps_dict['Projection_map']).astype(np.float16)
|
310 |
-
|
311 |
-
RandomPortfolio['CPTo'] = RandomPortfolio['CPT'].map(maps_dict['Own_map']).astype(np.float16) / 4
|
312 |
-
RandomPortfolio['FLEX1o'] = RandomPortfolio['FLEX1'].map(maps_dict['Own_map']).astype(np.float16)
|
313 |
-
RandomPortfolio['FLEX2o'] = RandomPortfolio['FLEX2'].map(maps_dict['Own_map']).astype(np.float16)
|
314 |
-
RandomPortfolio['FLEX3o'] = RandomPortfolio['FLEX3'].map(maps_dict['Own_map']).astype(np.float16)
|
315 |
-
RandomPortfolio['FLEX4o'] = RandomPortfolio['FLEX4'].map(maps_dict['Own_map']).astype(np.float16)
|
316 |
-
RandomPortfolio['FLEX5o'] = RandomPortfolio['FLEX5'].map(maps_dict['Own_map']).astype(np.float16)
|
317 |
-
|
318 |
-
portHeaderList = RandomPortfolio.columns.values.tolist()
|
319 |
-
portHeaderList.append('Salary')
|
320 |
-
portHeaderList.append('Projection')
|
321 |
-
portHeaderList.append('Own')
|
322 |
-
|
323 |
-
RandomPortArray = RandomPortfolio.to_numpy()
|
324 |
-
del RandomPortfolio
|
325 |
-
|
326 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,7:13].astype(int))]
|
327 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,13:19].astype(np.double))]
|
328 |
-
RandomPortArray = np.c_[RandomPortArray, np.einsum('ij->i',RandomPortArray[:,19:25].astype(np.double))]
|
329 |
-
|
330 |
-
RandomPortArrayOut = np.delete(RandomPortArray, np.s_[7:25], axis=1)
|
331 |
-
RandomPortfolioDF = pd.DataFrame(RandomPortArrayOut, columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'User/Field', 'Salary', 'Projection', 'Own'])
|
332 |
-
RandomPortfolioDF = RandomPortfolioDF.sort_values(by=Sim_function, ascending=False)
|
333 |
-
del RandomPortArray
|
334 |
-
del RandomPortArrayOut
|
335 |
-
# st.table(RandomPortfolioDF.head(50))
|
336 |
-
|
337 |
-
if insert_port == 1:
|
338 |
-
CleanPortfolio['Salary'] = sum([CleanPortfolio['CPT'].map(maps_dict['Salary_map']) * 1.5,
|
339 |
-
CleanPortfolio['FLEX1'].map(maps_dict['Salary_map']),
|
340 |
-
CleanPortfolio['FLEX2'].map(maps_dict['Salary_map']),
|
341 |
-
CleanPortfolio['FLEX3'].map(maps_dict['Salary_map']),
|
342 |
-
CleanPortfolio['FLEX4'].map(maps_dict['Salary_map']),
|
343 |
-
CleanPortfolio['FLEX5'].map(maps_dict['Salary_map'])
|
344 |
-
]).astype(np.int16)
|
345 |
-
if insert_port == 1:
|
346 |
-
CleanPortfolio['Projection'] = sum([CleanPortfolio['CPT'].map(maps_dict['Projection_map']) * 1.5,
|
347 |
-
CleanPortfolio['FLEX1'].map(maps_dict['Projection_map']),
|
348 |
-
CleanPortfolio['FLEX2'].map(maps_dict['Projection_map']),
|
349 |
-
CleanPortfolio['FLEX3'].map(maps_dict['Projection_map']),
|
350 |
-
CleanPortfolio['FLEX4'].map(maps_dict['Projection_map']),
|
351 |
-
CleanPortfolio['FLEX5'].map(maps_dict['Projection_map'])
|
352 |
-
]).astype(np.float16)
|
353 |
-
if insert_port == 1:
|
354 |
-
CleanPortfolio['Own'] = sum([CleanPortfolio['CPT'].map(maps_dict['own_map']) / 4,
|
355 |
-
CleanPortfolio['FLEX1'].map(maps_dict['own_map']),
|
356 |
-
CleanPortfolio['FLEX2'].map(maps_dict['own_map']),
|
357 |
-
CleanPortfolio['FLEX3'].map(maps_dict['own_map']),
|
358 |
-
CleanPortfolio['FLEX4'].map(maps_dict['own_map']),
|
359 |
-
CleanPortfolio['FLEX5'].map(maps_dict['own_map'])
|
360 |
-
]).astype(np.float16)
|
361 |
-
|
362 |
-
if site_var1 == 'Draftkings':
|
363 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] <= 50000].reset_index(drop=True)
|
364 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] >= 49500 - (FieldStrength * 1000)].reset_index(drop=True)
|
365 |
-
elif site_var1 == 'Fanduel':
|
366 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] <= 60000].reset_index(drop=True)
|
367 |
-
RandomPortfolioDF = RandomPortfolioDF[RandomPortfolioDF['Salary'] >= 59500 - (FieldStrength * 1000)].reset_index(drop=True)
|
368 |
-
|
369 |
-
RandomPortfolio = RandomPortfolioDF.sort_values(by=Sim_function, ascending=False)
|
370 |
-
|
371 |
-
RandomPortfolio = RandomPortfolio[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'User/Field', 'Salary', 'Projection', 'Own']]
|
372 |
-
|
373 |
-
return RandomPortfolio, maps_dict
|
374 |
-
|
375 |
-
dk_roo_raw = load_dk_player_projections()
|
376 |
-
fd_roo_raw = load_fd_player_projections()
|
377 |
-
|
378 |
-
static_exposure = pd.DataFrame(columns=['Player', 'count'])
|
379 |
-
overall_exposure = pd.DataFrame(columns=['Player', 'count'])
|
380 |
-
|
381 |
-
tab1, tab2 = st.tabs(['Uploads', 'Contest Sim'])
|
382 |
-
|
383 |
-
with tab1:
|
384 |
-
with st.container():
|
385 |
-
st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', and 'Own'. Upload your projections first to avoid an error message.")
|
386 |
-
col1, col2 = st.columns([3, 3])
|
387 |
-
|
388 |
-
with col1:
|
389 |
-
proj_file = st.file_uploader("Upload Projections File", key = 'proj_uploader')
|
390 |
-
|
391 |
-
if proj_file is not None:
|
392 |
-
try:
|
393 |
-
proj_dataframe = pd.read_csv(proj_file)
|
394 |
-
proj_dataframe = proj_dataframe.dropna(subset='Median')
|
395 |
-
except:
|
396 |
-
proj_dataframe = pd.read_excel(proj_file)
|
397 |
-
proj_dataframe = proj_dataframe.dropna(subset='Median')
|
398 |
-
|
399 |
-
player_salary_dict = dict(zip(proj_dataframe.Player, proj_dataframe.Salary))
|
400 |
-
player_proj_dict = dict(zip(proj_dataframe.Player, proj_dataframe.Median))
|
401 |
-
player_own_dict = dict(zip(proj_dataframe.Player, proj_dataframe.Own))
|
402 |
-
player_team_dict = dict(zip(proj_dataframe.Player, proj_dataframe.Team))
|
403 |
-
|
404 |
-
with col2:
|
405 |
-
portfolio_file = st.file_uploader("Upload Portfolio File", key = 'portfolio_uploader')
|
406 |
-
|
407 |
-
if portfolio_file is not None:
|
408 |
-
try:
|
409 |
-
portfolio_dataframe = pd.read_csv(portfolio_file)
|
410 |
-
except:
|
411 |
-
portfolio_dataframe = pd.read_excel(portfolio_file)
|
412 |
-
try:
|
413 |
-
try:
|
414 |
-
portfolio_dataframe.columns=["CPT", "FLEX1", "FLEX2", "FLEX3", "FLEX4", "FLEX5"]
|
415 |
-
split_portfolio = portfolio_dataframe
|
416 |
-
split_portfolio[['CPT', 'CPT_ID']] = split_portfolio.CPT.str.split("(", n=1, expand = True)
|
417 |
-
split_portfolio[['FLEX1', 'FLEX1_ID']] = split_portfolio.FLEX1.str.split("(", n=1, expand = True)
|
418 |
-
split_portfolio[['FLEX2', 'FLEX2_ID']] = split_portfolio.FLEX2.str.split("(", n=1, expand = True)
|
419 |
-
split_portfolio[['FLEX3', 'FLEX3_ID']] = split_portfolio.FLEX3.str.split("(", n=1, expand = True)
|
420 |
-
split_portfolio[['FLEX4', 'FLEX4_ID']] = split_portfolio.FLEX4.str.split("(", n=1, expand = True)
|
421 |
-
split_portfolio[['FLEX5', 'FLEX5_ID']] = split_portfolio.FLEX5.str.split("(", n=1, expand = True)
|
422 |
-
|
423 |
-
split_portfolio['CPT'] = split_portfolio['CPT'].str.strip()
|
424 |
-
split_portfolio['FLEX1'] = split_portfolio['FLEX1'].str.strip()
|
425 |
-
split_portfolio['FLEX2'] = split_portfolio['FLEX2'].str.strip()
|
426 |
-
split_portfolio['FLEX3'] = split_portfolio['FLEX3'].str.strip()
|
427 |
-
split_portfolio['FLEX4'] = split_portfolio['FLEX4'].str.strip()
|
428 |
-
split_portfolio['FLEX5'] = split_portfolio['FLEX5'].str.strip()
|
429 |
-
|
430 |
-
CPT_dict = dict(zip(split_portfolio.CPT, split_portfolio.CPT_ID))
|
431 |
-
FLEX1_dict = dict(zip(split_portfolio.FLEX1, split_portfolio.FLEX1_ID))
|
432 |
-
FLEX2_dict = dict(zip(split_portfolio.FLEX2, split_portfolio.FLEX2_ID))
|
433 |
-
FLEX3_dict = dict(zip(split_portfolio.FLEX3, split_portfolio.FLEX3_ID))
|
434 |
-
FLEX4_dict = dict(zip(split_portfolio.FLEX4, split_portfolio.FLEX4_ID))
|
435 |
-
FLEX5_dict = dict(zip(split_portfolio.FLEX5, split_portfolio.FLEX5_ID))
|
436 |
-
|
437 |
-
split_portfolio['Salary'] = sum([split_portfolio['CPT'].map(player_salary_dict) * 1.5,
|
438 |
-
split_portfolio['FLEX1'].map(player_salary_dict),
|
439 |
-
split_portfolio['FLEX2'].map(player_salary_dict),
|
440 |
-
split_portfolio['FLEX3'].map(player_salary_dict),
|
441 |
-
split_portfolio['FLEX4'].map(player_salary_dict),
|
442 |
-
split_portfolio['FLEX5'].map(player_salary_dict)])
|
443 |
-
|
444 |
-
del player_salary_dict
|
445 |
-
|
446 |
-
split_portfolio['Projection'] = sum([split_portfolio['CPT'].map(player_proj_dict) * 1.5,
|
447 |
-
split_portfolio['FLEX1'].map(player_proj_dict),
|
448 |
-
split_portfolio['FLEX2'].map(player_proj_dict),
|
449 |
-
split_portfolio['FLEX3'].map(player_proj_dict),
|
450 |
-
split_portfolio['FLEX4'].map(player_proj_dict),
|
451 |
-
split_portfolio['FLEX5'].map(player_proj_dict)])
|
452 |
-
|
453 |
-
del player_proj_dict
|
454 |
-
|
455 |
-
split_portfolio['Ownership'] = sum([split_portfolio['CPT'].map(player_own_dict) / 4,
|
456 |
-
split_portfolio['FLEX1'].map(player_own_dict),
|
457 |
-
split_portfolio['FLEX2'].map(player_own_dict),
|
458 |
-
split_portfolio['FLEX3'].map(player_own_dict),
|
459 |
-
split_portfolio['FLEX4'].map(player_own_dict),
|
460 |
-
split_portfolio['FLEX5'].map(player_own_dict)])
|
461 |
-
|
462 |
-
del player_own_dict
|
463 |
-
|
464 |
-
split_portfolio['CPT_team'] = split_portfolio['CPT'].map(player_team_dict)
|
465 |
-
split_portfolio['FLEX1_team'] = split_portfolio['FLEX1'].map(player_team_dict)
|
466 |
-
split_portfolio['FLEX2_team'] = split_portfolio['FLEX2'].map(player_team_dict)
|
467 |
-
split_portfolio['FLEX3_team'] = split_portfolio['FLEX3'].map(player_team_dict)
|
468 |
-
split_portfolio['FLEX4_team'] = split_portfolio['FLEX4'].map(player_team_dict)
|
469 |
-
split_portfolio['FLEX5_team'] = split_portfolio['FLEX5'].map(player_team_dict)
|
470 |
-
|
471 |
-
split_portfolio = split_portfolio[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'Salary', 'Projection', 'Ownership', 'CPT_team',
|
472 |
-
'FLEX1_team', 'FLEX2_team', 'FLEX3_team', 'FLEX4_team', 'FLEX5_team']]
|
473 |
-
|
474 |
-
split_portfolio['Main_Stack'] = 0
|
475 |
-
split_portfolio['Main_Stack_Size'] = 0
|
476 |
-
split_portfolio['Main_Stack_Size'] = 0
|
477 |
-
except:
|
478 |
-
portfolio_dataframe.columns=["CPT", "FLEX1", "FLEX2", "FLEX3", "FLEX4", "FLEX5"]
|
479 |
-
split_portfolio = portfolio_dataframe
|
480 |
-
split_portfolio[['CPT_ID', 'CPT']] = split_portfolio.CPT.str.split(":", n=1, expand = True)
|
481 |
-
split_portfolio[['FLEX1_ID', 'FLEX1']] = split_portfolio.FLEX1.str.split(":", n=1, expand = True)
|
482 |
-
split_portfolio[['FLEX2_ID', 'FLEX2']] = split_portfolio.FLEX2.str.split(":", n=1, expand = True)
|
483 |
-
split_portfolio[['FLEX3_ID', 'FLEX3']] = split_portfolio.FLEX3.str.split(":", n=1, expand = True)
|
484 |
-
split_portfolio[['FLEX4_ID', 'FLEX4']] = split_portfolio.FLEX4.str.split(":", n=1, expand = True)
|
485 |
-
split_portfolio[['FLEX5_ID', 'FLEX5']] = split_portfolio.FLEX5.str.split(":", n=1, expand = True)
|
486 |
-
|
487 |
-
split_portfolio['CPT'] = split_portfolio['CPT'].str.strip()
|
488 |
-
split_portfolio['FLEX1'] = split_portfolio['FLEX1'].str.strip()
|
489 |
-
split_portfolio['FLEX2'] = split_portfolio['FLEX2'].str.strip()
|
490 |
-
split_portfolio['FLEX3'] = split_portfolio['FLEX3'].str.strip()
|
491 |
-
split_portfolio['FLEX4'] = split_portfolio['FLEX4'].str.strip()
|
492 |
-
split_portfolio['FLEX5'] = split_portfolio['FLEX5'].str.strip()
|
493 |
-
|
494 |
-
CPT_dict = dict(zip(split_portfolio.CPT, split_portfolio.CPT_ID))
|
495 |
-
FLEX1_dict = dict(zip(split_portfolio.FLEX1, split_portfolio.FLEX1_ID))
|
496 |
-
FLEX2_dict = dict(zip(split_portfolio.FLEX2, split_portfolio.FLEX2_ID))
|
497 |
-
FLEX3_dict = dict(zip(split_portfolio.FLEX3, split_portfolio.FLEX3_ID))
|
498 |
-
FLEX4_dict = dict(zip(split_portfolio.FLEX4, split_portfolio.FLEX4_ID))
|
499 |
-
FLEX5_dict = dict(zip(split_portfolio.FLEX5, split_portfolio.FLEX5_ID))
|
500 |
-
|
501 |
-
split_portfolio['Salary'] = sum([split_portfolio['CPT'].map(player_salary_dict),
|
502 |
-
split_portfolio['FLEX1'].map(player_salary_dict),
|
503 |
-
split_portfolio['FLEX2'].map(player_salary_dict),
|
504 |
-
split_portfolio['FLEX3'].map(player_salary_dict),
|
505 |
-
split_portfolio['FLEX4'].map(player_salary_dict),
|
506 |
-
split_portfolio['FLEX5'].map(player_salary_dict)])
|
507 |
-
|
508 |
-
del player_salary_dict
|
509 |
-
|
510 |
-
split_portfolio['Projection'] = sum([split_portfolio['CPT'].map(player_proj_dict) * 1.5,
|
511 |
-
split_portfolio['FLEX1'].map(player_proj_dict),
|
512 |
-
split_portfolio['FLEX2'].map(player_proj_dict),
|
513 |
-
split_portfolio['FLEX3'].map(player_proj_dict),
|
514 |
-
split_portfolio['FLEX4'].map(player_proj_dict),
|
515 |
-
split_portfolio['FLEX5'].map(player_proj_dict)])
|
516 |
-
|
517 |
-
del player_proj_dict
|
518 |
-
|
519 |
-
split_portfolio['Ownership'] = sum([split_portfolio['CPT'].map(player_own_dict) / 4,
|
520 |
-
split_portfolio['FLEX1'].map(player_own_dict),
|
521 |
-
split_portfolio['FLEX2'].map(player_own_dict),
|
522 |
-
split_portfolio['FLEX3'].map(player_own_dict),
|
523 |
-
split_portfolio['FLEX4'].map(player_own_dict),
|
524 |
-
split_portfolio['FLEX5'].map(player_own_dict)])
|
525 |
-
|
526 |
-
del player_own_dict
|
527 |
-
|
528 |
-
split_portfolio['CPT_team'] = split_portfolio['CPT'].map(player_team_dict)
|
529 |
-
split_portfolio['FLEX1_team'] = split_portfolio['FLEX1'].map(player_team_dict)
|
530 |
-
split_portfolio['FLEX2_team'] = split_portfolio['FLEX2'].map(player_team_dict)
|
531 |
-
split_portfolio['FLEX3_team'] = split_portfolio['FLEX3'].map(player_team_dict)
|
532 |
-
split_portfolio['FLEX4_team'] = split_portfolio['FLEX4'].map(player_team_dict)
|
533 |
-
split_portfolio['FLEX5_team'] = split_portfolio['FLEX5'].map(player_team_dict)
|
534 |
-
|
535 |
-
split_portfolio = split_portfolio[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'Salary', 'Projection', 'Ownership', 'CPT_team',
|
536 |
-
'FLEX1_team', 'FLEX2_team', 'FLEX3_team', 'FLEX4_team', 'FLEX5_team']]
|
537 |
-
|
538 |
-
split_portfolio['Main_Stack'] = 0
|
539 |
-
split_portfolio['Main_Stack_Size'] = 0
|
540 |
-
split_portfolio['Main_Stack_Size'] = 0
|
541 |
-
except:
|
542 |
-
split_portfolio = portfolio_dataframe
|
543 |
-
|
544 |
-
split_portfolio['CPT'] = split_portfolio['CPT'].str[:-6]
|
545 |
-
split_portfolio['FLEX1'] = split_portfolio['FLEX1'].str[:-6]
|
546 |
-
split_portfolio['FLEX2'] = split_portfolio['FLEX2'].str[:-6]
|
547 |
-
split_portfolio['FLEX3'] = split_portfolio['FLEX3'].str[:-6]
|
548 |
-
split_portfolio['FLEX4'] = split_portfolio['FLEX4'].str[:-6]
|
549 |
-
split_portfolio['FLEX5'] = split_portfolio['FLEX5'].str[:-6]
|
550 |
-
|
551 |
-
split_portfolio['CPT'] = split_portfolio['CPT'].str.strip()
|
552 |
-
split_portfolio['FLEX1'] = split_portfolio['FLEX1'].str.strip()
|
553 |
-
split_portfolio['FLEX2'] = split_portfolio['FLEX2'].str.strip()
|
554 |
-
split_portfolio['FLEX3'] = split_portfolio['FLEX3'].str.strip()
|
555 |
-
split_portfolio['FLEX4'] = split_portfolio['FLEX4'].str.strip()
|
556 |
-
split_portfolio['FLEX5'] = split_portfolio['FLEX5'].str.strip()
|
557 |
-
|
558 |
-
split_portfolio['Salary'] = sum([split_portfolio['CPT'].map(player_salary_dict) * 1.5,
|
559 |
-
split_portfolio['FLEX1'].map(player_salary_dict),
|
560 |
-
split_portfolio['FLEX2'].map(player_salary_dict),
|
561 |
-
split_portfolio['FLEX3'].map(player_salary_dict),
|
562 |
-
split_portfolio['FLEX4'].map(player_salary_dict),
|
563 |
-
split_portfolio['FLEX5'].map(player_salary_dict)])
|
564 |
-
|
565 |
-
del player_salary_dict
|
566 |
-
|
567 |
-
split_portfolio['Projection'] = sum([split_portfolio['CPT'].map(player_proj_dict) * 1.5,
|
568 |
-
split_portfolio['FLEX1'].map(player_proj_dict),
|
569 |
-
split_portfolio['FLEX2'].map(player_proj_dict),
|
570 |
-
split_portfolio['FLEX3'].map(player_proj_dict),
|
571 |
-
split_portfolio['FLEX4'].map(player_proj_dict),
|
572 |
-
split_portfolio['FLEX5'].map(player_proj_dict)])
|
573 |
-
|
574 |
-
del player_proj_dict
|
575 |
-
|
576 |
-
split_portfolio['Ownership'] = sum([split_portfolio['CPT'].map(player_own_dict) / 4,
|
577 |
-
split_portfolio['FLEX1'].map(player_own_dict),
|
578 |
-
split_portfolio['FLEX2'].map(player_own_dict),
|
579 |
-
split_portfolio['FLEX3'].map(player_own_dict),
|
580 |
-
split_portfolio['FLEX4'].map(player_own_dict),
|
581 |
-
split_portfolio['FLEX5'].map(player_own_dict)])
|
582 |
-
|
583 |
-
del player_own_dict
|
584 |
-
|
585 |
-
split_portfolio['CPT_team'] = split_portfolio['CPT'].map(player_team_dict)
|
586 |
-
split_portfolio['FLEX1_team'] = split_portfolio['FLEX1'].map(player_team_dict)
|
587 |
-
split_portfolio['FLEX2_team'] = split_portfolio['FLEX2'].map(player_team_dict)
|
588 |
-
split_portfolio['FLEX3_team'] = split_portfolio['FLEX3'].map(player_team_dict)
|
589 |
-
split_portfolio['FLEX4_team'] = split_portfolio['FLEX4'].map(player_team_dict)
|
590 |
-
split_portfolio['FLEX5_team'] = split_portfolio['FLEX5'].map(player_team_dict)
|
591 |
-
|
592 |
-
split_portfolio = split_portfolio[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'Salary', 'Projection', 'Ownership', 'CPT_team',
|
593 |
-
'FLEX1_team', 'FLEX2_team', 'FLEX3_team', 'FLEX4_team', 'FLEX5_team']]
|
594 |
-
|
595 |
-
split_portfolio['Main_Stack'] = 0
|
596 |
-
split_portfolio['Main_Stack_Size'] = 0
|
597 |
-
split_portfolio['Main_Stack_Size'] = 0
|
598 |
-
|
599 |
-
for player_cols in split_portfolio.iloc[:, 0:6]:
|
600 |
-
static_col_raw = split_portfolio[player_cols].value_counts()
|
601 |
-
static_col = static_col_raw.to_frame()
|
602 |
-
static_col.reset_index(inplace=True)
|
603 |
-
static_col.columns = ['Player', 'count']
|
604 |
-
static_exposure = pd.concat([static_exposure, static_col], ignore_index=True)
|
605 |
-
static_exposure['Exposure'] = static_exposure['count'] / len(split_portfolio)
|
606 |
-
static_exposure = static_exposure[['Player', 'Exposure']]
|
607 |
-
|
608 |
-
del static_col_raw
|
609 |
-
del static_col
|
610 |
-
with st.container():
|
611 |
-
col1, col2 = st.columns([3, 3])
|
612 |
-
|
613 |
-
if portfolio_file is not None:
|
614 |
-
with col1:
|
615 |
-
st.write(len(portfolio_dataframe))
|
616 |
-
team_split_var1 = st.radio("Are you wanting to isolate any lineups with specific main stacks?", ('Full Portfolio', 'Specific Stacks'))
|
617 |
-
if team_split_var1 == 'Specific Stacks':
|
618 |
-
team_var1 = st.multiselect('Which main stacks would you like to include in the Portfolio?', options = split_portfolio['Main_Stack'].unique())
|
619 |
-
elif team_split_var1 == 'Full Portfolio':
|
620 |
-
team_var1 = split_portfolio.Main_Stack.values.tolist()
|
621 |
-
with col2:
|
622 |
-
player_split_var1 = st.radio("Are you wanting to isolate any lineups with specific players?", ('Full Players', 'Specific Players'))
|
623 |
-
if player_split_var1 == 'Specific Players':
|
624 |
-
find_var1 = st.multiselect('Which players must be included in the lineups?', options = static_exposure['Player'].unique())
|
625 |
-
elif player_split_var1 == 'Full Players':
|
626 |
-
find_var1 = static_exposure.Player.values.tolist()
|
627 |
-
|
628 |
-
split_portfolio = split_portfolio[split_portfolio['Main_Stack'].isin(team_var1)]
|
629 |
-
if player_split_var1 == 'Specific Players':
|
630 |
-
split_portfolio = split_portfolio[np.equal.outer(split_portfolio.to_numpy(copy=False), find_var1).any(axis=1).all(axis=1)]
|
631 |
-
elif player_split_var1 == 'Full Players':
|
632 |
-
split_portfolio = split_portfolio
|
633 |
-
|
634 |
-
for player_cols in split_portfolio.iloc[:, 0:6]:
|
635 |
-
exposure_col_raw = split_portfolio[player_cols].value_counts()
|
636 |
-
exposure_col = exposure_col_raw.to_frame()
|
637 |
-
exposure_col.reset_index(inplace=True)
|
638 |
-
exposure_col.columns = ['Player', 'count']
|
639 |
-
overall_exposure = pd.concat([overall_exposure, exposure_col], ignore_index=True)
|
640 |
-
overall_exposure['Exposure'] = overall_exposure['count'] / len(split_portfolio)
|
641 |
-
overall_exposure = overall_exposure.groupby('Player').sum()
|
642 |
-
overall_exposure.reset_index(inplace=True)
|
643 |
-
overall_exposure = overall_exposure[['Player', 'Exposure']]
|
644 |
-
overall_exposure = overall_exposure.set_index('Player')
|
645 |
-
overall_exposure = overall_exposure.sort_values(by='Exposure', ascending=False)
|
646 |
-
overall_exposure['Exposure'] = overall_exposure['Exposure'].astype(float).map(lambda n: '{:.2%}'.format(n))
|
647 |
-
|
648 |
-
with st.container():
|
649 |
-
col1, col2 = st.columns([1, 6])
|
650 |
-
|
651 |
-
with col1:
|
652 |
-
if portfolio_file is not None:
|
653 |
-
st.header('Exposure View')
|
654 |
-
st.dataframe(overall_exposure)
|
655 |
-
|
656 |
-
with col2:
|
657 |
-
if portfolio_file is not None:
|
658 |
-
st.header('Portfolio View')
|
659 |
-
split_portfolio = split_portfolio.reset_index()
|
660 |
-
split_portfolio['Lineup'] = split_portfolio['index'] + 1
|
661 |
-
display_portfolio = split_portfolio[['Lineup', 'CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5', 'Salary', 'Main_Stack', 'Main_Stack_Size', 'Projection', 'Ownership']]
|
662 |
-
hold_display = display_portfolio
|
663 |
-
display_portfolio = display_portfolio.set_index('Lineup')
|
664 |
-
st.dataframe(display_portfolio.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').background_gradient(cmap='RdYlGn_r', subset=['Ownership']).format(precision=2))
|
665 |
-
del split_portfolio
|
666 |
-
del exposure_col_raw
|
667 |
-
del exposure_col
|
668 |
-
with tab2:
|
669 |
-
col1, col2 = st.columns([1, 5])
|
670 |
-
with col1:
|
671 |
-
if st.button("Load/Reset Data", key='reset1'):
|
672 |
-
st.cache_data.clear()
|
673 |
-
dk_roo_raw = load_dk_player_projections()
|
674 |
-
fd_roo_raw = load_fd_player_projections()
|
675 |
-
|
676 |
-
slate_var1 = st.radio("Which data are you loading?", ('Paydirt', 'User'))
|
677 |
-
site_var1 = 'Draftkings'
|
678 |
-
if site_var1 == 'Draftkings':
|
679 |
-
if slate_var1 == 'User':
|
680 |
-
raw_baselines = proj_dataframe[['Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', 'Own']]
|
681 |
-
elif slate_var1 != 'User':
|
682 |
-
raw_baselines = dk_roo_raw
|
683 |
-
elif site_var1 == 'Fanduel':
|
684 |
-
if slate_var1 == 'User':
|
685 |
-
raw_baselines = proj_dataframe
|
686 |
-
elif slate_var1 != 'User':
|
687 |
-
raw_baselines = fd_roo_raw
|
688 |
-
st.info("If you are uploading a portfolio, note that there is an adjustments to projections and deviation mapping to prevent 'Projection Bias' and create a fair simulation")
|
689 |
-
insert_port1 = st.selectbox("Are you uploading a portfolio?", ('No', 'Yes'))
|
690 |
-
if insert_port1 == 'Yes':
|
691 |
-
insert_port = 1
|
692 |
-
elif insert_port1 == 'No':
|
693 |
-
insert_port = 0
|
694 |
-
contest_var1 = st.selectbox("What contest size are you simulating?", ('Small', 'Medium', 'Large'))
|
695 |
-
if contest_var1 == 'Small':
|
696 |
-
Contest_Size = 500
|
697 |
-
elif contest_var1 == 'Medium':
|
698 |
-
Contest_Size = 2500
|
699 |
-
elif contest_var1 == 'Large':
|
700 |
-
Contest_Size = 10000
|
701 |
-
linenum_var1 = 1000
|
702 |
-
strength_var1 = st.selectbox("How sharp is the field in the contest?", ('Not Very', 'Average', 'Very'))
|
703 |
-
if strength_var1 == 'Not Very':
|
704 |
-
Strength_var = 1
|
705 |
-
scaling_var = 5
|
706 |
-
elif strength_var1 == 'Average':
|
707 |
-
Strength_var = .75
|
708 |
-
scaling_var = 10
|
709 |
-
elif strength_var1 == 'Very':
|
710 |
-
Strength_var = .5
|
711 |
-
scaling_var = 15
|
712 |
-
|
713 |
-
with col2:
|
714 |
-
if st.button("Simulate Contest", key='sim1'):
|
715 |
-
try:
|
716 |
-
del dst_freq
|
717 |
-
del flex_freq
|
718 |
-
del te_freq
|
719 |
-
del wr_freq
|
720 |
-
del rb_freq
|
721 |
-
del qb_freq
|
722 |
-
del player_freq
|
723 |
-
del Sim_Winner_Export
|
724 |
-
del Sim_Winner_Frame
|
725 |
-
except:
|
726 |
-
pass
|
727 |
-
with st.container():
|
728 |
-
st.write('Contest Simulation Starting')
|
729 |
-
Total_Runs = 1000000
|
730 |
-
seed_depth1 = 5
|
731 |
-
Total_Runs = 2500000
|
732 |
-
if Contest_Size <= 1000:
|
733 |
-
strength_grow = .01
|
734 |
-
elif Contest_Size > 1000 and Contest_Size <= 2500:
|
735 |
-
strength_grow = .025
|
736 |
-
elif Contest_Size > 2500 and Contest_Size <= 5000:
|
737 |
-
strength_grow = .05
|
738 |
-
elif Contest_Size > 5000 and Contest_Size <= 20000:
|
739 |
-
strength_grow = .075
|
740 |
-
elif Contest_Size > 20000:
|
741 |
-
strength_grow = .1
|
742 |
-
|
743 |
-
field_growth = 100 * strength_grow
|
744 |
-
|
745 |
-
Sort_function = 'Median'
|
746 |
-
if Sort_function == 'Median':
|
747 |
-
Sim_function = 'Projection'
|
748 |
-
elif Sort_function == 'Own':
|
749 |
-
Sim_function = 'Own'
|
750 |
-
|
751 |
-
if slate_var1 == 'User':
|
752 |
-
OwnFrame = proj_dataframe
|
753 |
-
if contest_var1 == 'Large':
|
754 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (10 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
755 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (5 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
756 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
757 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
758 |
-
if contest_var1 == 'Medium':
|
759 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (6 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
760 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (3 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
761 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
762 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
763 |
-
if contest_var1 == 'Small':
|
764 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (3 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
765 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (1.5 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
766 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
767 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
768 |
-
Overall_Proj = OwnFrame[['Player', 'Team', 'Position', 'Median', 'Own', 'Salary']]
|
769 |
-
|
770 |
-
del OwnFrame
|
771 |
-
|
772 |
-
elif slate_var1 != 'User':
|
773 |
-
initial_proj = raw_baselines
|
774 |
-
drop_frame = initial_proj.drop_duplicates(subset = 'Player',keep = 'first')
|
775 |
-
OwnFrame = drop_frame[['Player', 'Team', 'Position', 'Median', 'Own', 'Floor', 'Ceiling', 'Salary']]
|
776 |
-
if contest_var1 == 'Large':
|
777 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (10 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
778 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (5 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
779 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
780 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
781 |
-
if contest_var1 == 'Medium':
|
782 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (6 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
783 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (3 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
784 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
785 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
786 |
-
if contest_var1 == 'Small':
|
787 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] == 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (3 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] == 'QB', 'Own'].mean(), OwnFrame['Own'])
|
788 |
-
OwnFrame['Own%'] = np.where((OwnFrame['Position'] != 'QB') & (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean() >= 0), OwnFrame['Own'] * (1.5 * (OwnFrame['Own'] - OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean())/100) + OwnFrame.loc[OwnFrame['Position'] != 'QB', 'Own'].mean(), OwnFrame['Own%'])
|
789 |
-
OwnFrame['Own%'] = np.where(OwnFrame['Own%'] > 75, 75, OwnFrame['Own%'])
|
790 |
-
OwnFrame['Own'] = OwnFrame['Own%'] * (500 / OwnFrame['Own%'].sum())
|
791 |
-
Overall_Proj = OwnFrame[['Player', 'Team', 'Position', 'Median', 'Own', 'Floor', 'Ceiling', 'Salary']]
|
792 |
-
|
793 |
-
del initial_proj
|
794 |
-
del drop_frame
|
795 |
-
del OwnFrame
|
796 |
-
|
797 |
-
if insert_port == 1:
|
798 |
-
UserPortfolio = portfolio_dataframe[['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5']]
|
799 |
-
elif insert_port == 0:
|
800 |
-
UserPortfolio = pd.DataFrame(columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5'])
|
801 |
-
|
802 |
-
Overall_Proj.replace('', np.nan, inplace=True)
|
803 |
-
Overall_Proj = Overall_Proj.dropna(subset=['Median'])
|
804 |
-
Overall_Proj = Overall_Proj.assign(Value=lambda x: (x.Median / (x.Salary / 1000)))
|
805 |
-
Overall_Proj['Sort_var'] = (Overall_Proj['Median'].rank(ascending=False) + Overall_Proj['Value'].rank(ascending=False)) / 2
|
806 |
-
Overall_Proj = Overall_Proj.sort_values(by='Sort_var', ascending=False)
|
807 |
-
Overall_Proj['Own'] = np.where((Overall_Proj['Median'] > 0) & (Overall_Proj['Own'] == 0), 1, Overall_Proj['Own'])
|
808 |
-
Overall_Proj = Overall_Proj.loc[Overall_Proj['Own'] > 0]
|
809 |
-
|
810 |
-
Overall_Proj['Floor'] = np.where(Overall_Proj['Position'] == 'QB', Overall_Proj['Median'] * .5, Overall_Proj['Median'] * .25)
|
811 |
-
Overall_Proj['Ceiling'] = np.where(Overall_Proj['Position'] == 'WR', Overall_Proj['Median'] + Overall_Proj['Median'], Overall_Proj['Median'] + Overall_Proj['Floor'])
|
812 |
-
Overall_Proj['STDev'] = Overall_Proj['Median'] / 4
|
813 |
-
|
814 |
-
Teams_used = Overall_Proj['Team'].drop_duplicates().reset_index(drop=True)
|
815 |
-
Teams_used = Teams_used.reset_index()
|
816 |
-
Teams_used['team_item'] = Teams_used['index'] + 1
|
817 |
-
Teams_used = Teams_used.drop(columns=['index'])
|
818 |
-
Teams_used_dictraw = Teams_used.drop(columns=['team_item'])
|
819 |
-
Teams_used_dict = Teams_used_dictraw.to_dict()
|
820 |
-
|
821 |
-
del Teams_used_dictraw
|
822 |
-
|
823 |
-
team_list = Teams_used['Team'].to_list()
|
824 |
-
item_list = Teams_used['team_item'].to_list()
|
825 |
-
|
826 |
-
FieldStrength_raw = Strength_var + ((30 - len(Teams_used)) * .01)
|
827 |
-
FieldStrength = FieldStrength_raw - (FieldStrength_raw * (20000 / Contest_Size))
|
828 |
-
|
829 |
-
del FieldStrength_raw
|
830 |
-
|
831 |
-
if FieldStrength < 0:
|
832 |
-
FieldStrength = Strength_var
|
833 |
-
field_split = Strength_var
|
834 |
-
|
835 |
-
for checkVar in range(len(team_list)):
|
836 |
-
Overall_Proj['Team'] = Overall_Proj['Team'].replace(team_list, item_list)
|
837 |
-
|
838 |
-
flex_raw = Overall_Proj
|
839 |
-
flex_raw.dropna(subset=['Median']).reset_index(drop=True)
|
840 |
-
flex_raw = flex_raw.reset_index(drop=True)
|
841 |
-
flex_raw = flex_raw.sort_values(by='Own', ascending=False)
|
842 |
-
|
843 |
-
pos_players = flex_raw
|
844 |
-
pos_players.dropna(subset=['Median']).reset_index(drop=True)
|
845 |
-
pos_players = pos_players.reset_index(drop=True)
|
846 |
-
|
847 |
-
del flex_raw
|
848 |
-
|
849 |
-
if insert_port == 1:
|
850 |
-
try:
|
851 |
-
# Initialize an empty DataFrame to store raw portfolio data
|
852 |
-
Raw_Portfolio = pd.DataFrame()
|
853 |
-
|
854 |
-
# Split each portfolio column and concatenate to Raw_Portfolio
|
855 |
-
columns_to_process = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5']
|
856 |
-
for col in columns_to_process:
|
857 |
-
temp_df = UserPortfolio[col].str.split("(", n=1, expand=True)
|
858 |
-
temp_df.columns = [col, 'Drop']
|
859 |
-
Raw_Portfolio = pd.concat([Raw_Portfolio, temp_df], axis=1)
|
860 |
-
|
861 |
-
# Keep only required variables and remove whitespace
|
862 |
-
keep_vars = columns_to_process
|
863 |
-
CleanPortfolio = Raw_Portfolio[keep_vars]
|
864 |
-
CleanPortfolio = CleanPortfolio.apply(lambda x: x.str.strip())
|
865 |
-
|
866 |
-
# Reset index and clean up the DataFrame
|
867 |
-
CleanPortfolio.reset_index(inplace=True)
|
868 |
-
CleanPortfolio['User/Field'] = CleanPortfolio['index'] + 1
|
869 |
-
CleanPortfolio.drop(columns=['index'], inplace=True)
|
870 |
-
CleanPortfolio.replace('', np.nan, inplace=True)
|
871 |
-
CleanPortfolio.dropna(subset=['QB'], inplace=True)
|
872 |
-
|
873 |
-
# Create cleaport_players DataFrame
|
874 |
-
unique_vals, counts = np.unique(CleanPortfolio.iloc[:, 0:6].values, return_counts=True)
|
875 |
-
cleaport_players = pd.DataFrame(np.column_stack([unique_vals, counts]), columns=['Player', 'Freq']).astype({'Freq': int}).sort_values('Freq', ascending=False).reset_index(drop=True)
|
876 |
-
|
877 |
-
# Merge and update nerf_frame DataFrame
|
878 |
-
nerf_frame = pd.merge(cleaport_players, Overall_Proj, on='Player', how='left')
|
879 |
-
nerf_frame[['Median', 'Floor', 'Ceiling', 'STDev']] *= 0.9
|
880 |
-
del Raw_Portfolio
|
881 |
-
except:
|
882 |
-
# Reset index and perform column-wise operations
|
883 |
-
CleanPortfolio = UserPortfolio.reset_index(drop=True)
|
884 |
-
CleanPortfolio['User/Field'] = CleanPortfolio.index + 1
|
885 |
-
CleanPortfolio.replace('', np.nan, inplace=True)
|
886 |
-
CleanPortfolio.dropna(subset=['QB'], inplace=True)
|
887 |
-
|
888 |
-
# Create cleaport_players DataFrame
|
889 |
-
unique_vals, counts = np.unique(CleanPortfolio.iloc[:, 0:6].values, return_counts=True)
|
890 |
-
cleaport_players = pd.DataFrame({'Player': unique_vals, 'Freq': counts}).sort_values('Freq', ascending=False).reset_index(drop=True).astype({'Freq': int})
|
891 |
-
|
892 |
-
# Merge and update nerf_frame DataFrame
|
893 |
-
nerf_frame = pd.merge(cleaport_players, Overall_Proj, on='Player', how='left')
|
894 |
-
nerf_frame[['Median', 'Floor', 'Ceiling', 'STDev']] *= 0.9
|
895 |
-
|
896 |
-
elif insert_port == 0:
|
897 |
-
CleanPortfolio = UserPortfolio
|
898 |
-
cleaport_players = pd.DataFrame(np.column_stack(np.unique(CleanPortfolio.iloc[:,0:6].values, return_counts=True)),
|
899 |
-
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
900 |
-
cleaport_players['Freq'] = cleaport_players['Freq'].astype(int)
|
901 |
-
nerf_frame = Overall_Proj
|
902 |
-
|
903 |
-
ref_dict = {
|
904 |
-
'pos':['FLEX'],
|
905 |
-
'pos_dfs':['FLEX_Table'],
|
906 |
-
'pos_dicts':['flex_dict']
|
907 |
-
}
|
908 |
-
|
909 |
-
maps_dict = {
|
910 |
-
'Floor_map':dict(zip(Overall_Proj.Player,Overall_Proj.Floor)),
|
911 |
-
'Projection_map':dict(zip(Overall_Proj.Player,Overall_Proj.Median)),
|
912 |
-
'Ceiling_map':dict(zip(Overall_Proj.Player,Overall_Proj.Ceiling)),
|
913 |
-
'Salary_map':dict(zip(Overall_Proj.Player,Overall_Proj.Salary)),
|
914 |
-
'Pos_map':dict(zip(Overall_Proj.Player,Overall_Proj.Position)),
|
915 |
-
'Own_map':dict(zip(Overall_Proj.Player,Overall_Proj.Own)),
|
916 |
-
'Team_map':dict(zip(Overall_Proj.Player,Overall_Proj.Team)),
|
917 |
-
'STDev_map':dict(zip(Overall_Proj.Player,Overall_Proj.STDev)),
|
918 |
-
'team_check_map':dict(zip(Overall_Proj.Player,Overall_Proj.Team))
|
919 |
-
}
|
920 |
-
|
921 |
-
up_dict = {
|
922 |
-
'Floor_map':dict(zip(cleaport_players.Player,nerf_frame.Floor)),
|
923 |
-
'Projection_map':dict(zip(cleaport_players.Player,nerf_frame.Median)),
|
924 |
-
'Ceiling_map':dict(zip(cleaport_players.Player,nerf_frame.Ceiling)),
|
925 |
-
'Salary_map':dict(zip(cleaport_players.Player,nerf_frame.Salary)),
|
926 |
-
'Pos_map':dict(zip(cleaport_players.Player,nerf_frame.Position)),
|
927 |
-
'Own_map':dict(zip(cleaport_players.Player,nerf_frame.Own)),
|
928 |
-
'Team_map':dict(zip(cleaport_players.Player,nerf_frame.Team)),
|
929 |
-
'STDev_map':dict(zip(cleaport_players.Player,nerf_frame.STDev)),
|
930 |
-
'team_check_map':dict(zip(cleaport_players.Player,nerf_frame.Team))
|
931 |
-
}
|
932 |
-
|
933 |
-
del Overall_Proj
|
934 |
-
del nerf_frame
|
935 |
-
|
936 |
-
RunsVar = 1
|
937 |
-
st.write('Seed frame creation')
|
938 |
-
FinalPortfolio, maps_dict = run_seed_frame(seed_depth1, Strength_var, strength_grow, Teams_used, Total_Runs)
|
939 |
-
|
940 |
-
Sim_size = linenum_var1
|
941 |
-
SimVar = 1
|
942 |
-
Sim_Winners = []
|
943 |
-
fp_array = FinalPortfolio.values
|
944 |
-
if insert_port == 1:
|
945 |
-
up_array = CleanPortfolio.values
|
946 |
-
st.write('Simulating contest on frames')
|
947 |
-
while SimVar <= Sim_size:
|
948 |
-
try:
|
949 |
-
fp_random = fp_array[np.random.choice(fp_array.shape[0], Contest_Size-len(CleanPortfolio), replace=False)]
|
950 |
-
|
951 |
-
smple_arrays1 = np.c_[fp_random,
|
952 |
-
np.sum(np.random.normal(
|
953 |
-
loc = np.vectorize(maps_dict['Projection_map'].__getitem__)(fp_random[:,:-5]),
|
954 |
-
scale = np.vectorize(maps_dict['STDev_map'].__getitem__)(fp_random[:,:-5])),
|
955 |
-
axis=1)]
|
956 |
-
try:
|
957 |
-
smple_arrays2 = np.c_[up_array,
|
958 |
-
np.sum(np.random.normal(
|
959 |
-
loc = np.vectorize(up_dict['Projection_map'].__getitem__)(up_array[:,:-5]),
|
960 |
-
scale = np.vectorize(up_dict['STDev_map'].__getitem__)(up_array[:,:-5])),
|
961 |
-
axis=1)]
|
962 |
-
except:
|
963 |
-
pass
|
964 |
-
try:
|
965 |
-
smple_arrays = np.vstack((smple_arrays1, smple_arrays2))
|
966 |
-
except:
|
967 |
-
smple_arrays = smple_arrays1
|
968 |
-
final_array = smple_arrays[smple_arrays[:, 7].argsort()[::-1]]
|
969 |
-
best_lineup = final_array[final_array[:, -1].argsort(kind='stable')[::-1][:1]]
|
970 |
-
Sim_Winners.append(best_lineup)
|
971 |
-
SimVar += 1
|
972 |
-
|
973 |
-
except:
|
974 |
-
FieldStrength += (strength_grow + ((30 - len(Teams_used)) * .001))
|
975 |
-
FinalPortfolio3, maps_dict3 = get_correlated_portfolio_for_sim(Total_Runs * field_split)
|
976 |
-
FinalPortfolio4, maps_dict4 = get_uncorrelated_portfolio_for_sim(Total_Runs * field_split)
|
977 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio3], axis=0)
|
978 |
-
FinalPortfolio = pd.concat([FinalPortfolio, FinalPortfolio4], axis=0)
|
979 |
-
try:
|
980 |
-
FinalPortfolio = FinalPortfolio.drop_duplicates(subset = ['Projection', 'Ownership'],keep = 'last').reset_index(drop = True)
|
981 |
-
except:
|
982 |
-
FinalPortfolio = FinalPortfolio.drop_duplicates(subset = ['Projection', 'Own'],keep = 'last').reset_index(drop = True)
|
983 |
-
maps_dict.update(maps_dict3)
|
984 |
-
maps_dict.update(maps_dict4)
|
985 |
-
del FinalPortfolio3
|
986 |
-
del maps_dict3
|
987 |
-
del FinalPortfolio4
|
988 |
-
del maps_dict4
|
989 |
-
fp_array = FinalPortfolio.values
|
990 |
-
if insert_port == 1:
|
991 |
-
up_array = CleanPortfolio.values
|
992 |
-
SimVar = SimVar
|
993 |
-
st.write('Contest simulation complete')
|
994 |
-
|
995 |
-
Sim_Winner_Frame = pd.DataFrame(np.concatenate(Sim_Winners), columns=FinalPortfolio.columns.tolist() + ['Fantasy'])
|
996 |
-
Sim_Winner_Frame['GPP_Proj'] = (Sim_Winner_Frame['Projection'] + Sim_Winner_Frame['Fantasy']) / 2
|
997 |
-
Sim_Winner_Frame['Salary'] = Sim_Winner_Frame['Salary'].astype(int)
|
998 |
-
Sim_Winner_Frame['Projection'] = Sim_Winner_Frame['Projection'].astype(np.float16)
|
999 |
-
Sim_Winner_Frame['Fantasy'] = Sim_Winner_Frame['Fantasy'].astype(np.float16)
|
1000 |
-
Sim_Winner_Frame['GPP_Proj'] = Sim_Winner_Frame['GPP_Proj'].astype(np.float16)
|
1001 |
-
Sim_Winner_Frame = Sim_Winner_Frame.sort_values(by='GPP_Proj', ascending=False)
|
1002 |
-
|
1003 |
-
player_freq = pd.DataFrame(np.column_stack(np.unique(Sim_Winner_Frame.iloc[:,0:6].values, return_counts=True)),
|
1004 |
-
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
1005 |
-
player_freq['Freq'] = player_freq['Freq'].astype(int)
|
1006 |
-
player_freq['Position'] = player_freq['Player'].map(maps_dict['Pos_map'])
|
1007 |
-
player_freq['Salary'] = player_freq['Player'].map(maps_dict['Salary_map'])
|
1008 |
-
player_freq['Proj Own'] = (player_freq['Player'].map(maps_dict['Own_map']) / 100)
|
1009 |
-
player_freq['Exposure'] = player_freq['Freq']/(Sim_size)
|
1010 |
-
player_freq['Edge'] = player_freq['Exposure'] - player_freq['Proj Own']
|
1011 |
-
player_freq['Team'] = player_freq['Player'].map(maps_dict['Team_map'])
|
1012 |
-
for checkVar in range(len(team_list)):
|
1013 |
-
player_freq['Team'] = player_freq['Team'].replace(item_list, team_list)
|
1014 |
-
|
1015 |
-
player_freq = player_freq[['Player', 'Position', 'Team', 'Salary', 'Proj Own', 'Exposure', 'Edge']]
|
1016 |
-
|
1017 |
-
cpt_freq = pd.DataFrame(np.column_stack(np.unique(Sim_Winner_Frame.iloc[:,0:1].values, return_counts=True)),
|
1018 |
-
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
1019 |
-
cpt_freq['Freq'] = cpt_freq['Freq'].astype(int)
|
1020 |
-
cpt_freq['Position'] = cpt_freq['Player'].map(maps_dict['Pos_map'])
|
1021 |
-
cpt_freq['Salary'] = cpt_freq['Player'].map(maps_dict['Salary_map'])
|
1022 |
-
cpt_freq['Proj Own'] = (cpt_freq['Player'].map(maps_dict['Own_map']) / 4) / 100
|
1023 |
-
cpt_freq['Exposure'] = cpt_freq['Freq']/(Sim_size)
|
1024 |
-
cpt_freq['Edge'] = cpt_freq['Exposure'] - cpt_freq['Proj Own']
|
1025 |
-
cpt_freq['Team'] = cpt_freq['Player'].map(maps_dict['Team_map'])
|
1026 |
-
for checkVar in range(len(team_list)):
|
1027 |
-
cpt_freq['Team'] = cpt_freq['Team'].replace(item_list, team_list)
|
1028 |
-
|
1029 |
-
cpt_freq = cpt_freq[['Player', 'Position', 'Team', 'Salary', 'Proj Own', 'Exposure', 'Edge']]
|
1030 |
-
|
1031 |
-
flex_freq = pd.DataFrame(np.column_stack(np.unique(Sim_Winner_Frame.iloc[:,[1, 2, 3, 4, 5]].values, return_counts=True)),
|
1032 |
-
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
1033 |
-
flex_freq['Freq'] = flex_freq['Freq'].astype(int)
|
1034 |
-
flex_freq['Position'] = flex_freq['Player'].map(maps_dict['Pos_map'])
|
1035 |
-
flex_freq['Salary'] = flex_freq['Player'].map(maps_dict['Salary_map'])
|
1036 |
-
flex_freq['Proj Own'] = (flex_freq['Player'].map(maps_dict['Own_map']) / 100) - ((flex_freq['Player'].map(maps_dict['Own_map']) / 4) / 100)
|
1037 |
-
flex_freq['Exposure'] = flex_freq['Freq']/(Sim_size)
|
1038 |
-
flex_freq['Edge'] = flex_freq['Exposure'] - flex_freq['Proj Own']
|
1039 |
-
flex_freq['Team'] = flex_freq['Player'].map(maps_dict['Team_map'])
|
1040 |
-
for checkVar in range(len(team_list)):
|
1041 |
-
flex_freq['Team'] = flex_freq['Team'].replace(item_list, team_list)
|
1042 |
-
|
1043 |
-
flex_freq = flex_freq[['Player', 'Position', 'Team', 'Salary', 'Proj Own', 'Exposure', 'Edge']]
|
1044 |
-
|
1045 |
-
del fp_random
|
1046 |
-
del smple_arrays
|
1047 |
-
del final_array
|
1048 |
-
del fp_array
|
1049 |
-
try:
|
1050 |
-
del up_array
|
1051 |
-
except:
|
1052 |
-
pass
|
1053 |
-
del best_lineup
|
1054 |
-
del CleanPortfolio
|
1055 |
-
del FinalPortfolio
|
1056 |
-
del maps_dict
|
1057 |
-
del team_list
|
1058 |
-
del item_list
|
1059 |
-
del Sim_size
|
1060 |
-
|
1061 |
-
with st.container():
|
1062 |
-
st.dataframe(Sim_Winner_Frame.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').background_gradient(cmap='RdYlGn_r', subset=['Own']).format(precision=2), use_container_width = True)
|
1063 |
-
|
1064 |
-
with st.container():
|
1065 |
-
tab1, tab2, tab3 = st.tabs(['Overall Exposures', 'CPT Exposures', 'FLEX Exposures'])
|
1066 |
-
with tab1:
|
1067 |
-
st.dataframe(player_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(freq_format, precision=2), use_container_width = True)
|
1068 |
-
st.download_button(
|
1069 |
-
label="Export Exposures",
|
1070 |
-
data=convert_df_to_csv(player_freq),
|
1071 |
-
file_name='player_freq_export.csv',
|
1072 |
-
mime='text/csv',
|
1073 |
-
)
|
1074 |
-
with tab2:
|
1075 |
-
st.dataframe(cpt_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(freq_format, precision=2), use_container_width = True)
|
1076 |
-
st.download_button(
|
1077 |
-
label="Export Exposures",
|
1078 |
-
data=convert_df_to_csv(cpt_freq),
|
1079 |
-
file_name='cpt_freq_export.csv',
|
1080 |
-
mime='text/csv',
|
1081 |
-
)
|
1082 |
-
with tab3:
|
1083 |
-
st.dataframe(flex_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(freq_format, precision=2), use_container_width = True)
|
1084 |
-
st.download_button(
|
1085 |
-
label="Export Exposures",
|
1086 |
-
data=convert_df_to_csv(flex_freq),
|
1087 |
-
file_name='flex_freq_export.csv',
|
1088 |
-
mime='text/csv',
|
1089 |
-
)
|
1090 |
-
|
1091 |
-
st.download_button(
|
1092 |
-
label="Export Tables",
|
1093 |
-
data=convert_df_to_csv(Sim_Winner_Frame),
|
1094 |
-
file_name='NFL_consim_export.csv',
|
1095 |
-
mime='text/csv',
|
1096 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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_instances: 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSGO_Contest_Sims-main/requirements.txt
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
streamlit
|
2 |
-
gspread
|
3 |
-
openpyxl
|
4 |
-
matplotlib
|
5 |
-
streamlit-aggrid
|
6 |
-
pulp
|
7 |
-
docker
|
8 |
-
plotly
|
9 |
-
scipy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|