Open chrisbach1 opened 1 year ago
I hadnt tried to use my late swap code yet this season. It had been 10 months since i used it, and tried last night on the NBA slate as Ja Morant was scratched.
Got the same error you got. Code worked last season.
It stopped because the loop most likely hit a lineup with all players that could not be swapped remove those with a preliminary step and it should work.
@Dr-Two-Inch - is there an easy way to know which lineups have all players who's games have started? If I have a csv with 150 lineups generated all I can see is player ID's. That would take me hours to weed out certain lineups.
You could add additional columns after the ftps columns with player names and time if you had player start times in your players list.
On Thu, Jan 19, 2023, 7:31 PM Chris Bachmann @.***> wrote:
@Dr-Two-Inch https://github.com/Dr-Two-Inch - is there an easy way to know which lineups have all players who's games have started? If I have a csv with 150 lineups generated all I can see is player ID's. That would take me hours to weed out certain lineups.
— Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/398#issuecomment-1397781321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANBWO7V5LL3IUSUUDLIKHGDWTHMFLANCNFSM6AAAAAATNIWOQU . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@chrisbach1 - I'm sure there is a better programmatic solution but right now I just use a quick excel function ( COUNTIF(E2:L2,"(LOCKED)") ) to look at each lineup in my DKEntries.csv file and manually remove any lineup that has all 8 players locked. It does take some time it makes the process a lot faster than manually inspecting every cell.
@Dr-Two-Inch This is brilliant. I just want to make sure im following your instructions. Grab the csv after lock and use your excel function to spot all 9 spots locked. Delete those rows, so the optimizer wont be stopped because of this. Say you had 150 lineups, and you deleted 25 lineups/rows. Then you would just optimize 125 and copy/paste over the 125 rows remaining in your DKEntries.csv file, that way it never touches the 25 where theres nothing to do the lineup since all are locked.
Am i correct? This would have been great last night as we had like 5 or more guys scratched due to the upcoming all star break.
@lightninglarry That's it for the most part if the function reads 8 delete the row, what works best for me is to sort by the column with the function in it (smallest - largest) then delete the rows with 8 spots locked all at once. This way is also important because the solver will also encounter an issue if there is an empty row as well.
@lightninglarry & @chrisbach1 to clarify one thing all of this only works after the game has actually tipped that way the DKEntries file will read "In progress" for the locked players. So for example typically between the 6 and 6:30 pm game locks, I will not actually download the DKEntries file until ~6:15 pm.
@Dr-Two-Inch i assume you would use same steps if playing on Fanduel as well?
@lightninglarry There are some minor differences for how FD handles lock times and locked players but the concepts should all stay the same. I would encourage you to practice on a short slate where you expect much less news like tonight (3-game slate) for example.
So I got my late swap functioning, much props @Dr-Two-Inch .
Fanduel is a bigger hurdle.
After slate locks, and you download the live csv, it just gives you numbers 3333-3333 as a players id. No name, no nothing. So unless you know who 3333-3333 is , you have no idea if his game has started. on DK it will say (LOCKED) after players name so you can tell.
Only thing I can say is to run the latevswap and if it doesn't crash, you didn't have all 9 spots locked, if it crashes, well I dont know then. Late swap in nba is usually a mad dash versus time and unless I'm missing something it would be hard to determine if all 9 spots are filled just looking at the live csv.
I wrote a script to remove all the rows from the csv if all players are locked. Takes like a second to run. Let me know if you guys are interested. I can post the code
If you want to do a lateswap, you have to redownload your "EDIT ENTRIES" csv from draftkings. Thats where it will contain all the locked lineups.
I only use it for NBA just FYI
im game to try it out @chrisbach1 .
Do you have any advice for my FD issue from my comment above when it doesnt say locked at all on live entries from Fanduel?
Im not sure about fanduel. I dont use it too often. I would need a sample csv with lineups currently in progress
import csv
with open('DKEntries.csv', 'r') as input_file, open('output.csv', 'w', newline='') as output_file: reader = csv.reader(input_file) writer = csv.writer(output_file)
headers = next(reader)
writer.writerow(headers)
for row in reader:
if all('LOCKED' in cell for cell in row[4:12]):
continue
writer.writerow(row)
This will read your Draftkings file and it needs to be labeled 'DKEntries'. It will then create a new csv without the rows that have all positions locked. The output csv is titles 'output.csv'
The output.csv needs to be where you are fetching lineups from in the latewap feature.
Has anyone ever had a problem with Late Swap on NBA? It seems like my optimizer will get stuck and stop running. I removed all Exposures and restrictions but it just stops after a few lineups are built. Here is my error:
*File "C:\Users\chris\Desktop\Own\LATE_SWAP.PY", line 27, in
for lineup in optimizer.optimize_lineups(lineups):
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py", line 494, in optimize_lineups
generated_lineup = self._build_lineup(lineup_players, context, unswappable_players)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py", line 534, in _build_lineup
players_with_positions = link_players_with_positions(players, positions)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\site-packages\pydfs_lineup_optimizer\utils.py", line 109, in link_players_with_positions
raise LineupOptimizerException('Unable to build lineup')
pydfs_lineup_optimizer.exceptions.LineupOptimizerException: Unable to build lineup**