示例#1
0
def hist_FD_contest_salaries():
    todays_date = dt.datetime.strptime(time.strftime("%Y-%m-%d"), "%Y-%m-%d")
    pp = pprint.PrettyPrinter(indent=4)
    FDSession = fdo.FDSession()
    sport_list = ['NBA', 'NHL', 'NFL', 'MLB']
    for sport in sport_list:
        daily_contests = FDSession.get_daily_contests(sport)
        for contest_ID, contest_url in daily_contests.iteritems():
            player_dict = {
                player['first_name'] + ' ' + player['last_name']: {
                    'fppg': player['fppg'],
                    'salary': player['salary'],
                    'position': player['position'],
                    'games_played': player['played'],
                    'injury_status': player['injury_status']
                }
                for player in FDSession.fanduel_api_data(contest_url)
                ['players']
            }
            print 'now historizing %s contest: %s' % (sport, contest_ID)
            dbo.write_to_db(
                'hist_fanduel_data', {
                    'sport': sport,
                    'date': todays_date,
                    'contest_ID': contest_ID,
                    'contest_dict': player_dict
                }, False)
            print 'contest: %s historized successfully' % sport
    return
示例#2
0
def run_program(sport_list, update_model_interval, max_bet):
    FDSession = fdo.FDSession()
    current_bet = 0
    #last contest_time = get_last_contest_time() - return last time for latest contest tonight
    run_time = 1000
    while current_bet <= max_bet:
        if run_time > update_model_interval:
            contest_rosters = build_contest_rosters(FDSession, sport_list)
            run_time = 10
        else:
            for contest_id, roster in contest_rosters.iteritems():
                contest_list = FDSession.fanduel_api_data(
                    "https://api.fanduel.com/contests?fixture_list=" +
                    contest_id)['contests']
                for contest in contest_list:
                    enter, entered_contest = contest_entry_decider(
                        FDSession, contest, roster)
                    if enter == True:
                        entered_contest['model_confidence'] = roster[
                            'confidence']
                        entered_contest['slate_player_count'] = roster[
                            'slate_player_count']
                        entered_contest['timestamp'] = str(datetime.now())
                        entered_contest['sport'] = roster['class'].sport
                        print 'entering contest'
                        os.system('pause')
                        if FDSession.enter_contest(contest['entries']['_url'],
                                                   roster['roster'],
                                                   entered_contest) == True:
                            current_bet = current_bet + contest['entry_fee']
                            print 'current bet=' + str(current_bet)
        print 'loop'
        os.system('pause')
示例#3
0
def todays_lineups(sport_list):
    FDSession = fdo.FDSession()
    contest_rosters = main.build_contest_rosters(FDSession, sport_list)
    #write to csv!
    return