pydfs-lineup-optimizer
pydfs-lineup-optimizer copied to clipboard
optimizer.restrict_positions_for_same_team(('RB', 'RB'))
Getting ready for nfl season , and this might have been addressed. This code works, but it will allow a RB into the flex/util from same team. How do your restrict that?
example Nick Chubb at RB1, Kareem Hunt at FLEX/UTIL?
Hi, what optimizer are you using? If you do restrict_positions_for_same_team(('RB', 'RB')) it shouldn't allow to add RB as FLEX from same team. RB is the name of player position, not position slot in dfs site.
Not sure which version @DimaKudosh , how can i tell? I just did this sample run from Fanduel(used an csv from last season where i changed 2 rbs from the panthers(mccaffrey and m.davis) spit out 2 lineups
- QB Kyler Murray QB ARI ARI@CAR 28.38 8400.0$
- RB Nick Chubb RB CLE CLE@DAL 99.0 8300.0$
- RB Mike Davis RB CAR ARI@CAR 661.0 6300.0$
- WR Tyler Lockett WR SEA SEA@MIA 20.633 7500.0$
- WR Kenny Golladay WR DET NO@DET 14.7 7300.0$
- WR Andy Isabella WR ARI ARI@CAR 12.9 5000.0$
- TE Tyler Higbee TE LAR NYG@LAR 12.8 6000.0$
- FLEX Christian McCaffrey RB CAR ARI@CAR 199.0 6000.0$
- DEF Indianapolis Colts D IND IND@CHI 15.0 4900.0$
Fantasy Points 1063.41 Salary 59700.00
- QB Dak Prescott QB DAL CLE@DAL 28.973 8200.0$
- RB Nick Chubb RB CLE CLE@DAL 99.0 8300.0$
- RB Mike Davis RB CAR ARI@CAR 661.0 6300.0$
- WR Tyler Lockett WR SEA SEA@MIA 20.633 7500.0$
- WR Stefon Diggs WR BUF BUF@LV 16.933 7000.0$
- WR Cedrick Wilson WR DAL CLE@DAL 25.2 5000.0$
- TE Mark Andrews TE BAL BAL@WAS 9.133 7400.0$
- FLEX Christian McCaffrey RB CAR ARI@CAR 199.0 6000.0$
- DEF Arizona Cardinals D ARI ARI@CAR 99.0 3800.0$
May I ask how you came up with those fantasy points?
most of them are just their fppg on the season, although i changed chubb, mccaffrey, davis, and hunt just to test to see if it would put rbs from same team in lineup, it does unfortunately
Could you provide a full code sample?
@DimaKudosh from pydfs_lineup_optimizer import get_optimizer, Site, Sport, CSVLineupExporter, PositionsStack, PlayersGroup
class CustomExporter(CSVLineupExporter): @staticmethod def render_player(player): result = f'{player.id}:{player.full_name}' if player.lineup_position != 'UTIL': result += f' - {player.lineup_position}' return result
optimizer = get_optimizer(Site.FANDUEL, Sport.FOOTBALL) optimizer.settings.csv_exporter = CustomExporter # replace default exporter with custom optimizer.load_players_from_csv(r"C:\Users\brand\Desktop\PYTHON\NFL\fdnfl.csv")
kyler = optimizer.get_player_by_name("Kyler Murray") optimizer.add_player_to_lineup(kyler) kyler.max_exposure = 1 kyler.max_exposure = .10
#rodgers_adams_group = PlayersGroup([optimizer.get_player_by_name(name) for name in ('Aaron Rodgers', 'Davante Adams')], max_exposure=0.5) #optimizer.add_stack(PositionsStack(['QB', ('WR', 'TE')])) # stack QB and WR or TE from same team optimizer.add_stack(PositionsStack(['QB', 'TE'], for_teams=['LAR'])) # stack QB and TE for one of provided teams optimizer.add_stack(PositionsStack(['QB', 'WR'], for_teams=['DAL', 'ARI', 'BUF', 'GB'])) # stack QB and WR for one of provided teams optimizer.set_min_salary_cap(59500) optimizer.set_max_repeating_players(7) optimizer.restrict_positions_for_same_team(('QB', 'D'), ('RB', 'RB')) optimizer.force_positions_for_opposing_team(('QB', 'WR'), ('WR', 'WR')) lineups = optimizer.optimize(n=10) for lineup in lineups: print(lineup) optimizer.export(r"C:\Users\brand\Desktop\PYTHON\NFL\NFLFANDUEL.csv") import pandas as pd df = pd.read_csv(r"C:\Users\brand\Desktop\PYTHON\NFL\NFLFANDUEL.csv") optimizer.print_statistic()
I can't reproduce this bug. Are you using the latest version of library?
how do you i know @DimaKudosh . im a noob at this. Do i just re run the install pydfs line again at the top?
from pydfs_lineup_optimizer import __version__
print(__version__)
3.4.0
How do i run the 3.5 latest version? again im a noob and appreciate your help.
pip install pydfs-lineup-optimizer -U
awesome @DimaKudosh was able to update, now with the same above code the lineups dont come through, but this error.
GenerateLineupException: Can't generate lineups. Following constraints are not valid: max_from_one_team_MIN,max_from_one_team_DET,max_from_one_team_CAR,max_from_one_team_LV
You have the code wrong
On Thu, Jul 22, 2021, 6:27 PM lightninglarry @.***> wrote:
awesome @DimaKudosh https://github.com/DimaKudosh was able to update, now with the same above code the lineups dont come through, but this error.
GenerateLineupException: Can't generate lineups. Following constraints are not valid: max_from_one_team_MIN,max_from_one_team_DET,max_from_one_team_CAR,max_from_one_team_LV
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/279#issuecomment-885276193, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBWO7WG3CYUPTAYZNWROPDTZCLOTANCNFSM5AQHZARA .
You have the code wrong … On Thu, Jul 22, 2021, 6:27 PM lightninglarry @.***> wrote: awesome @DimaKudosh https://github.com/DimaKudosh was able to update, now with the same above code the lineups dont come through, but this error. GenerateLineupException: Can't generate lineups. Following constraints are not valid: max_from_one_team_MIN,max_from_one_team_DET,max_from_one_team_CAR,max_from_one_team_LV — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#279 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBWO7WG3CYUPTAYZNWROPDTZCLOTANCNFSM5AQHZARA .
can you help a brother out @Denwen12 .
can anyone pinpoint what is wrong with the above code? I comment some things out and it runs, but not all together.
Can you post your whole code
On Fri, Aug 6, 2021, 6:20 PM lightninglarry @.***> wrote:
can anyone pinpoint what is wrong with the above code? I comment some things out and it runs, but not all together.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/279#issuecomment-894546673, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBWO7RZBXLG2DU7NRSY4ATT3RN3TANCNFSM5AQHZARA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
@Denwen12 from pydfs_lineup_optimizer import get_optimizer, Site, Sport, CSVLineupExporter, PositionsStack, PlayersGroup
class CustomExporter(CSVLineupExporter): @staticmethod def render_player(player): result = f'{player.id}:{player.full_name}' if player.lineup_position != 'UTIL': result += f' - {player.lineup_position}' return result
optimizer = get_optimizer(Site.FANDUEL, Sport.FOOTBALL) optimizer.settings.csv_exporter = CustomExporter # replace default exporter with custom optimizer.load_players_from_csv(r"C:\Users\brand\Desktop\PYTHON\NFL\fdnfl.csv")
kyler = optimizer.get_player_by_name("Kyler Murray") optimizer.add_player_to_lineup(kyler) kyler.max_exposure = 1 kyler.max_exposure = .10
#rodgers_adams_group = PlayersGroup([optimizer.get_player_by_name(name) for name in ('Aaron Rodgers', 'Davante Adams')], max_exposure=0.5) #optimizer.add_stack(PositionsStack(['QB', ('WR', 'TE')])) # stack QB and WR or TE from same team optimizer.add_stack(PositionsStack(['QB', 'TE'], for_teams=['LAR'])) # stack QB and TE for one of provided teams optimizer.add_stack(PositionsStack(['QB', 'WR'], for_teams=['DAL', 'ARI', 'BUF', 'GB'])) # stack QB and WR for one of provided teams optimizer.set_min_salary_cap(59500) optimizer.set_max_repeating_players(7) optimizer.restrict_positions_for_same_team(('QB', 'D'), ('RB', 'RB')) optimizer.force_positions_for_opposing_team(('QB', 'WR'), ('WR', 'WR')) lineups = optimizer.optimize(n=10) for lineup in lineups: print(lineup) optimizer.export(r"C:\Users\brand\Desktop\PYTHON\NFL\NFLFANDUEL.csv")