def hist_FD_contest_salaries(): todays_date=time.strftime("%Y-%m-%d") table='hist_fanduel_data' recordset=dbo.get_table_last_row(table,'Date') if str(recordset[0][1])==todays_date: print "hist_fd_contest_salares: salaries already historized in %s for today " % table time.sleep(5) return s,session_id=fdo.get_fanduel_session() contest_dict=fdo.get_FD_contests(s) sports_list=['mlb','nba','nhl','nfl'] #pick this option if you wanna historize all sports #sports_list=['mlb','nba'] for sport in sports_list: print sport sport_contest_dict=(x for x in contest_dict if x['sport']==sport) test_dict_case=(x for x in contest_dict if x['sport']==sport) #assign duplicate var to avoid list mutation if len(list(test_dict_case))>0: #test if there are contests for the sport historized_contests=[] ContestID='' rw=1 for contest in sport_contest_dict: #loop through each for given sport Url='https://www.fanduel.com/e/Game'+contest['entryURL'][contest['entryURL'].find('Game\\')+5:] # print contest['startString'] if contest['gameId'] not in historized_contests and len(contest['startString'])<14 and contest['entryURL'].find('accept_public_challenge')==-1: #check for contests at other times print 'now historizing %s contest#: %d' % (sport,contest['gameId']) hist_FD_playerdata(sport.upper(),Url,contest['gameId']) print '%s contest#: %d historized succesfully' % (sport,contest['gameId']) historized_contests.append(contest['gameId']) fdo.end_fanduel_session(s) return
def hist_web_lineups(): table = 'hist_lineup_optimizers' recordset = dbo.get_table_last_row(table, 'Date') todays_date = time.strftime("%Y-%m-%d") if str(recordset[0][0]) == todays_date: print "hist_web_lineups: a recordset already exists in table: %s for entered date" % table time.sleep(5) return if TeamOdds.get_team_odds('MLB')[1].split()[1] != todays_date.split( '-')[2]: #Refactor print "MLB team odds are not for today" time.sleep(5) mlb_odds = '' else: mlb_odds = json.dumps(TeamOdds.get_team_odds('MLB')[0]) # if TeamOdds.get_team_odds('NHL')[1].split()[1]!=todays_date.split('-')[2]: # print "NHL team odds are not for today" # time.sleep(5) # nhl_odds='' # else: # nhl_odds=json.dumps(TeamOdds.get_team_odds('NHL')[0]) nhl_odds = '' nba_odds = '' # if TeamOdds.get_team_odds('NBA')[1].split()[1]!=todays_date.split('-')[2]: # print "NBA team odds are not for today" # time.sleep(5) # nba_odds='' # else: # nba_odds=json.dumps(TeamOdds.get_team_odds('NBA')[0]) dfn_nba = Cell('Backtest_Parameters', 'clDFNNBA').value dfn_mlb = Cell('Backtest_Parameters', 'clDFNMLB').value rw_nba = Cell('Backtest_Parameters', 'clRWNBA').value rw_mlb = Cell('Backtest_Parameters', 'clRWMLB').value rw_nhl = Cell('Backtest_Parameters', 'clRWNHL').value rn_nba = Cell('Backtest_Parameters', 'clRNNBA').value rn_nhl = Cell('Backtest_Parameters', 'clRNNHL').value rn_mlb = Cell('Backtest_Parameters', 'clRNMLB').value db_data = [ todays_date, dfn_nba, dfn_mlb, rw_nba, rw_mlb, rw_nhl, mlb_odds, rn_nba, rn_nhl, rn_mlb, nba_odds, nhl_odds ] columns = 'Date,DFN_NBA,DFN_MLB,RW_NBA,RW_MLB,RW_NHL,MLB_ODDS,RN_NBA,RN_NHL,RN_MLB,NBA_ODDS,NHL_ODDS' placeholders = ', '.join(['%s'] * len(db_data)) print 'now historizing' dbo.insert_mysql(table, columns, db_data, placeholders) print 'web_lineups historized succesfully' return
def hist_web_lineups(): table='hist_lineup_optimizers' recordset=dbo.get_table_last_row(table,'Date') todays_date=time.strftime("%Y-%m-%d") if str(recordset[0][0])==todays_date: print "hist_web_lineups: a recordset already exists in table: %s for entered date" % table time.sleep(5) return if TeamOdds.get_team_odds('MLB')[1].split()[1]!=todays_date.split('-')[2]: #Refactor print "MLB team odds are not for today" time.sleep(5) mlb_odds='' else: mlb_odds=json.dumps(TeamOdds.get_team_odds('MLB')[0]) # if TeamOdds.get_team_odds('NHL')[1].split()[1]!=todays_date.split('-')[2]: # print "NHL team odds are not for today" # time.sleep(5) # nhl_odds='' # else: # nhl_odds=json.dumps(TeamOdds.get_team_odds('NHL')[0]) nhl_odds='' nba_odds='' # if TeamOdds.get_team_odds('NBA')[1].split()[1]!=todays_date.split('-')[2]: # print "NBA team odds are not for today" # time.sleep(5) # nba_odds='' # else: # nba_odds=json.dumps(TeamOdds.get_team_odds('NBA')[0]) dfn_nba=Cell('Backtest_Parameters','clDFNNBA').value dfn_mlb=Cell('Backtest_Parameters','clDFNMLB').value rw_nba=Cell('Backtest_Parameters','clRWNBA').value rw_mlb=Cell('Backtest_Parameters','clRWMLB').value rw_nhl=Cell('Backtest_Parameters','clRWNHL').value rn_nba=Cell('Backtest_Parameters','clRNNBA').value rn_nhl=Cell('Backtest_Parameters','clRNNHL').value rn_mlb=Cell('Backtest_Parameters','clRNMLB').value db_data=[todays_date,dfn_nba,dfn_mlb,rw_nba,rw_mlb,rw_nhl,mlb_odds,rn_nba,rn_nhl,rn_mlb,nba_odds,nhl_odds] columns='Date,DFN_NBA,DFN_MLB,RW_NBA,RW_MLB,RW_NHL,MLB_ODDS,RN_NBA,RN_NHL,RN_MLB,NBA_ODDS,NHL_ODDS' placeholders = ', '.join(['%s'] * len(db_data)) print 'now historizing' dbo.insert_mysql(table,columns,db_data,placeholders) print 'web_lineups historized succesfully' return
def hist_FD_contest_salaries(): todays_date = time.strftime("%Y-%m-%d") table = 'hist_fanduel_data' recordset = dbo.get_table_last_row(table, 'Date') if str(recordset[0][1]) == todays_date: print "hist_fd_contest_salares: salaries already historized in %s for today " % table time.sleep(5) return s, session_id = fdo.get_fanduel_session() contest_dict = fdo.get_FD_contests(s) sports_list = ['mlb', 'nba', 'nhl', 'nfl'] #pick this option if you wanna historize all sports #sports_list=['mlb','nba'] for sport in sports_list: print sport sport_contest_dict = (x for x in contest_dict if x['sport'] == sport) test_dict_case = (x for x in contest_dict if x['sport'] == sport ) #assign duplicate var to avoid list mutation if len(list(test_dict_case) ) > 0: #test if there are contests for the sport historized_contests = [] ContestID = '' rw = 1 for contest in sport_contest_dict: #loop through each for given sport Url = 'https://www.fanduel.com/e/Game' + contest['entryURL'][ contest['entryURL'].find('Game\\') + 5:] # print contest['startString'] if contest['gameId'] not in historized_contests and len( contest['startString'] ) < 14 and contest['entryURL'].find( 'accept_public_challenge' ) == -1: #check for contests at other times print 'now historizing %s contest#: %d' % ( sport, contest['gameId']) hist_FD_playerdata(sport.upper(), Url, contest['gameId']) print '%s contest#: %d historized succesfully' % ( sport, contest['gameId']) historized_contests.append(contest['gameId']) fdo.end_fanduel_session(s) return