npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fanduel_nba_lineup_optimizer

v1.0.6

Published

This module contains a closure built on a genetic algorithm that allows you to rapidly spawn optimized NBA FanDuel lineups.

Downloads

18

Readme

Fanduel NBA Lineup Optimizer


A genetic algorithm that rapidly finds optimal constrained pairings from large datasets

This repo allows you to rapidly generate valid high value lineup pairings for FanDuel using a compounding genetic algorithm. In other words, this is gold for the fantasy sports nerds! You're welcome for open sourcing this ;) Report issues on GitHub. Pull requests more than welcome. Trying to contact me directly? Hit me at [email protected]

Want to see this algorithm in action? Head to my website http://BasketballRoto.com and click the green Optimize Roster button and enjoy the magic.

Usage directions:

  • Enter your npm initialized project directory and install the library by running: npm install --save fanduel_nba_lineup_optimizer

  • In the file you intend to use the library in, import the library like so: const geneticLineupOptimizer = require('fanduel_nba_lineup_optimizer');

  • Initialize the library like so (we'll discuss the params later on): var lineupBuilder = geneticLineupOptimizer.spawnEnvironment(cleansedData, generations, evolutions, positions, budget, mutations);

  • Once initialized, if no formatting errors are logged, you can begin to spawn lineups like so: var playersToAdd = lineupBuilder.spawnLineup();

  • Then, the playersToAdd variable will be false if a lineup could not be produced (and the reason is console.logged), or it will contain an object with a playersToAdd.fitness (projected score) property and a playersToAdd.lineup property that will contain a grouping of players based on your parameters.

Parameters:

As discussed above, the library is initialized like so:

var lineupBuilder = geneticLineupOptimizer.spawnEnvironment(cleansedData, generations, evolutions, positions, budget, mutations);

Let's discuss each of those parameters in more detail:


1) cleansedData - array

This is an array that contains the player objects the algorithm will be pairing and using as it's population from which it derives lineups. Each of the player objects in the cleansedData array MUST contain the following properties:

| Property | Type | Definition | | ------------- |:----------:| ------------:| | id | int | A unique identifier. | | fanduel_positions | string | A single string containing the abbreviated FanDuel position that the player is eligible for, i.e. 'PG', 'SG', 'SF', 'PF' or 'C' | | fanduel_price | int | The player's assigned FanDuel price. | | _DFSpoints | int | The projected total FanDuel points that the player will score. |


2) generations - int

This integer determines how many generations (essentially iterations) each evolution will evolve and breed for. The more you include, the longer the process will take, but the higher your odds will be to reach the maximum projected score. I'd suggest starting off with 50. As with evolutions, the more generations you include will slow your processing time but increase your odds of finding the optimal lineup.


3) evolutions - int

This integer determines the number of times the algorithm will compound. So, for example, let's say you choose 50 generations and 4 evolutions; the algorithm will evolve 4 different lineups that were each born from 50 iterations. The algorithm will then select the highest lineup of those 4, and return that as the optimal lineup. As with generations, the more evolutions you include will slow your processing time but increase your odds of finding the optimal lineup.


4) positions - array

An array containing strings of the abbreviated FanDuel position that you solving for, i.e. 'PG', 'SG', 'SF', 'PF' or 'C'. So, for example, let's say you only want to solve for 2 PG positions and 2 SF positions; your positions parameter would look like this: ['PG','PG','SF','SF']. Or, if you want to solve for 1 SG and 2 PF positions, your positions parameter would look like this: ['SG','PF','PF']. * (If you've pre-selected X players, their single positions should not be included in the positions array, their cost should be removed from the budget and their player objects should be removed from the cleansedData array before initialization)


5) budget - int

This parameter dictates what budget the algorithm is allowed to spend in optimizing your lineup. So, for example, if you are solving for an entire lineup, your budget would be 60,000. Or, if you've selected two players already that cost a total of 12,000, you would pass in a budget of 48,000. * (If you've pre-selected X players, their single positions should not be included in the positions array, their cost should be removed from the budget and their player objects should be removed from the cleansedData array before initialization)


6) mutations - int

This determines how many mutations each generation will create during the breeding process. Try messing around with this number, but I recommend between 3-5. It greatly increases your odds of returning the optimal lineup, but does reach a point of diminishing returns in regards to speed. As with generations, the more mutations you include will slow your processing time but increase your odds of finding the optimal lineup.


Want to see this algorithm in action? Head to my website http://BasketballRoto.com and click the green Optimize Roster button and enjoy the magic.

Trying to contact me? Hit me at [email protected]