model

package
v0.0.0-...-c5fd561 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllWager = []Wager{
	WagerOver,
	WagerUnder,
}
View Source
var PlayerNames map[string]string = map[string]string{
	"Nah'Shon Hyland":     "Bones Hyland",
	"Ty Harris":           "Tyasha Harris",
	"Naz Hillman":         "Naz Hillmon",
	"Olivia Nelson-Odada": "Olivia Nelson-Ododa",
}

If key is found, use the value.

Functions

func ConvertMinutesToFloat

func ConvertMinutesToFloat(minutes string) (float64, error)

func CosineSimilarity

func CosineSimilarity(a, b []float64) float64

func EuclideanDistance

func EuclideanDistance(diff PlayerDiff, statsOfInterest []Stat) float64

EuclideanDistance calculates the euclidean distance of a PlayerDiff object that stores the difference between two players' averages.

func StandardizedPlayerStatsFields

func StandardizedPlayerStatsFields() []string

func TeamEuclideanDistance

func TeamEuclideanDistance(diff TeamDiff, statsOfInterest []Stat) float64

Types

type AverageStats

type AverageStats struct {
	Assists                float64 `json:"assists"`
	Blocks                 float64 `json:"blocks"`
	DefensiveRebounds      float64 `json:"defensive_rebounds"`
	FieldGoalsAttempted    float64 `json:"field_goals_attempted"`
	FieldGoalsMade         float64 `json:"field_goals_made"`
	FreeThrowsAttempted    float64 `json:"free_throws_attempted"`
	FreeThrowsMade         float64 `json:"free_throws_made"`
	GamesPlayed            float64 `json:"games_played"`
	Height                 float64 `json:"height"`
	Minutes                float64 `json:"minutes"`
	OffensiveRebounds      float64 `json:"offensive_rebounds"`
	PersonalFoulsDrawn     float64 `json:"personal_fouls_drawn"`
	PersonalFouls          float64 `json:"personal_fouls"`
	Points                 float64 `json:"points"`
	Rebounds               float64 `json:"rebounds"`
	Steals                 float64 `json:"steals"`
	ThreePointersAttempted float64 `json:"three_pointers_attempted"`
	ThreePointersMade      float64 `json:"three_pointers_made"`
	Turnovers              float64 `json:"turnovers"`
	Weight                 float64 `json:"weight"`
	FantasyScore           float64 `json:"fantasy_score"`
	PointsAssists          float64 `json:"points_assists"`
	PointsRebounds         float64 `json:"points_rebounds"`
	PointsReboundsAssists  float64 `json:"points_rebounds_assists"`
	ReboundsAssists        float64 `json:"rebounds_assists"`
	BlocksSteals           float64 `json:"blocks_steals"`
	DoubleDouble           float64 `json:"double_double"`
	Passes                 float64 `json:"passes"`
	PotentialAssists       float64 `json:"potential_assists"`
}

func (*AverageStats) PercentChange

func (startValue *AverageStats) PercentChange(finalValue *AverageStats) *AverageStats

type DBProposition

type DBProposition struct {
	PlayerID     int        `db:"playerID"`
	GameID       string     `db:"gameID"`
	OpponentID   int        `db:"opponentID"`
	PlayerName   string     `db:"playerName"`
	StatType     string     `db:"statType"`
	Target       float64    `db:"target"`
	Sportsbook   string     `db:"sportsbook"`
	LastModified *time.Time `db:"lastModified"`
	CreatedAt    *time.Time `db:"CreatedAt"`
	UpdatedAt    *time.Time `db:"UpdatedAt"`
}

type GameBreakdownInput

type GameBreakdownInput struct {
	Name   string      `json:"name"`
	Filter *GameFilter `json:"filter"`
	Weight float64     `json:"weight"`
}

type GameFilter

type GameFilter struct {
	TeamID              *int            `json:"teamID"`
	OpponentID          *int            `json:"opponentID"`
	OpponentMatch       *bool           `json:"opponentMatch"`
	PlayerID            *int            `json:"playerID"`
	GameID              *string         `json:"gameID"`
	Seasons             *[]SeasonOption `json:"seasons"`
	SeasonMatch         *bool           `json:"seasonMatch"`
	PreviousSeasonMatch *bool           `json:"previousSeasonMatch"`
	StartDate           *string         `json:"startDate"`
	EndDate             *string         `json:"endDate"`
	GameType            *GameType       `json:"gameType"`
	GameTypeMatch       *bool           `json:"gameTypeMatch"`
	HomeOrAway          *HomeOrAway     `json:"homeOrAway"`
	HomeOrAwayMatch     *bool           `json:"homeOrAwayMatch"`
	StatFilters         *[]*StatFilter  `json:"statFilters"`
	LastX               *int            `json:"lastX"`
	Outcome             *GameOutcome    `json:"outcome"`
}

func (*GameFilter) MatchPlayerGame

func (gameFilter *GameFilter) MatchPlayerGame(g *PlayerGame) bool

Match returns true if the player game matches the given filter

func (*GameFilter) MongoFilter

func (f *GameFilter) MongoFilter() bson.M

func (*GameFilter) MongoPipeline

func (f *GameFilter) MongoPipeline(playerPipeline mongo.Pipeline) mongo.Pipeline

func (GameFilter) String

func (f GameFilter) String() string

type GameOutcome

type GameOutcome string
const (
	GameOutcomeWin     GameOutcome = "WIN"
	GameOutcomeLoss    GameOutcome = "LOSS"
	GameOutcomePending GameOutcome = "PENDING"
)

func (GameOutcome) IsValid

func (e GameOutcome) IsValid() bool

func (GameOutcome) MarshalGQL

func (e GameOutcome) MarshalGQL(w io.Writer)

func (GameOutcome) String

func (e GameOutcome) String() string

func (*GameOutcome) UnmarshalGQL

func (e *GameOutcome) UnmarshalGQL(v interface{}) error

type GamePrediction

type GamePrediction struct {
	Estimation         *AverageStats             `json:"estimation"`
	EstimationAccuracy *AverageStats             `json:"estimationAccuracy"`
	Fragments          []*GamePredictionFragment `json:"fragments"`
}

type GamePredictionFragment

type GamePredictionFragment struct {
	Name         string         `json:"name"`
	Derived      *AverageStats  `json:"derived"`
	DerivedGames []*PlayerGame  `json:"derivedGames"`
	Base         *AverageStats  `json:"base"`
	PctChange    *AverageStats  `json:"pctChange"`
	Weight       float64        `json:"weight"`
	Propositions []*Proposition `json:"propositions"`
}

type GameType

type GameType string
const (
	GameTypeRegularSeason GameType = "REGULAR_SEASON"
	GameTypePlayoffs      GameType = "PLAYOFFS"
)

func (GameType) IsValid

func (e GameType) IsValid() bool

func (GameType) MarshalGQL

