DimaKudosh / pydfs-lineup-optimizer

Daily Fantasy Sports lineup optimzer for all popular daily fantasy sports sites
MIT License
418 stars 157 forks source link

BOOSTS to players based on another player #395

Open lightninglarry opened 1 year ago

lightninglarry commented 1 year ago

How could I code in when player A is in lineup, player B gets a positive or negative bump to his projection?

example: Lebron James and Anthony Davis. Both high ceiling players and high priced. More than likely they dont get to the optimal together. 1 goes off, that hurts other usually.

So If lineup has Lebron, giving AD a -20 % boost to his projection? Or in NFL If lineup has QB Josh Allen, giving WR Stefon Diggs a + 20 % boost to his projection?

This would not force or not force guys in, but rather tweak their projections.

chrisbach1 commented 1 year ago

I think you would have to do some complex coding for the optimizer to boost or subtract another players points IF a certain player is selected in a lineup. What I would suggest is looking into the grouping. As far as NBA goes, you are probably better off to make some solid grouping rules or player/position correlation stacks to your optimizer due to the amount of games in one night and the amount of changes made to final rosters before a game. There isn't much time between sites posting starters and the game actually beginning. That, in combination with games starting every 30 minutes, up to 14 games in a single night, and late swapping...it sound like it would be a nightmare.

You can put Lebron and Davis in a group and make it so only 1 is selected.(max_from_group)

group = PlayersGroup(optimizer.player_pool.get_players('LeBron James', 'Anthony Davis'), max_from_group=1) optimizer.add_players_group(group)

You could also group wide receivers based on if a quarterback is in your lineup. If Josh Allen is in your lineup, it will pair with at least one WR from the group.

group = PlayersGroup( optimizer.player_pool.get_players('Stephon Diggs', 'Gabriel Davis', 'Isaiah Mckenzie'), max_from_group=1, depends_on=optimizer.player_pool.get_player_by_name('Josh Allen'), strict_depend=False, # if you want to generate lineups with Diggs, Davis, Mckenzie but without Josh Allen ) optimizer.add_players_group(group)

lightninglarry commented 1 year ago

i understand the logic and do use your examples that you listed. I guess my query was more for a smaller/single game type slate. Mainly NFL. I have access to another premium optimizer that allows to do this, but was just seeing if anyone had insight on ways to do this with python.

Dr-Two-Inch commented 1 year ago

@lightninglarry I think the easiest programmatic solution here is to add a step during your lineup sorting at the end that boosts the overall projection. For example: if this row contains "Player A" & "Player B" then multiply the total projection by 1.05 #5% boost.

lightninglarry commented 1 year ago

@Dr-Two-Inch I follow what your saying, but could you give an example with code?