DimaKudosh / pydfs-lineup-optimizer

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

Locked two players for basketball draftkings caption mode #207

Closed flutter-genius closed 4 years ago

flutter-genius commented 4 years ago
from pydfs_lineup_optimizer import Site, Sport, get_optimizer

optimizer = get_optimizer(Site.DRAFTKINGS_CAPTAIN_MODE, Sport.BASKETBALL)
optimizer.load_players_from_csv("DKSalaries.csv")
player1 = optimizer.get_player_by_name("LeBron James")
player2 = optimizer.get_player_by_name("Tyler Herro")
optimizer.add_player_to_lineup(player1)
optimizer.add_player_to_lineup(player2)

lineup_generator = optimizer.optimize(3)
for lineup in lineup_generator:
    print(lineup)

I tried with this code. If there are only one locked player, it is good. And with this code, I am getting below error. Please help me. Thank you.

Traceback (most recent call last): File ".\example.py", line 9, in <module> optimizer.add_player_to_lineup(player2) File "F:\source\018_django_lingups_optimizer\workspace\pydfs-lineup-optimizer-master\pydfs_lineup_optimizer\lineup_optimizer.py", line 224, in add_player_to_lineup raise LineupOptimizerException('You\'re already select all %s\'s' % '/'.join(player.positions)) pydfs_lineup_optimizer.exceptions.LineupOptimizerException: You're already select all CPT's PS F:\source\018_django_lingups_optimizer\workspace\pydfs-lineup-optimizer-master>

Denwen12 commented 4 years ago

thats because its trying to use the names in the top of the csv and they prob end up being in the same position in csv as cpt position

Denwen12 commented 4 years ago

draftkings has repeated players names in csv

flutter-genius commented 4 years ago

Thank you, Denwen. for solution, what is your suggestions?

flutter-genius commented 4 years ago

yeah, it is correct that draftkings has repeated players names in csv

flutter-genius commented 4 years ago

Is there way to solve this problem?

Denwen12 commented 4 years ago

gimme a few to check my stuff

flutter-genius commented 4 years ago

Thank you

Denwen12 commented 4 years ago

where do you want herro and lebron locked

flutter-genius commented 4 years ago

It is just example

Denwen12 commented 4 years ago

ok

Denwen12 commented 4 years ago

Can you check if this worked for lebron in capt position?

player = ['LeBron James']
position = ['CPT']
optimizer.add_players_group(PlayersGroup(players=[player for player in optimizer.players if player.name  in player and list_intersection(player.positions, position)], min_from_group=1, ))
flutter-genius commented 4 years ago

yeah, it is working for 1 locked player

Denwen12 commented 4 years ago

you can prob repeat that set of code with another player group

Denwen12 commented 4 years ago

but adjust the group and put position2 and player2

flutter-genius commented 4 years ago

Ok, let me try with it. Thank you

Denwen12 commented 4 years ago

if you need help editing the code let me know

flutter-genius commented 4 years ago

Ok, thanks

Denwen12 commented 4 years ago

any luck?

flutter-genius commented 4 years ago

I am trying now. If I solve the problem, will message..

flutter-genius commented 4 years ago

I solved the problem. If I try with get_player_by_id, it is working well. Thank you, Denwen

Denwen12 commented 4 years ago

can you show an example of the code you used?

flutter-genius commented 4 years ago
from pydfs_lineup_optimizer import Site, Sport, get_optimizer, PlayersGroup

optimizer = get_optimizer(Site.DRAFTKINGS_CAPTAIN_MODE, Sport.BASKETBALL)
optimizer.load_players_from_csv("DKSalaries.csv")
player1 = optimizer.get_player_by_id("15545066")
player2 = optimizer.get_player_by_id("15545029")

optimizer.add_player_to_lineup(player1)
optimizer.add_player_to_lineup(player2)

lineup_generator = optimizer.optimize(3)
for lineup in lineup_generator:
    print(lineup)
flutter-genius commented 4 years ago

of course, two locked players can't be CPT position.

Denwen12 commented 4 years ago

thats what i figured when i saw your error

flutter-genius commented 4 years ago

Great

Denwen12 commented 4 years ago

there is different ways of doing stuff just have to figure out what works best

flutter-genius commented 4 years ago

If you want, could you explain about it? Thank you