func (e GameType) MarshalGQL(w io.Writer)

func (GameType) String

func (e GameType) String() string

func (*GameType) UnmarshalGQL

func (e *GameType) UnmarshalGQL(v interface{}) error

type HomeOrAway

type HomeOrAway string
const (
	HomeOrAwayHome HomeOrAway = "HOME"
	HomeOrAwayAway HomeOrAway = "AWAY"
)

func (HomeOrAway) IsValid

func (e HomeOrAway) IsValid() bool

func (HomeOrAway) MarshalGQL

func (e HomeOrAway) MarshalGQL(w io.Writer)

func (HomeOrAway) String

func (e HomeOrAway) String() string

func (*HomeOrAway) UnmarshalGQL

func (e *HomeOrAway) UnmarshalGQL(v interface{}) error

type Injury

type Injury struct {
	Status     string `json:"status" bson:"status"`
	StartDate  string `json:"start_date" bson:"start_date"`
	ReturnDate string `json:"return_date" bson:"return_date"`
	PlayerID   int    `json:"playerID" bson:"playerID"`
	Team       Team   `json:"team" bson:"team"`
}

TODO: Might eventually want missed gameIDs

type ModelInput

type ModelInput struct {
	Model              *string               `json:"model"`
	GameBreakdowns     []*GameBreakdownInput `json:"gameBreakdowns"`
	SimilarPlayerInput *SimilarPlayerInput   `json:"similarPlayerInput"`
	SimilarTeamInput   *SimilarTeamInput     `json:"similarTeamInput"`
}

type Operator

type Operator string
const (
	OperatorGt  Operator = "GT"
	OperatorGte Operator = "GTE"
	OperatorLt  Operator = "LT"
	OperatorLte Operator = "LTE"
	OperatorEq  Operator = "EQ"
	OperatorNeq Operator = "NEQ"
)

func (*Operator) Evaluate

func (o *Operator) Evaluate(left, right float64) bool

func (Operator) IsValid

func (e Operator) IsValid() bool

func (Operator) MarshalGQL

func (e Operator) MarshalGQL(w io.Writer)

func (Operator) String

func (e Operator) String() string

func (*Operator) UnmarshalGQL

func (e *Operator) UnmarshalGQL(v interface{}) error

type Period

type Period struct {
	StartDate *string         `json:"startDate"`
	EndDate   *string         `json:"endDate"`
	Seasons   *[]SeasonOption `json:"seasons"`
	Limit     *int            `json:"limit"`
}

TODO: Add GameType to Period

func (*Period) MatchGame

func (p *Period) MatchGame(game *PlayerGame) bool

func (*Period) MatchProjection

func (p *Period) MatchProjection(projection *Projection) bool

func (*Period) MongoFilter

func (p *Period) MongoFilter() bson.M

func (Period) String

func (p Period) String() string

type Player

type Player struct {
	FirstName    string   `json:"first_name" bson:"first_name" db:"firstName"`
	LastName     string   `json:"last_name" bson:"last_name" db:"lastName"`
	Name         string   `json:"name" bson:"name" db:"name"`
	PlayerID     int      `json:"playerID" bson:"playerID" db:"playerID"`
	Seasons      []string `json:"seasons" bson:"seasons"` //todo db
	Position     string   `json:"position" bson:"position" db:"position"`
	CurrentTeam  string   `json:"currentTeam" bson:"teamABR" db:"teamABR"`
	TeamID       int      `json:"teamID" bson:"teamID" db:"teamID"`
	Height       string   `json:"height" bson:"height" db:"height"`
	HeightInches int      `json:"heightInches" bson:"heightInches" db:"heightInches"`
	Weight       int      `json:"weight" bson:"weight" db:"weight"`

	CreatedAt *time.Time `json:"CreatedAt" bson:"CreatedAt" db:"CreatedAt"`
	UpdatedAt *time.Time `json:"UpdatedAt" bson:"UpdatedAt" db:"UpdatedAt"`
	// When retrieving a player, also retrieve all of the games they've played within the minimum start date and maximum end date.
	GamesCache []*PlayerGame `json:"gamesCache" bson:"gamesCache"`
	League     string        `json:"league" bson:"league" db:"league"`
}

func (*Player) HeightInInches

func (p *Player) HeightInInches() int

type PlayerAverage

type PlayerAverage struct {
	AllMinutes             []string `json:"all_minutes" bson:"all_minutes"`
	Assists                float64  `json:"assists" bson:"assists"`
	Blocks                 float64  `json:"blocks" bson:"blocks"`
	DefensiveRebounds      float64  `json:"defensive_rebounds" bson:"defensive_rebounds"`
	FieldGoalsAttempted    float64  `json:"field_goals_attempted" bson:"field_goals_attempted"`
	FieldGoalsMade         float64  `json:"field_goals_made" bson:"field_goals_made"`
	FreeThrowsAttempted    float64  `json:"free_throws_attempted" bson:"free_throws_attempted"`
	FreeThrowsMade         float64  `json:"free_throws_made" bson:"free_throws_made"`
	GamesPlayed            float64  `json:"games_played" bson:"games_played"`
	Height                 float64  `json:"height" bson:"height"`
	Minutes                float64  `json:"minutes" bson:"minutes"`
	OffensiveRebounds      float64  `json:"offensive_rebounds" bson:"offensive_rebounds"`
	Player                 Player   `json:"player" bson:"player"`
	PersonalFoulsDrawn     float64  `json:"personal_fouls_drawn" bson:"personal_fouls_drawn"`
	PersonalFouls          float64  `json:"personal_fouls" bson:"personal_fouls"`
	Points                 float64  `json:"points" bson:"points"`
	Rebounds               float64  `json:"rebounds" bson:"rebounds"`
	Steals                 float64  `json:"steals" bson:"steals"`
	ThreePointersAttempted float64  `json:"three_pointers_attempted" bson:"three_pointers_attempted"`
	ThreePointersMade      float64  `json:"three_pointers_made" bson:"three_pointers_made"`
	Turnovers              float64  `json:"turnovers" bson:"turnovers"`
	Weight                 float64  `json:"weight" bson:"weight"`
	FantasyScore           float64  `json:"fantasy_score"`
	PointsAssists          float64  `json:"points_assists"`
	PointsRebounds         float64  `json:"points_rebounds"`
	PointsReboundsAssists  float64  `json:"points_rebounds_assists"`
	ReboundsAssists        float64  `json:"rebounds_assists"`
	BlocksSteals           float64  `json:"blocks_steals"`
	DoubleDouble           float64  `json:"double_double"`
}

TODO: To add a new stat to player similarity, add it to all of: ... // TODO: look into this, see if there is a more maintainable way to do this

func NewPlayerAverage

func NewPlayerAverage(games []*PlayerGame, player *Player) PlayerAverage

func (*PlayerAverage) AverageMinutes

