Spaces:
Sleeping
Sleeping
File size: 30,811 Bytes
2f8e52c 09a3d56 28226be 09a3d56 e334040 09a3d56 de43947 09a3d56 9ce7dfc 09a3d56 9ce7dfc dc829eb 09a3d56 9ce7dfc 346309d 9ce7dfc 346309d ab3e05f 09a3d56 f72e929 e334040 9ce7dfc e334040 09a3d56 9ce7dfc 9837076 9ce7dfc 09a3d56 9ce7dfc e334040 09a3d56 9ce7dfc 1362d63 9837076 812883a 9837076 812883a 09a3d56 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc 09a3d56 e334040 9ce7dfc 09a3d56 e334040 9ce7dfc 09a3d56 9ce7dfc 9837076 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc 09a3d56 e334040 09a3d56 9ce7dfc 09a3d56 9ce7dfc 9837076 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc e334040 9ce7dfc 09a3d56 9ce7dfc e334040 9ce7dfc e334040 9ce7dfc 09a3d56 e334040 09a3d56 9ce7dfc 09a3d56 9ce7dfc e334040 9ce7dfc e334040 9ce7dfc 09a3d56 e334040 09a3d56 9ce7dfc e334040 09a3d56 9ce7dfc 9837076 9ce7dfc 09a3d56 9ce7dfc 09a3d56 9ce7dfc e334040 09a3d56 9ce7dfc 9837076 9ce7dfc 09a3d56 346309d ab3e05f 09a3d56 85eb84f 5752545 adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f 5752545 adb856d 85eb84f 5752545 adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f adb856d 85eb84f 346309d ab3e05f 28226be 9837076 28226be 9837076 28226be 47184c3 9837076 47184c3 28226be 47184c3 9837076 47184c3 28226be 47184c3 9837076 47184c3 28226be 47184c3 9837076 47184c3 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 9837076 28226be 47184c3 9837076 47184c3 28226be 346309d ab3e05f 346309d b4970a0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 |
import streamlit as st
import time
# Numpy
from numpy import nan as np_nan
from numpy import inf as np_inf
# Pandas
from pandas import DataFrame
from pandas import concat as pd_concat
from pandas import options as pd_options
from pandas import errors as pd_errors
from pandas import options as poptions
from pandas import set_option
# Time
import time
from time import sleep as time_sleep
from datetime import datetime, date
from pytz import timezone as pytz_timezone
from database import *
pd_options.mode.chained_assignment = None # default='warn'
from warnings import simplefilter
simplefilter(action="ignore", category=pd_errors.PerformanceWarning)
poptions.mode.chained_assignment = None # default='warn'
set_option('future.no_silent_downcasting', True)
st.markdown("""
<style>
/* Tab styling */
.stElementContainer [data-baseweb="button-group"] {
gap: 2.000rem;
padding: 4px;
}
.stElementContainer [kind="segmented_control"] {
height: 2.000rem;
white-space: pre-wrap;
background-color: #DAA520;
color: white;
border-radius: 20px;
gap: 1px;
padding: 10px 20px;
font-weight: bold;
transition: all 0.3s ease;
}
.stElementContainer [kind="segmented_controlActive"] {
height: 3.000rem;
background-color: #DAA520;
border: 3px solid #FFD700;
border-radius: 10px;
color: black;
}
.stElementContainer [kind="segmented_control"]:hover {
background-color: #FFD700;
cursor: pointer;
}
div[data-baseweb="select"] > div {
background-color: #DAA520;
color: white;
}
</style>""", unsafe_allow_html=True)
# Streamlit UI Configuration
st.set_page_config(
page_title="Paydirt Model Updates",
page_icon="π",
layout="wide"
)
st.title("π Paydirt Model Updates")
st.markdown("### Update models and generate seed frames")
st.markdown("---")
# Sport Selection
sport_icons = {
"NHL": "π",
"NFL": "π",
"NBA": "π",
"MLB": "βΎ"
}
selected_tab = st.segmented_control(
"Select Tab",
options=["NHL Updates", "NBA Updates", 'MLB Updates', 'NFL Updates'],
selection_mode='single',
default='NHL Updates',
width='stretch',
label_visibility='collapsed',
key='tab_selector'
)
# Main content area
if selected_tab == "NHL Updates":
from sports.nhl_functions import *
if st.button(f"π Update NHL models and generate seed frames", type="primary", use_container_width=True):
st.write("Starting prop betting table generation...")
build_prop_betting_table(nhl_db)
try:
st.write("NHL Prop Betting Table refreshed")
except:
pass
st.write("Starting DraftKings player level basic outcomes generation...")
roo_file, own_dicts = build_dk_player_level_basic_outcomes(slate_info, dk_player_hold, fd_player_hold, nhl_db)
try:
if roo_file is not None and len(roo_file) > 0:
st.write("NHL Draftkings Player Level ROO refreshed")
st.table(roo_file.head(10))
else:
st.write("NHL Draftkings Player Level ROO generation failed")
st.stop()
except Exception as e:
st.write(f"Error: {e}")
st.write("Starting DraftKings stack matrix basic outcomes generation...")
dk_stacks_outcomes = build_dk_stack_matrix_basic_outcomes(slate_info, dk_stacks_hold, own_dicts)
st.write("Starting Fanduel stack matrix basic outcomes generation...")
fd_stacks_outcomes = build_fd_stack_matrix_basic_outcomes(slate_info, fd_stacks_hold)
st.write("Starting DraftKings pp stack matrix basic outcomes generation...")
dk_pp_outcomes = build_dk_pp_stack_matrix_basic_outcomes(slate_info, dk_pp_stacks_hold, own_dicts)
st.write("Starting Fanduel pp stack matrix basic outcomes generation...")
fd_pp_outcomes = build_fd_pp_stack_matrix_basic_outcomes(slate_info, fd_pp_stacks_hold)
final_stacks_Proj = pd_concat([dk_stacks_outcomes, fd_stacks_outcomes])
final_stacks_Proj.replace([np_nan, np_inf, -np_inf], 0, inplace=True)
sh = gc.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('Player_Lines_ROO')
worksheet.batch_clear(['A:Z'])
worksheet.update([final_stacks_Proj.columns.values.tolist()] + final_stacks_Proj.values.tolist())
collection = nhl_db['Player_Lines_ROO']
final_stacks_Proj.reset_index(inplace=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(final_stacks_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = final_stacks_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
st.write(f"Retry due to error: {e}")
time_sleep(1)
try:
st.write("NHL Stack Matrix refreshed")
except:
pass
final_pp_Proj = pd_concat([dk_pp_outcomes, fd_pp_outcomes])
final_pp_Proj.replace([np_nan, np_inf, -np_inf], 0, inplace=True)
worksheet = sh.worksheet('Player_PowerPlay_ROO')
worksheet.batch_clear(['A:Z'])
worksheet.update([final_pp_Proj.columns.values.tolist()] + final_pp_Proj.values.tolist())
collection = nhl_db['Player_Powerplay_ROO']
final_pp_Proj.reset_index(inplace=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(final_pp_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = final_pp_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
st.write(f"Retry due to error: {e}")
time_sleep(1)
try:
st.write("NHL Powerplay Stack Matrix refreshed")
except:
pass
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
sh = gc.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('Timestamp')
worksheet.batch_clear(['A:z'])
worksheet.update_cell(1, 1, current_time)
try:
sh = gc.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('prop_trends')
trends_assist = DataFrame(worksheet.get_all_records())
trends_assist['Projection'] = trends_assist['Projection'].replace('', np_nan)
prop_trends_final = trends_assist.dropna(subset=['Projection'])
except:
sh = gc2.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('prop_trends')
trends_assist = DataFrame(worksheet.get_all_records())
trends_assist['Projection'] = trends_assist['Projection'].replace('', np_nan)
prop_trends_final = trends_assist.dropna(subset=['Projection'])
collection = nhl_db['prop_trends']
prop_trends_final.reset_index(inplace=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(prop_trends_final), chunk_size):
for _ in range(5):
try:
df_chunk = prop_trends_final.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
st.write(f"Retry due to error: {e}")
time_sleep(1)
worksheet = sh.worksheet('prop_trends_check')
worksheet.batch_clear(['A:Z'])
worksheet.update([prop_trends_final.columns.values.tolist()] + prop_trends_final.values.tolist())
try:
sh = gc.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('Pick6_ingest')
Overall_Proj = DataFrame(worksheet.get_all_records())
except:
sh = gc2.open_by_url(NHL_Master_hold)
worksheet = sh.worksheet('Pick6_ingest')
Overall_Proj = DataFrame(worksheet.get_all_records())
collection = nhl_db['Pick6_ingest']
Overall_Proj.reset_index(inplace=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(Overall_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = Overall_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
st.write(f"Retry due to error: {e}")
time_sleep(1)
st.write("Starting DraftKings NHL seed frame generation...")
DK_NHL_seed_frame(nhl_db, roo_file)
try:
st.write("NHL Draftkings Seed Frames refreshed")
except:
pass
time.sleep(1)
st.write("Starting Fanduel NHL seed frame generation...")
FD_NHL_seed_frame(nhl_db, roo_file)
try:
st.write("NHL Fanduel Seed Frames refreshed")
except:
pass
st.success("β
NHL updates completed successfully!")
st.balloons()
if selected_tab == "NFL Updates":
from sports.nfl_functions import *
if st.button(f"οΏ½ Update NFL models and generate seed frames", type="primary", use_container_width=True):
x: int = 1
high_end: int = 1
while x <= high_end:
Prop_Data_Creation_var = 0
DK_Team_Level_Stacks_var = 0
FD_Team_Level_Stacks_var = 0
DK_ROO_Structure_Creation_var = 0
FD_ROO_Structure_Creation_var = 0
DK_seed_frame_var = 0
FD_seed_frame_var = 0
upload_betting_var = 0
DK_SD_ROO_var = 0
FD_SD_ROO_var = 0
DK_SD_seed_frame_var = 0
FD_SD_seed_frame_var = 0
if upload_betting_var == 0:
upload_betting_data(client)
upload_betting_var = 1
time_sleep(1)
if DK_Team_Level_Stacks_var == 0:
Overall_Proj = DK_Team_Level_Stacks(dk_stacks_hold, dk_raw)
DK_Team_Level_Stacks_var = 1
if DK_Team_Level_Stacks_var == 1:
collection = nfl_db['DK_DFS_Stacks']
Overall_Proj = Overall_Proj.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(Overall_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = Overall_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Draftkings Team Level Stacks refreshed")
time_sleep(1)
if FD_Team_Level_Stacks_var == 0:
Overall_Proj = FD_Team_Level_Stacks(fd_stacks_hold, fd_raw)
FD_Team_Level_Stacks_var = 1
if FD_Team_Level_Stacks_var == 1:
collection = nfl_db['FD_DFS_Stacks']
Overall_Proj = Overall_Proj.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(Overall_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = Overall_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Fanduel Team Level Stacks refreshed")
time_sleep(1)
if DK_ROO_Structure_Creation_var == 0:
DK_ROO = DK_ROO_Structure_Creation(dk_player_hold, short_team_acro, long_team_acro, team_only_acro)
DK_ROO_Structure_Creation_var = 1
if DK_ROO_Structure_Creation_var == 1:
collection = nfl_db['DK_NFL_ROO']
DK_ROO = DK_ROO.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(DK_ROO), chunk_size):
for _ in range(5):
try:
df_chunk = DK_ROO.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Draftkings ROO structure refreshed")
time_sleep(1)
if FD_ROO_Structure_Creation_var == 0:
FD_ROO = FD_ROO_Structure_Creation(fd_player_hold, short_team_acro, long_team_acro, team_only_acro)
FD_ROO_Structure_Creation_var = 1
if FD_ROO_Structure_Creation_var == 1:
collection = nfl_db['FD_NFL_ROO']
FD_ROO = FD_ROO.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(FD_ROO), chunk_size):
for _ in range(5):
try:
df_chunk = FD_ROO.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Fanduel ROO structure refreshed")
time_sleep(1)
if DK_seed_frame_var == 0:
DK_seed_frame(DK_ROO, seed_team_acro, short_team_acro, client)
DK_seed_frame_var = 1
st.write("NFL Draftkings Seed Frames refreshed")
time_sleep(1)
if FD_seed_frame_var == 0:
FD_seed_frame(FD_ROO, seed_team_acro, short_team_acro, client)
FD_seed_frame_var = 1
st.write("NFL Fanduel Seed Frames refreshed")
time_sleep(1)
if Prop_Data_Creation_var == 0:
Overall_Proj = Prop_Data_Creation()
Prop_Data_Creation_var = 1
if Prop_Data_Creation_var == 1:
collection = nfl_db['Player_Baselines']
Overall_Proj = Overall_Proj.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(Overall_Proj), chunk_size):
for _ in range(5):
try:
df_chunk = Overall_Proj.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Player Baselines refreshed")
time_sleep(1)
if DK_SD_ROO_var == 0:
dk_sd_roo_result = DK_SD_ROO(dk_showdown_hold, team_only_acro, short_team_acro, long_team_acro, dk_sd_projections)
DK_SD_ROO_var = 1
if DK_SD_ROO_var == 1:
collection = nfl_db['DK_SD_NFL_ROO']
dk_sd_roo_result = dk_sd_roo_result.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(dk_sd_roo_result), chunk_size):
for _ in range(5):
try:
df_chunk = dk_sd_roo_result.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Draftkings SD ROO structure refreshed")
time_sleep(1)
if FD_SD_ROO_var == 0:
fd_sd_roo_result = FD_SD_ROO(fd_showdown_hold, team_only_acro, short_team_acro, long_team_acro, fd_sd_projections)
FD_SD_ROO_var = 1
if FD_SD_ROO_var == 1:
collection = nfl_db['FD_SD_NFL_ROO']
fd_sd_roo_result = fd_sd_roo_result.reset_index(drop=True)
chunk_size = 100000
collection.drop()
for i in range(0, len(fd_sd_roo_result), chunk_size):
for _ in range(5):
try:
df_chunk = fd_sd_roo_result.iloc[i:i + chunk_size]
collection.insert_many(df_chunk.to_dict('records'), ordered=False)
break
except Exception as e:
print(f"Retry due to error: {e}")
time_sleep(1)
else:
pass
st.write("NFL Fanduel SD ROO structure refreshed")
time_sleep(1)
if DK_SD_seed_frame_var == 0:
DK_SD_seed_frame(dk_sd_roo_result, team_only_acro, long_team_acro, client, dk_showdown_options, dk_sd_projections)
DK_SD_seed_frame_var = 1
st.write("NFL Draftkings SD Seed Frames refreshed")
time_sleep(1)
if FD_SD_seed_frame_var == 0:
FD_SD_seed_frame(fd_sd_roo_result, team_only_acro, long_team_acro, client, fd_showdown_options, fd_sd_projections)
FD_SD_seed_frame_var = 1
st.write("NFL Fanduel SD Seed Frames refreshed")
time_sleep(1)
print (f'currently on run {x}, {high_end - x} runs remaining')
x += 1
if high_end > 1:
time_sleep(600)
st.success("β
NFL updates completed successfully!")
st.balloons()
if selected_tab == "NBA Updates":
from sports.nba_functions import *
if st.button(f"π Update NBA models and generate seed frames", type="primary", use_container_width=True):
x: int = 1
high_end: int = 1
while x <= high_end:
try:
try:
sh = gc.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Game_Adj')
except:
sh = gc2.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Game_Adj')
t_range = worksheet.range('T2:T32')
# Create a list of zeros with the same length as t_range
values = [0] * len(t_range)
worksheet.update('T2:T32', [[0] for _ in range(len(t_range))])
# Sleep for 2 seconds
time.sleep(2)
# Get values from Z2:Z32
z_values = worksheet.range('Z2:Z32')
z_data = [cell.value for cell in z_values]
worksheet.update([[val] for val in z_data], 'T2:T32')
except:
pass
ROO_creation_var = 0
SD_ROO_creation_var = 0
DK_SD_seed_frame_var = 0
FD_SD_seed_frame_var = 0
DK_seed_frame_var = 0
FD_seed_frame_var = 0
upload_mongo_dfs_var = 0
upload_mongo_bets_var = 0
if ROO_creation_var == 0:
try:
DK_ROO = DK_NBA_ROO_Build(dk_roo_player_hold)
FD_ROO = FD_NBA_ROO_Build(fd_roo_player_hold)
solver_DK = DK_ROO.copy()
solver_FD = FD_ROO.copy()
solver_DK = solver_DK.drop_duplicates(subset=['Player'])
solver_DK['Player'] = solver_DK['Player'].replace('Ron Holland', 'Ronald Holland II')
solver_FD = solver_FD.drop_duplicates(subset=['Player'])
solver_FD['Player'] = solver_FD['Player'].replace('Ron Holland', 'Ronald Holland II')
try:
solver_DK['Timestamp'] = str(date.today())
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1H7kdaxVF7Bv3kb1DSa_3Dq6OaC9ajq9UAQfVyDluXzk/edit?gid=0#gid=0')
worksheet = sh.worksheet('NBA DK')
worksheet.batch_clear(['A:AB'])
worksheet.update([solver_DK.columns.values.tolist()] + solver_DK.values.tolist())
except:
sh = gc2.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('NBA DK')
worksheet.batch_clear(['A:AB'])
worksheet.update([solver_DK.columns.values.tolist()] + solver_DK.values.tolist())
try:
solver_FD['Timestamp'] = str(date.today())
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1H7kdaxVF7Bv3kb1DSa_3Dq6OaC9ajq9UAQfVyDluXzk/edit?gid=0#gid=0')
worksheet = sh.worksheet('NBA FD')
worksheet.batch_clear(['A:AB'])
worksheet.update([solver_FD.columns.values.tolist()] + solver_FD.values.tolist())
except:
sh = gc2.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('NBA FD')
worksheet.batch_clear(['A:AB'])
worksheet.update([solver_FD.columns.values.tolist()] + solver_FD.values.tolist())
time.sleep(3)
roo_final = pd_concat([DK_ROO, FD_ROO])
roo_final['Salary'] = roo_final['Salary'].astype(int)
tz = pytz_timezone('US/Central')
central_tz = datetime.now(tz)
current_time = central_tz.strftime("%H:%M:%S")
roo_final['timestamp'] = current_time
try:
sh = gc.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Player_Level_ROO')
worksheet.batch_clear(['A:AB'])
worksheet.update([roo_final.columns.values.tolist()] + roo_final.values.tolist())
except:
sh = gc2.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Player_Level_ROO')
worksheet.batch_clear(['A:AB'])
worksheet.update([roo_final.columns.values.tolist()] + roo_final.values.tolist())
ROO_creation_var = 1
except:
pass
if ROO_creation_var == 1:
try:
st.write("NBA ROO structure refreshed")
except:
pass
else:
try:
st.write("NBA ROO structure script broke")
except:
pass
time_sleep(1)
upload_dfs_data(client, roo_final)
try:
st.write("NBA DFS database refreshed")
except:
pass
upload_betting_data(client)
try:
st.write("NBA betting database refreshed")
except:
pass
try:
trending_script()
try:
st.write("NBA Trending Tables refreshed")
except:
pass
except:
try:
st.write("NBA Trending Tables broke")
except:
pass
if DK_seed_frame_var == 0:
DK_NBA_seed_frame(roo_final, client)
DK_seed_frame_var = 1
if DK_seed_frame_var == 1:
try:
st.write("NBA Draftkings Seed Frames refreshed")
except:
pass
else:
try:
st.write("NBA Draftkings Seed Frames script broke")
except:
pass
time_sleep(1)
if FD_seed_frame_var == 0:
FD_NBA_seed_frame(roo_final, client)
FD_seed_frame_var = 1
if FD_seed_frame_var == 1:
try:
st.write("NBA Fanduel Seed Frames refreshed")
except:
pass
else:
try:
st.write("NBA Fanduel Seed Frames script broke")
except:
pass
time_sleep(1)
if SD_ROO_creation_var == 0:
DK_SD_ROO = DK_SD_NBA_ROO_Build(dk_sd_player_hold, dk_showdown_options, dk_sd_projections)
FD_SD_ROO = FD_SD_NBA_ROO_Build(fd_sd_player_hold, fd_showdown_options, fd_sd_projections)
sd_roo_final = pd_concat([DK_SD_ROO, FD_SD_ROO])
sd_roo_final['Salary'] = sd_roo_final['Salary'].astype(int)
tz = pytz_timezone('US/Central')
central_tz = datetime.now(tz)
current_time = central_tz.strftime("%H:%M:%S")
sd_roo_final['timestamp'] = current_time
try:
sh = gc.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Player_Level_SD_ROO')
worksheet.batch_clear(['A:AB'])
worksheet.update([sd_roo_final.columns.values.tolist()] + sd_roo_final.values.tolist())
except:
sh = gc2.open_by_url(NBA_Master_hold)
worksheet = sh.worksheet('Player_Level_SD_ROO')
worksheet.batch_clear(['A:AB'])
worksheet.update([sd_roo_final.columns.values.tolist()] + sd_roo_final.values.tolist())
ROO_creation_var = 1
if ROO_creation_var == 1:
try:
st.write("NBA SD ROO structure refreshed")
except:
pass
else:
try:
st.write("NBA SD ROO structure script broke")
except:
pass
time_sleep(1)
if DK_SD_seed_frame_var == 0:
DK_NBA_SD_seed_frame(dk_showdown_options, dk_sd_projections)
DK_SD_seed_frame_var = 1
if DK_SD_seed_frame_var == 1:
try:
st.write("NBA Draftkings SD Seed Frames refreshed")
except:
pass
else:
try:
st.write("NBA Draftkings SD Seed Frames script broke")
except:
pass
time_sleep(1)
if FD_SD_seed_frame_var == 0:
FD_NBA_SD_seed_frame(fd_showdown_options, fd_sd_projections)
FD_SD_seed_frame_var = 1
if FD_SD_seed_frame_var == 1:
try:
st.write("NBA Fanduel SD Seed Frames refreshed")
except:
pass
else:
try:
st.write("NBA Fanduel SD Seed Frames script broke")
except:
pass
time_sleep(1)
upload_sd_dfs_data(client, sd_roo_final)
try:
st.write("NBA SD DFS database refreshed")
except:
pass
print (f'currently on run {x}, {high_end - x} runs remaining')
x += 1
if high_end > 1:
time_sleep(600)
st.success("β
NBA updates completed successfully!")
st.balloons()
if selected_tab == "MLB Updates":
from sports.mlb_functions import *
st.info("MLB updates coming soon!")
st.write("MLB functionality will be added later on.") |