Пример #1
0
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
Пример #2
0
def get_live_contest_ids():
    s, session_id = fdo.get_fanduel_session()
    r = s.get(
        'https://www.fanduel.com/mycontests/162491/live?start=0&number=10000')
    live_contest_dict = json.loads(r.text)
    for contest in live_contest_dict['seats']:
        dbo.write_to_db('FD_table_contests', 'table_id,contest_id',
                        [str(contest[2].split(r'/')[2]),
                         str(contest[0])])
Пример #3
0
def run_enter_best_contests(daily_bet,bin_size):
	s, session_id = fdo.get_fanduel_session()
	total_bet = 0
	time_remaining = Ugen.get_time_remain('17:00')
	wins_data = build_pWins_vs_topwins_dict(bin_size)
	while total_bet < daily_bet and time_remaining > 0:
		tmp_total_bet = total_bet
		potential_contests = data_scrapping.get_potential_contests(s,['nhl'],[{"standard":1}],[3,5],[1,2,5,10,25],0.6,'7:00')
		print potential_contests
		total_bet = total_bet + data_scrapping.enter_best_contests(s,session_id,'NHL',(daily_bet - total_bet),potential_contests,time_remaining,wins_data,bin_size)
		time.sleep(60)
		time_remaining = Ugen.get_time_remain('17:00')
	fdo.end_fanduel_session(s)
	return total_bet
Пример #4
0
def run_enter_best_contests(daily_bet, bin_size):
    s, session_id = fdo.get_fanduel_session()
    total_bet = 0
    time_remaining = Ugen.get_time_remain('17:00')
    wins_data = build_pWins_vs_topwins_dict(bin_size)
    while total_bet < daily_bet and time_remaining > 0:
        tmp_total_bet = total_bet
        potential_contests = data_scrapping.get_potential_contests(
            s, ['nhl'], [{
                "standard": 1
            }], [3, 5], [1, 2, 5, 10, 25], 0.6, '7:00')
        print potential_contests
        total_bet = total_bet + data_scrapping.enter_best_contests(
            s, session_id, 'NHL', (daily_bet - total_bet), potential_contests,
            time_remaining, wins_data, bin_size)
        time.sleep(60)
        time_remaining = Ugen.get_time_remain('17:00')
    fdo.end_fanduel_session(s)
    return total_bet
Пример #5
0
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
Пример #6
0
def get_live_contest_ids():
	s, session_id = fdo.get_fanduel_session()
	r = s.get('https://www.fanduel.com/mycontests/162491/live?start=0&number=10000')
	live_contest_dict = json.loads(r.text)
	for contest in live_contest_dict['seats']:
		dbo.write_to_db('FD_table_contests','table_id,contest_id',[str(contest[2].split(r'/')[2]),str(contest[0])])