func (p *PlayerAverage) AverageMinutes() (float64, error)

func (*PlayerAverage) AverageStats

func (p *PlayerAverage) AverageStats() *AverageStats

func (*PlayerAverage) Difference

func (p *PlayerAverage) Difference(fromPlayer PlayerAverage) PlayerDiff

func (*PlayerAverage) Normalize

func (p *PlayerAverage) Normalize(stats ...StatOfInterest) PlayerAverage

func (*PlayerAverage) Score

func (p *PlayerAverage) Score(stat Stat) float64

type PlayerDiff

type PlayerDiff PlayerAverage

type PlayerFilter

type PlayerFilter struct {
	Name                *string         `json:"name"`
	PlayerID            *int            `json:"playerID"`
	Seasons             *[]SeasonOption `json:"seasons"`
	PositionStrict      *Position       `json:"positionStrict"`
	PositionStrictMatch *bool           `json:"positionStrictMatch"`
	PositionLoose       *Position       `json:"positionLoose"`
	PositionLooseMatch  *bool           `json:"positionLooseMatch"`
	TeamAbr             *string         `json:"teamABR"`
	TeamID              *int            `json:"teamID"`
	StartDate           *string         `json:"startDate"`
	EndDate             *string         `json:"endDate"`
	StatFilters         *[]*StatFilter  `json:"statFilters"`
	WithGames           *GameFilter     `json:"withGames"`
}

func (PlayerFilter) FilterPlayerStats

func (input PlayerFilter) FilterPlayerStats(players []*Player, toPlayer *Player) []*Player

func (PlayerFilter) GetEarliestSeasonStartDate

func (f PlayerFilter) GetEarliestSeasonStartDate() (*time.Time, error)

func (PlayerFilter) Key

func (f PlayerFilter) Key() string

func (*PlayerFilter) MongoPipeline

func (input *PlayerFilter) MongoPipeline() mongo.Pipeline

func (PlayerFilter) String

func (f PlayerFilter) String() string

type PlayerGame

type PlayerGame struct {
	AssistPercentage             sql.NullFloat64 `db:"assistPct" json:"assist_percentage" bson:"assist_percentage"`
	Assists                      sql.NullInt16   `db:"assists" json:"assists" bson:"assists"`
	PotentialAssists             sql.NullInt16   `db:"potentialAssists" json:"potential_assists" bson:"potential_assists"`
	AssistConversionRate         sql.NullFloat64 `db:"assistConversionRate" json:"assist_conversion_rate" bson:"assist_conversion_rate"`
	Passes                       sql.NullInt16   `db:"passes" json:"passes" bson:"passes"`
	Date                         *time.Time      `db:"date" json:"date" bson:"date"`
	DefensiveReboundPercentage   sql.NullFloat64 `db:"defensiveReboundPct" json:"defensive_rebound_percentage" bson:"defensive_rebound_percentage"`
	DefensiveRebounds            sql.NullInt16   `db:"defensiveRebounds" json:"defensive_rebounds" bson:"defensive_rebounds"`
	EffectiveFieldGoalPercentage sql.NullFloat64 `db:"effectiveFieldGoalPct" json:"effective_field_goal_percentage" bson:"effective_field_goal_percentage"`
	FieldGoalPercentage          sql.NullFloat64 `db:"fieldGoalPct" json:"field_goal_percentage" bson:"field_goal_percentage"`
	FieldGoalsAttempted          sql.NullInt16   `db:"fieldGoalsAttempted" json:"field_goals_attempted" bson:"field_goals_attempted"`
	FieldGoalsMade               sql.NullInt16   `db:"fieldGoalsMade" json:"field_goals_made" bson:"field_goals_made"`
	FreeThrowsAttempted          sql.NullInt16   `db:"freeThrowsAttempted" json:"free_throws_attempted" bson:"free_throws_attempted"`
	FreeThrowsMade               sql.NullInt16   `db:"freeThrowsMade" json:"free_throws_made" bson:"free_throws_made"`
	FreeThrowsPercentage         sql.NullFloat64 `db:"freeThrowPct" json:"free_throws_percentage" bson:"free_throws_percentage"` //change to freeThrowPercentage
	GameID                       string          `db:"gameID" json:"gameID" bson:"gameID"`
	HomeOrAway                   HomeOrAway      `db:"homeAway" json:"home_or_away" bson:"home_or_away"` //add "HOME" or "AWAY" constraint
	Margin                       sql.NullInt16   `db:"margin" json:"margin" bson:"margin"`
	Minutes                      float64         `db:"minutes" json:"minutes" bson:"minutes"`
	OffensiveReboundPercentage   sql.NullFloat64 `db:"offensiveReboundPct" json:"offensive_rebound_percentage" bson:"offensive_rebound_percentage"`
	OffensiveRebounds            sql.NullInt16   `db:"offensiveRebounds" json:"offensive_rebounds" bson:"offensive_rebounds"`
	TeamID                       int             `db:"teamID" json:"team" bson:"team"`
	OpponentID                   int             `db:"opponentID" json:"opponent" bson:"opponent"`
	PersonalFoulsDrawn           sql.NullInt16   `db:"personalFoulsDrawn" json:"personal_fouls_drawn" bson:"personal_fouls_drawn"`
	PersonalFouls                sql.NullInt16   `db:"personalFouls" json:"personal_fouls" bson:"personal_fouls"`
	Points                       sql.NullInt16   `db:"points" json:"points" bson:"points"`
	PlayerID                     int             `db:"playerID" json:"playerID" bson:"playerID"`
	PlayerRef                    *Player         `json:"playerRef" bson:"playerRef"`
	Playoffs                     bool            `db:"playoffs" json:"playoffs" bson:"playoffs"`
	Season                       SeasonOption    `db:"season" json:"season" bson:"season"`
	ThreePointPercentage         sql.NullFloat64 `db:"threePointPct" json:"three_point_percentage" bson:"three_point_percentage"`
	ThreePointersAttempted       sql.NullInt16   `db:"threePointersAttempted" json:"three_pointers_attempted" bson:"three_pointers_attempted"`
	ThreePointersMade            sql.NullInt16   `db:"threePointersMade" json:"three_pointers_made" bson:"three_pointers_made"`
	Rebounds                     sql.NullInt16   `db:"rebounds" json:"total_rebounds" bson:"total_rebounds"`
	TrueShootingPercentage       sql.NullFloat64 `db:"trueShootingPct" json:"true_shooting_percentage" bson:"true_shooting_percentage"`
	Turnovers                    sql.NullInt16   `db:"turnovers" json:"turnovers" bson:"turnovers"`
	Blocks                       sql.NullInt16   `db:"blocks" json:"blocks" bson:"blocks"`
	Steals                       sql.NullInt16   `db:"steals" json:"steals" bson:"steals"`
	Usage                        sql.NullFloat64 `db:"usage" json:"usage" bson:"usage"`
	Outcome                      string          `db:"outcome" json:"win_or_loss" bson:"win_or_loss"`

	CreatedAt *time.Time `db:"CreatedAt" json:"CreatedAt" bson:"CreatedAt"`
	UpdatedAt *time.Time `db:"UpdatedAt" json:"UpdatedAt" bson:"UpdatedAt"`
}

