pydfs-lineup-optimizer icon indicating copy to clipboard operation
pydfs-lineup-optimizer copied to clipboard

max players from one team

Open jeffreyyourman opened this issue 3 years ago • 9 comments

jeffreyyourman avatar Oct 25 '21 00:10 jeffreyyourman

Hi there! First off, thank you so much for this optimizer, it's amazing to have and not have to build it yourself!

I'm building out nba lineups and i want to be able to say "ok i want no more than 2 players per team or 3 players per team. When i use the line

optimizer.max_from_one_team(3) it throws me an error that says and in the image below

TypeError: 'int' object is not callable image

Is there something that i'm doing wrong? I also tried using optimizer.set_players_from_one_team({'LAL': 3}) and from my understanding this is to have at least 3 players from the lakers. Not a max set?

Thanks again!

jeffreyyourman avatar Oct 25 '21 00:10 jeffreyyourman

Did you try the line 13 instead? This one seems to work for me. optimizer.set_players_from_one_team({'CLE': 3}) # max 3 Cavs per lineup

This line should force 3 players from one team... optimizer.add_stack(TeamStack(3, for_teams=['LAL']))

Uncle6Pack avatar Oct 25 '21 14:10 Uncle6Pack

hey @Uncle6Pack yeah i did. So what that line does is forces 3 players from that team into your lineup. So it always has 3 players from that team.

What i want is i want a max of lets say 3. So depending on the lineup optimzier it will either choose 1,2,3 players from that team and put it in the lineup but never more than 3.

I feel like this shoudl be more of a rule than a stack? I'm not entirely sure but i just want the ability to say i only want up to 3 players form that team. Not exactly 3 but any number up to 3

for game in optimizer.player_pool.games: optimizer.add_players_group( PlayersGroup( optimizer.player_pool.get_players(PlayerFilter(teams=[game.home_team, game.away_team])), max_from_group=4, ) )

I've tried this as well but it wasn't working for me. It still adds more than 4 players to a lineup when i believe it should end at 4.

jeffreyyourman avatar Oct 25 '21 18:10 jeffreyyourman

following as i brought this question up in #251

lightninglarry avatar Oct 26 '21 13:10 lightninglarry

@lightninglarry did the solution proposed in the other thread work?

jeffreyyourman avatar Oct 28 '21 14:10 jeffreyyourman

im 100 percent it probably does @jeffreyyourman but im a python novice so i dont even know how to implement it. Check the thread out and maybe you can figure out the issue. @sansbacon is pretty sharp from what he posts so im 100 percent sure it works, i just not sure how to do it. LMK as i would like to use this for NBA GPPs

lightninglarry avatar Oct 28 '21 16:10 lightninglarry

ive tried this @jeffreyyourman and i think im on the right track fanduel uses 9 roster slots so this code works to guarantee max 2 per team. Adjust per site slots. lineup_slots = 9 optimizer.set_total_teams(lineup_slots - 1)

lightninglarry avatar Nov 01 '21 18:11 lightninglarry

@jeffreyyourman ive found the best way to do this inside settings.py inside whatever site you are playing(FD or DK). Insert this line inside your bball block

about 10 or so lines of code down @SitesRegistry.register_settings class FanDuelBasketballSettings(FanDuelSettings): max_from_one_team = 2(whatever number you desire, i use 2). smaller slates ill adjust this to 3 or 4 if really small slate. sport = Sport.BASKETBALL positions = [

lightninglarry avatar Nov 22 '21 22:11 lightninglarry

Here's what I did: #338

This shows how to add a method to the lineupOptimizer class, which will set the max_from_one_team attribute to whatever value you pass to it. This has the same effect as @lightninglarry 's technique, but instead of hardcoding in the settings you pass the value from your program.

holmes72 avatar Jan 08 '22 17:01 holmes72