func (*PlayerGame) Score

func (g *PlayerGame) Score(stat Stat) float64

type PlayerSimilarityMatrix

type PlayerSimilarityMatrix struct {
	Matrix map[int]SimilarityVector
}

func NewPlayerSimilarityMatrix

func NewPlayerSimilarityMatrix(players []PlayerAverage) *PlayerSimilarityMatrix

func (*PlayerSimilarityMatrix) AddNormalizedPlayers

func (m *PlayerSimilarityMatrix) AddNormalizedPlayers(players []PlayerAverage)

func (*PlayerSimilarityMatrix) AddPlayer

func (m *PlayerSimilarityMatrix) AddPlayer(playerID int, playerAverage PlayerAverage) error

AddPlayer adds a player to the matrix and calculates the comparisons between the new player and the existing players.

func (*PlayerSimilarityMatrix) AddPlayers

func (m *PlayerSimilarityMatrix) AddPlayers(players []PlayerAverage) error

func (*PlayerSimilarityMatrix) CompareAverages

func (m *PlayerSimilarityMatrix) CompareAverages(in int, averageIn PlayerAverage) map[int]PlayerDiff

func (*PlayerSimilarityMatrix) GetNearestPlayers

func (m *PlayerSimilarityMatrix) GetNearestPlayers(toPlayer int, limit int, statsOfInterest []Stat) (similarPlayers []*Player, err error)

type PlayerSnapshots

type PlayerSnapshots map[string]PlayerSimilarityMatrix

PlayerSnapshots in time holding the similarity matrix for each date range. The key is "<startDate>-<endDate>" and value is a similarity Matrix. The value is a matrix that holds the average stats of players and comparisons between them.

func NewPlayerSnapshots

func NewPlayerSnapshots() *PlayerSnapshots

func (*PlayerSnapshots) AddSnapshot

func (s *PlayerSnapshots) AddSnapshot(startDate, endDate time.Time, playerFilter *PlayerFilter, players []*Player)

func (*PlayerSnapshots) GetSimilarPlayers

func (s *PlayerSnapshots) GetSimilarPlayers(playerID, limit int, startDate, endDate string, playerFilter *PlayerFilter, statsOfInterest []Stat) []*Player

func (*PlayerSnapshots) Key

func (s *PlayerSnapshots) Key(startDate, endDate string, playerPoolFilter PlayerFilter) string

type PlayersInGame

type PlayersInGame struct {
	TeamPlayers     []*Player `json:"team" bson:"team"`
	OpponentPlayers []*Player `json:"opponent" bson:"opponent"`
}

type Position

type Position string
const (
	PositionG  Position = "G"
	PositionF  Position = "F"
	PositionC  Position = "C"
	PositionGF Position = "G_F"
	PositionFG Position = "F_G"
	PositionFC Position = "F_C"
	PositionCF Position = "C_F"
)

func (Position) IsValid

func (e Position) IsValid() bool

func (Position) MarshalGQL

func (e Position) MarshalGQL(w io.Writer)

func (Position) String

func (e Position) String() string

func (*Position) UnmarshalGQL

func (e *Position) UnmarshalGQL(v interface{}) error

type PrizePicks

type PrizePicks struct {
	Data     []PrizePicksData     `json:"data" bson:"data"`
	Included []PrizePicksIncluded `json:"included" bson:"included"`
}

type PrizePicksData

type PrizePicksData struct {
	//unique identifier of the projection
	PrizePickID string `json:"id" bson:"id"`
	Attributes  struct {
		//line available to be played on the board (i.e. 45.5), associated w/ a player and stat type
		Line_score string `json:"line_score" bson:"line_score"`
		//
		Risk_exposure float64 `json:"risk_exposure" bson:"risk_exposure"`
		//time the projection was created at
		Created_at string `json:"created_at" bson:"created_at"`
		//last time the projection was updated at
		Updated_at string `json:"updated_at" bson:"updated_at"`
		//the opponent of the player in the event offered, varies by league (i.e. for NFL the opposing team abbreviation)
		Description string `json:"description" bson:"description"`
		//time the event is expected to start
		Start_time string `json:"start_time" bson:"start_time"`
		// event states (i.e. pre-game, in-progress, final)
		Status string `json:"status" bson:"status"`
		//whether or not a projection is promotional in nature
		Is_promo            bool   `json:"is_promo" bson:"is_promo"`
		Discount_percentage string `json:"discount_percentage" bson:"discount_percentage"`
		//time the event is expected to end
		End_time string `json:"end_time" bson:"end_time"`
		Position struct {
			Data string `json:"data" bson:"data"`
		} `json:"position" bson:"position"`
	} `json:"attributes" bson:"attributes"`
	Relationships struct {
		Player struct {
			Data struct {
				ID string `json:"id" bson:"id"`
			} `json:"data" bson:"data"`
		} `json:"new_player" bson:"new_player"`
		League struct {
			Data struct {
				ID string `json:"id" bson:"id"`
			} `json:"data" bson:"data"`
		} `json:"league" bson:"league"`
		StatType struct {
			Data struct {
				ID string `json:"id" bson:"id"`
			} `json:"data" bson:"data"`
		} `json:"stat_type" bson:"stat_type"`
	} `json:"relationships" bson:"relationships"`
}

type PrizePicksIncluded

type PrizePicksIncluded struct {
	ID         string `json:"id" bson:"id"`
	Attributes struct {
		Name string `json:"name" bson:"name"`
	} `json:"attributes" bson:"attributes"`
}

type Projection

type Projection struct {
	PlayerName  string         `json:"playername" bson:"playername"`
	OpponentAbr string         `json:"opponent" bson:"opponent"` //TODO: Refactor to OpponentAbr
	Props       []*Proposition `json:"propositions" bson:"propositions"`
	StartTime   string         `json:"startTime" bson:"startTime"`
	Date        string         `json:"date" bson:"date"`

	Player   Player `json:"playerCache" bson:"playerCache"`
	Opponent Team   `json:"opponentTeam" bson:"opponentTeam"`
}

func GetBestProjection

func GetBestProjection(projections []*Projection) *Projection

func ParsePrizePick

func ParsePrizePick(prop PrizePicksData, itemIDToNameMap map[string]string, projections []*Projection) ([]*Projection, error)

ParsePrizePick creates a Projection and adds it to the projections slice or adds a Target to an existing projection

func ParseUnderdogProjection

func ParseUnderdogProjection(json UnderdogFantasy, sport string) ([]*Projection, error)

func (*Projection) UnmarshalBSON

func (p *Projection) UnmarshalBSON(data []byte) error

type PropBreakdown

type PropBreakdown struct {
	Name              string        `json:"name"`
	Over              int           `json:"over"`
	Under             int           `json:"under"`
	Push              int           `json:"push"`
	OverPct           float64       `json:"overPct"`
	UnderPct          float64       `json:"underPct"`
	PushPct           float64       `json:"pushPct"`
	DerivedAverage    float64       `json:"derivedAverage"`
	Weight            float64       `json:"weight"`
	PctChange         float64       `json:"pctChange"`
	Contribution      float64       `json:"contribution"`
	Base              float64       `json:"base"`
	DerivedGames      []*PlayerGame `json:"derivedGames"`
	DerivedGamesCount int           `json:"derivedGamesCount"`
	StdDev            float64       `json:"stdDev"`
}

type PropOutcome

type PropOutcome string
const (
	PropOutcomeOver    PropOutcome = "OVER"
	PropOutcomeUnder   PropOutcome = "UNDER"
	PropOutcomePush    PropOutcome = "PUSH"
	PropOutcomePending PropOutcome = "PENDING"
)

func (PropOutcome) IsValid

func (e PropOutcome) IsValid() bool

func (PropOutcome) MarshalGQL

func (e PropOutcome) MarshalGQL(w io.Writer)

func (PropOutcome) String

func (e PropOutcome) String() string

func (*PropOutcome) UnmarshalGQL

func (e *PropOutcome) UnmarshalGQL(v interface{}) error

type PropPrediction

type PropPrediction struct {
	Estimation         float64          `json:"estimation"`
	EstimationAccuracy *float64         `json:"estimationAccuracy"`
	Significance       float64          `json:"significance"`
	CumulativeOver     int              `json:"cumulativeOver"`
	CumulativeUnder    int              `json:"cumulativeUnder"`
	CumulativePush     int              `json:"cumulativePush"`
	CumulativeOverPct  float64          `json:"cumulativeOverPct"`
	CumulativeUnderPct float64          `json:"cumulativeUnderPct"`
	CumulativePushPct  float64          `json:"cumulativePushPct"`
	Wager              Wager            `json:"wager"`
	WagerOutcome       WagerOutcome     `json:"wagerOutcome"`
	Breakdowns         []*PropBreakdown `json:"breakdowns"`
	StdDev             float64          `json:"stdDev"`
}

type Proposition

type Proposition struct {
	PlayerID     int              `db:"playerID"`
	GameID       string           `db:"gameID"`
	OpponentID   int              `db:"opponentID"`
	PlayerName   string           `db:"playerName"`
	Sportsbook   SportsbookOption `db:"sportsbook" json:"sportsbook" bson:"sportsbook"`
	Target       float64          `db:"target" json:"target" bson:"target"`
	TypeRaw      string           `db:"statType" json:"type" bson:"type"`
	Type         Stat             `json:"propType" bson:"propType"`
	LastModified *time.Time       `json:"lastModified" bson:"lastModified" db:"lastModified"`
	Outcome      PropOutcome      `json:"outcome" bson:"outcome"`
	ActualResult *float64         `json:"actualResult" bson:"actualResult"`
	Accuracy     float64          `json:"accuracy" bson:"accuracy"`
	Game         *PlayerGame      `json:"game" bson:"game"`
	CreatedAt    *time.Time       `json:"createdAt" bson:"createdAt" db:"CreatedAt"`
	UpdatedAt    *time.Time       `json:"updatedAt" bson:"updatedAt" db:"UpdatedAt"`
}

func (*Proposition) MarshalJSON

func (p *Proposition) MarshalJSON() ([]byte, error)

func (*Proposition) Match

func (p *Proposition) Match(propositionFilter PropositionFilter) bool

func (*Proposition) UnmarshalBSON

func (p *Proposition) UnmarshalBSON(data []byte) error

func (*Proposition) UnmarshalJSON

func (p *Proposition) UnmarshalJSON(data []byte) error

type PropositionFilter

type PropositionFilter struct {
	Sportsbook      *SportsbookOption `json:"sportsbook"`
	PropositionType *Stat             `json:"propositionType"`
	StartDate       *string           `json:"startDate"`
	EndDate         *string           `json:"endDate"`
	PlayerID        *int              `json:"PlayerID"`
	PlayerName      *string           `json:"PlayerName"`
	TeamID          *int              `json:"TeamID"`
	TeamName        *string           `json:"TeamName"`
}

func (*PropositionFilter) UnmarshalBSON

func (f *PropositionFilter) UnmarshalBSON(data []byte) error

func (*PropositionFilter) UnmarshalJSON

func (f *PropositionFilter) UnmarshalJSON(data []byte) error

type Schedule

type Schedule struct {
	LeagueSchedule struct {
		GameDates []struct {
			Games []struct {
				GameDateEst string `json:"gameDateEst"`
				AwayTeam    struct {
					TeamTriCode string `json:"teamTriCode"`
				} `json:"awayTeam"`
				HomeTeam struct {
					TeamTriCode string `json:"teamTriCode"`
				} `json:"homeTeam"`
				GameID string `json:"gameId"`
			} `json:"games"`
		} `json:"gameDates"`
	} `json:"leagueSchedule"`
}

type SeasonOption

type SeasonOption string
const (
	SEASON_2022_23 SeasonOption = "2022-23"
	SEASON_2021_22 SeasonOption = "2021-22"
	SEASON_2020_21 SeasonOption = "2020-21"
)

func NewSeasonOption

func NewSeasonOption(s string) SeasonOption

func (SeasonOption) MarshalGQL

func (o SeasonOption) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*SeasonOption) UnmarshalBSON

func (s *SeasonOption) UnmarshalBSON(data []byte) error

func (*SeasonOption) UnmarshalGQL

func (o *SeasonOption) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (*SeasonOption) UnmarshalJSON

func (s *SeasonOption) UnmarshalJSON(data []byte) error

type SimilarPlayerInput

type SimilarPlayerInput struct {
	Limit            int           `json:"limit"`
	StatsOfInterest  []Stat        `json:"statsOfInterest"`
	PlayerPoolFilter *PlayerFilter `json:"playerPoolFilter"`
	Weight           float64       `json:"weight"`
}

type SimilarPlayerQuery

type SimilarPlayerQuery struct {
	SimilarPlayerInput SimilarPlayerInput `json:"similarPlayerInput"`
	ToPlayerID         int                `json:"toPlayerID"`
	EndDate            *time.Time         `json:"endDate"`
}

type SimilarTeamInput

type SimilarTeamInput struct {
	Limit           int           `json:"limit"`
	StatsOfInterest []Stat        `json:"statsOfInterest"`
	TeamPoolFilter  []*TeamFilter `json:"teamPoolFilter"`
	Period          *Period       `json:"period"`
	Weight          float64       `json:"weight"`
}

type SimilarityVector

type SimilarityVector struct {
	//Comparisons show the difference between the average of this player and the average of other players (e.g. thisPlayer.points - otherPlayer.points)
	Comparisons map[int]PlayerDiff
	//Average is the average stats of this player, so that they can be compared to other (new) players
	Average PlayerAverage
}

func (*SimilarityVector) GetNearest

func (v *SimilarityVector) GetNearest(limit int, statsOfInterest []Stat) []PlayerDiff

type SportsbookOption

type SportsbookOption string
const (
	SportsbookOptionPrizePicks      SportsbookOption = "PrizePicks"
	SportsbookOptionUnderdogFantasy SportsbookOption = "UnderdogFantasy"
)

func (SportsbookOption) IsValid

func (e SportsbookOption) IsValid() bool

func (SportsbookOption) MarshalGQL

func (e SportsbookOption) MarshalGQL(w io.Writer)

func (SportsbookOption) String

func (e SportsbookOption) String() string

func (*SportsbookOption) UnmarshalGQL

func (e *SportsbookOption) UnmarshalGQL(v interface{}) error

type StandardizedPlayerStats

type StandardizedPlayerStats struct {
	Name                   string  `db:"name"`
	Id                     int     `db:"playerID"`
	NGames                 int     `db:"games"`
	Assists                float64 `db:"ZSCORE_assists"`
	DefensiveRebounds      float64 `db:"ZSCORE_defensiveRebounds"`
	OffensiveRebounds      float64 `db:"ZSCORE_offensiveRebounds"`
	FieldGoalsAttempted    float64 `db:"ZSCORE_fieldGoalsAttempted"`
	FieldGoalsMade         float64 `db:"ZSCORE_fieldGoalsMade"`
	FreeThrowsAttempted    float64 `db:"ZSCORE_freeThrowsAttempted"`
	FreeThrowsMade         float64 `db:"ZSCORE_freeThrowsMade"`
	PersonalFoulsDrawn     float64 `db:"ZSCORE_personalFoulsDrawn"`
	PersonalFouls          float64 `db:"ZSCORE_personalFouls"`
	Points                 float64 `db:"ZSCORE_points"`
	ThreePointersAttempted float64 `db:"ZSCORE_threePointersAttempted"`
	ThreePointersMade      float64 `db:"ZSCORE_threePointersMade"`
	Rebounds               float64 `db:"ZSCORE_rebounds"`
	Turnovers              float64 `db:"ZSCORE_turnovers"`
	Blocks                 float64 `db:"ZSCORE_blocks"`
	Steals                 float64 `db:"ZSCORE_steals"`
	PotentialAssists       float64 `db:"ZSCORE_potentialAssists"`
	Passes                 float64 `db:"ZSCORE_passes"`
	Minutes                float64 `db:"ZSCORE_minutes"`
	HeightInches           float64 `db:"ZSCORE_heightInches"`
	Weight                 float64 `db:"ZSCORE_weight"`
}

func (*StandardizedPlayerStats) CosineSimilarityTo

func (a *StandardizedPlayerStats) CosineSimilarityTo(b StandardizedPlayerStats) float64

func (StandardizedPlayerStats) Field

func (s StandardizedPlayerStats) Field(field string) float64

type Stat

type Stat string
const (
	Points                       Stat = "points"
	Assists                      Stat = "assists"
	Rebounds                     Stat = "rebounds"
	Steals                       Stat = "steals"
	Blocks                       Stat = "blocks"
	ThreePointersMade            Stat = "three_pointers_made"
	ThreePointersAttempted       Stat = "three_pointers_attempted"
	ThreePointPercentage         Stat = "three_point_percentage"
	FreeThrowsMade               Stat = "free_throws_made"
	FreeThrowsAttempted          Stat = "free_throws_attempted"
	FreeThrowsPercentage         Stat = "free_throws_percentage"
	FieldGoalsMade               Stat = "field_goals_made"
	FieldGoalsAttempted          Stat = "field_goals_attempted"
	FieldGoalPercentage          Stat = "field_goal_percentage"
	EffectiveFieldGoalPercentage Stat = "effective_field_goal_percentage"
	TrueShootingPercentage       Stat = "true_shooting_percentage"
	Minutes                      Stat = "minutes"
	OffensiveRebounds            Stat = "offensive_rebounds"
	DefensiveRebounds            Stat = "defensive_rebounds"
	AssistPercentage             Stat = "assist_percentage"
	OffensiveReboundPercentage   Stat = "offensive_rebound_percentage"
	DefensiveReboundPercentage   Stat = "defensive_rebound_percentage"
	Usage                        Stat = "usage"
	Turnovers                    Stat = "turnovers"
	PersonalFouls                Stat = "personal_fouls"
	PersonalFoulsDrawn           Stat = "personal_fouls_drawn"
	PointsReboundsAssists        Stat = "points_rebounds_assists"
	PointsRebounds               Stat = "points_rebounds"
	PointsAssists                Stat = "points_assists"
	ReboundsAssists              Stat = "rebounds_assists"
	BlocksSteals                 Stat = "blocks_steals"
	FantasyScore                 Stat = "fantasy_score"
	GamesPlayed                  Stat = "games_played"
	Height                       Stat = "height"
	Weight                       Stat = "weight"
	DoubleDouble                 Stat = "double_double"
	Passes                       Stat = "passes"
	PotentialAssists             Stat = "potential_assists"
	AssistConversionRate         Stat = "assist_conversion_rate"

	//TeamStats
	GamesWon    Stat = "games_won"
	GamesLost   Stat = "games_lost"
	OppPoints   Stat = "opponent_points"
	OppAssists  Stat = "opponent_assists"
	OppRebounds Stat = "opponent_rebounds"
)

func NewStat

func NewStat(stat string) (Stat, error)

func PlayerAverageStats

func PlayerAverageStats() []Stat

func TeamAverageStats

func TeamAverageStats() []Stat

func (Stat) MarshalGQL

func (s Stat) MarshalGQL(w io.Writer)

func (Stat) SQL

func (s Stat) SQL() (string, error)

func (Stat) String

func (s Stat) String() string

func (*Stat) UnmarshalBSON

func (s *Stat) UnmarshalBSON(data []byte) error

func (*Stat) UnmarshalGQL

func (s *Stat) UnmarshalGQL(v interface{}) error

func (*Stat) UnmarshalJSON

func (s *Stat) UnmarshalJSON(data []byte) error

type StatDistribution

type StatDistribution struct {
	StatType Stat    `json:"statType" bson:"statType"`
	Mean     float64 `db:"mean" json:"mean" bson:"mean"`
	StdDev   float64 `db:"stdDev" json:"stdDev" bson:"stdDev"`
}

type StatFilter

type StatFilter struct {
	Period   *Period  `json:"period"`
	Stat     Stat     `json:"stat"`
	Mode     StatMode `json:"mode"`
	Operator Operator `json:"operator"`
	Value    float64  `json:"value"`
}

func (*StatFilter) MatchGame

func (f *StatFilter) MatchGame(game *PlayerGame) bool

func (*StatFilter) MatchPlayer

func (f *StatFilter) MatchPlayer(player *Player) bool

func (StatFilter) String

func (f StatFilter) String() string

type StatMode

type StatMode string
const (
	StatModePerGame   StatMode = "PER_GAME"
	StatModePer36     StatMode = "PER_36"
	StatModePerMinute StatMode = "PER_MINUTE"
	StatModeTotal     StatMode = "TOTAL"
)

func (StatMode) IsValid

func (e StatMode) IsValid() bool

func (StatMode) MarshalGQL

func (e StatMode) MarshalGQL(w io.Writer)

func (StatMode) String

func (e StatMode) String() string

func (*StatMode) UnmarshalGQL

func (e *StatMode) UnmarshalGQL(v interface{}) error

type StatOfInterest

type StatOfInterest struct {
	Scores []float64
	Stat   Stat
	Mean   float64
	StdDev float64
}

func NewStatOfInterest

func NewStatOfInterest(stat Stat) *StatOfInterest

func (*StatOfInterest) Add

func (s *StatOfInterest) Add(playerAverage PlayerAverage)

func (*StatOfInterest) AddTeam

func (s *StatOfInterest) AddTeam(teamAverage TeamAverage)

func (*StatOfInterest) ZScore

func (s *StatOfInterest) ZScore(playerAverage PlayerAverage) float64

func (*StatOfInterest) ZScoreTeam

func (s *StatOfInterest) ZScoreTeam(teamAverage TeamAverage) float64

type Team

type Team struct {
	Name         string `db:"name" json:"name" bson:"name"`
	TeamID       int    `db:"teamID" json:"teamID" bson:"teamID"`
	Abbreviation string `db:"abbreviation" json:"abbreviation" bson:"abbreviation"`
	Location     string `db:"city" json:"location" bson:"city"`
	// todo: remove this
	NumWins    int         `json:"numWins" bson:"numWins"`
	NumLoss    int         `json:"numLoss" bson:"numLoss"`
	League     string      `db:"league" json:"league" bson:"league"`
	GamesCache []*TeamGame `json:"gamesCache" bson:"gamesCache"`
	CreatedAt  *time.Time  `db:"CreatedAt" json:"CreatedAt" bson:"CreatedAt"`
	UpdatedAt  *time.Time  `db:"UpdatedAt" json:"UpdatedAt" bson:"UpdatedAt"`
}

type TeamAverage

type TeamAverage struct {
	WinsAndLosses      []string `json:"wins_and_losses" bson:"wins_and_losses"`
	GamesPlayed        float64  `json:"games_played" bson:"games_played"`
	GamesWon           float64  `json:"games_won" bson:"games_won"`
	GamesLost          float64  `json:"games_lost" bson:"games_lost"`
	Points             float64  `json:"points" bson:"points"`
	OppPoints          float64  `json:"opponent_points" bson:"opponent_points"`
	Assists            float64  `json:"assists" bson:"assists"`
	OppAssists         float64  `json:"opponent_assists" bson:"opponent_assists"`
	Rebounds           float64  `json:"rebounds" bson:"rebounds"`
	OppRebounds        float64  `json:"opponent_rebounds" bson:"opponent_rebounds"`
	Steals             float64  `json:"steals" bson:"steals"`
	Blocks             float64  `json:"blocks" bson:"blocks"`
	Turnovers          float64  `json:"turnovers" bson:"turnovers"`
	ThreePointersMade  float64  `json:"three_pointers_made" bson:"three_pointers_made"`
	PersonalFouls      float64  `json:"personal_fouls" bson:"personal_fouls"`
	PersonalFoulsDrawn float64  `json:"personal_fouls_drawn" bson:"personal_fouls_drawn"`
	Team               Team     `json:"team" bson:"team"`
}

func NewTeamAverage

func NewTeamAverage(games []*TeamGame, team *Team) TeamAverage

func (*TeamAverage) Difference

func (t *TeamAverage) Difference(fromTeam TeamAverage) TeamDiff

func (*TeamAverage) Normalize

func (t *TeamAverage) Normalize(stats ...StatOfInterest) TeamAverage

func (*TeamAverage) Score

func (t *TeamAverage) Score(stat Stat) float64

type TeamDiff

type TeamDiff TeamAverage

type TeamFilter

type TeamFilter struct {
	Name         *string `json:"name"`
	TeamID       *int    `json:"teamID"`
	Abbreviation *string `json:"abbreviation"`
}

func (*TeamFilter) MongoFilter

func (f *TeamFilter) MongoFilter() bson.M

func (TeamFilter) String

func (f TeamFilter) String() string

type TeamGame

type TeamGame struct {
	Assists                              int     `json:"assists" bson:"assists"`
	Blocks                               int     `json:"blocks" bson:"blocks"`
	Date                                 string  `json:"date" bson:"date"`
	DefensiveRating                      float64 `json:"defensive_rating" bson:"defensive_rating"`
	DefensiveRebounds                    int     `json:"defensive_rebounds" bson:"defensive_rebounds"`
	DefensiveReboundPercentage           float64 `json:"defensive_rebound_percentage" bson:"defensive_rebound_percentage"`
	FieldGoalPercentage                  float64 `json:"field_goal_percentage" bson:"field_goal_percentage"`
	FieldGoalsAttempted                  int     `json:"field_goals_attempted" bson:"field_goals_attempted"`
	FieldGoalsMade                       int     `json:"field_goals_made" bson:"field_goals_made"`
	FreeThrowsAttempted                  int     `json:"free_throws_attempted" bson:"free_throws_attempted"`
	FreeThrowsMade                       int     `json:"free_throws_made" bson:"free_throws_made"`
	FreeThrowsPercentage                 float64 `json:"free_throws_percentage" bson:"free_throws_percentage"`
	GameID                               string  `json:"gameID" bson:"gameID"`
	HomeOrAway                           string  `json:"home_or_away" bson:"home_or_away"`
	Margin                               int     `json:"margin" bson:"margin"`
	OffensiveRebounds                    int     `json:"offensive_rebounds" bson:"offensive_rebounds"`
	OffensiveReboundPercentage           float64 `json:"offensive_rebound_percentage" bson:"offensive_rebound_percentage"`
	TeamID                               int     `json:"teamID" bson:"teamID"`
	OpponentID                           int     `json:"opponent" bson:"opponent"`
	OpponentAssists                      int     `json:"opponent_assists" bson:"opponent_assists"`
	OpponentEffectiveFieldGoalPercentage float64 `json:"opponent_effective_field_goal_percentage" bson:"opponent_effective_field_goal_percentage"` //get from opponent's game
	OpponentFieldGoalsAttempted          int     `json:"opponent_field_goals_attempted" bson:"opponent_field_goals_attempted"`                     //get from opponent's game
	OpponentFreeThrowsAttempted          int     `json:"opponent_free_throws_attempted" bson:"opponent_free_throws_attempted"`                     //get from opponent's game
	OpponentPoints                       int     `json:"opponent_points" bson:"opponent_points"`                                                   //get from opponent's game
	OpponentRebounds                     int     `json:"opponent_rebounds" bson:"opponent_rebounds"`                                               //get from opponent's game
	OpponentThreePointersAttempted       int     `json:"opponent_three_pointers_attempted" bson:"opponent_three_pointers_attempted"`
	OpponentThreePointersMade            int     `json:"opponent_three_pointers_made" bson:"opponent_three_pointers_made"`
	PlusMinusPerHundred                  float64 `json:"plus_minus_per_hundred" bson:"plus_minus_per_hundred"`
	Points                               int     `json:"points" bson:"points"`
	Playoffs                             bool    `json:"playoffs" bson:"playoffs"`
	Possessions                          int     `json:"possessions" bson:"possessions"`
	PersonalFouls                        int     `json:"personal_fouls" bson:"personal_fouls"`
	PersonalFoulsDrawn                   int     `json:"personal_fouls_drawn" bson:"personal_fouls_drawn"` //get from opponent's game
	Rebounds                             int     `json:"rebounds" bson:"rebounds"`
	Season                               string  `json:"season" bson:"season"`
	Steals                               int     `json:"steals" bson:"steals"`
	ThreePointersAttempted               int     `json:"three_pointers_attempted" bson:"three_pointers_attempted"`
	ThreePointersMade                    int     `json:"three_pointers_made" bson:"three_pointers_made"`
	Turnovers                            int     `json:"turnovers" bson:"turnovers"`
	WinOrLoss                            string  `json:"win_or_loss" bson:"win_or_loss"`
}

func (TeamGame) String

func (t TeamGame) String() string

type TeamSimilarityMatrix

type TeamSimilarityMatrix struct {
	Matrix map[int]TeamSimilarityVector
}

func NewTeamSimilarityMatrix

func NewTeamSimilarityMatrix(teams []TeamAverage) *TeamSimilarityMatrix

func (*TeamSimilarityMatrix) AddNormalizedTeams

func (m *TeamSimilarityMatrix) AddNormalizedTeams(teams []TeamAverage)

func (*TeamSimilarityMatrix) AddTeam

func (m *TeamSimilarityMatrix) AddTeam(teamID int, teamAverage TeamAverage) error

AddTeam adds a team to the matrix and calculates the comparisons between the new team and the existing teams.

func (*TeamSimilarityMatrix) AddTeams

func (m *TeamSimilarityMatrix) AddTeams(teams []TeamAverage) error

func (*TeamSimilarityMatrix) CompareAverages

func (m *TeamSimilarityMatrix) CompareAverages(in int, averageIn TeamAverage) map[int]TeamDiff

func (*TeamSimilarityMatrix) GetNearestTeams

func (m *TeamSimilarityMatrix) GetNearestTeams(toTeam int, limit int, statsOfInterest []Stat) (similarTeams []*Team, err error)

type TeamSimilarityVector

type TeamSimilarityVector struct {
	//Comparisons show the difference between the average of this player and the average of other players (e.g. thisPlayer.points - otherPlayer.points)
	Comparisons map[int]TeamDiff
	//Average is the average stats of this player, so that they can be compared to other (new) players
	Average TeamAverage
}

func (*TeamSimilarityVector) GetNearest

func (v *TeamSimilarityVector) GetNearest(limit int, statsOfInterest []Stat) []TeamDiff

type TeamSnapshots

type TeamSnapshots map[string]TeamSimilarityMatrix

func NewTeamSnapshots

func NewTeamSnapshots() *TeamSnapshots

func (*TeamSnapshots) AddSnapshot

func (s *TeamSnapshots) AddSnapshot(startDate, endDate time.Time, teams []*Team)

func (*TeamSnapshots) GetSimilarTeams

func (s *TeamSnapshots) GetSimilarTeams(teamID, limit int, startDate, endDate string, statsOfInterest []Stat) []*Team

func (*TeamSnapshots) Key

func (m *TeamSnapshots) Key(startDate, endDate string) string

type UnderdogAppearance

type UnderdogAppearance struct {
	PlayerID     string `json:"player_id"`
	AppearanceID string `json:"id"`
}

type UnderdogFantasy

type UnderdogFantasy struct {
	Players        []UnderdogPlayer        `json:"players"`
	Appearances    []UnderdogAppearance    `json:"appearances"`
	OverUnderLines []UnderdogOverUnderLine `json:"over_under_lines"`
	Games          []UnderdogGame          `json:"games"`
}

type UnderdogGame

type UnderdogGame struct {
	AwayTeamID string `json:"away_team_id"`
	HomeTeamID string `json:"home_team_id"`
	Title      string `json:"title"`
	StartTime  string `json:"scheduled_at"`
}

type UnderdogOverUnderLine

type UnderdogOverUnderLine struct {
	OverUnder struct {
		Appearance struct {
			AppearanceID string `json:"appearance_id"`
			Category     string `json:"stat"`
		} `json:"appearance_stat"`
	} `json:"over_under"`

	Target string `json:"stat_value"`
}

type UnderdogPlayer

type UnderdogPlayer struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	PlayerID  string `json:"id"`
	Sport     string `json:"sport_id"`
	TeamID    string `json:"team_id"`
}

type Wager

type Wager string
const (
	WagerOver  Wager = "OVER"
	WagerUnder Wager = "UNDER"
)

func PValue

func PValue(estimation float64, stddev float64, target float64) (float64, Wager)

func (Wager) IsValid

func (e Wager) IsValid() bool

func (Wager) MarshalGQL

func (e Wager) MarshalGQL(w io.Writer)

func (Wager) String

func (e Wager) String() string

func (*Wager) UnmarshalGQL

func (e *Wager) UnmarshalGQL(v interface{}) error

type WagerOutcome

type WagerOutcome string
const (
	WagerOutcomeHit     WagerOutcome = "HIT"
	WagerOutcomeMiss    WagerOutcome = "MISS"
	WagerOutcomePush    WagerOutcome = "PUSH"
	WagerOutcomePending WagerOutcome = "PENDING"
)

func (WagerOutcome) IsValid

func (e WagerOutcome) IsValid() bool

func (WagerOutcome) MarshalGQL

func (e WagerOutcome) MarshalGQL(w io.Writer)

func (WagerOutcome) String

func (e WagerOutcome) String() string

func (*WagerOutcome) UnmarshalGQL

func (e *WagerOutcome) UnmarshalGQL(v interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL