rankings

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package rankings calculates the alternative rankings of a league based on data obtained from a fantasy sports provider.

Index

Constants

This section is empty.

Variables

View Source
var MinimizeAPICalls = true

MinimizeAPICalls to the fantasy sports provider, whenever possible

View Source
var Types = struct {
	// SCORE represents a rankings scheme that uses points to compare teams
	SCORE string

	// RECORD represents a rankings scheme that uses a win/loss/tie record to
	// compare teams
	RECORD string
}{
	"score",
	"record",
}

Types contains the various types of ranking schemes offered by this package.

Functions

func GetWeeklyRanking

func GetWeeklyRanking(
	client PowerRankingsClient,
	leagueKey string,
	week int,
	results chan *WeeklyRanking,
	errors chan error,
	projection bool,
	schemes []Scheme)

GetWeeklyRanking returns a league's rankings for a specific week

func GetWeeklyRankingFromMatchups added in v0.4.0

func GetWeeklyRankingFromMatchups(
	week int,
	matchups []goff.Matchup,
	results chan *WeeklyRanking,
	schemes []Scheme)

GetWeeklyRankingFromMatchups rankings teams for a given week using matchups

Types

type LeaguePowerData

type LeaguePowerData struct {
	RankingScheme     Scheme
	OverallRankings   []*TeamPowerData
	ProjectedRankings []*TeamPowerData
	ByTeam            map[string]*TeamPowerData
	ByWeek            []*WeeklyRanking
}

LeaguePowerData for an entire league over the course of multiple weeks

func GetPowerData

func GetPowerData(client PowerRankingsClient, l *goff.League, currentWeek int) ([]*LeaguePowerData, error)

GetPowerData returns a league's power rankings up to the given week and projections until the end of the season.

type PowerRankings

type PowerRankings []*TeamPowerData

PowerRankings ranks teams based on their performance over multiple weeks

func (PowerRankings) Len

func (p PowerRankings) Len() int

func (PowerRankings) Less

func (p PowerRankings) Less(i, j int) bool

func (PowerRankings) Swap

func (p PowerRankings) Swap(i, j int)

type PowerRankingsClient

type PowerRankingsClient interface {
	GetAllTeamStats(leagueKey string, week int, projection bool) ([]goff.Team, error)
	GetLeagueStandings(leagueKey string) (*goff.League, error)
	GetMatchupsForWeekRange(leagueKey string, startWeek, endWeek int) (map[int][]goff.Matchup, error)
}

PowerRankingsClient calculates the power rankings from a fantasy football statistics provider.

type PowerSortedTeamRankingsData added in v0.4.0

type PowerSortedTeamRankingsData []*TeamRankingData

PowerSortedTeamRankingsData allows information about how teams ranked for a week to be sorted by their power scores

func (PowerSortedTeamRankingsData) Len added in v0.4.0

func (PowerSortedTeamRankingsData) Less added in v0.4.0

func (s PowerSortedTeamRankingsData) Less(i, j int) bool

func (PowerSortedTeamRankingsData) Swap added in v0.4.0

func (s PowerSortedTeamRankingsData) Swap(i, j int)

type ProjectedPowerRankings added in v0.2.0

type ProjectedPowerRankings []*TeamPowerData

ProjectedPowerRankings ranks teams based on their combined actual and projected performance over multiple weeks

func (ProjectedPowerRankings) Len added in v0.2.0

func (p ProjectedPowerRankings) Len() int

func (ProjectedPowerRankings) Less added in v0.2.0

func (p ProjectedPowerRankings) Less(i, j int) bool

func (ProjectedPowerRankings) Swap added in v0.2.0

func (p ProjectedPowerRankings) Swap(i, j int)

type ProjectedRecordRankings added in v0.4.0

type ProjectedRecordRankings []*TeamPowerData

ProjectedRecordRankings ranks teams based on their combined actual and projected performance over multiple weeks

func (ProjectedRecordRankings) Len added in v0.4.0

func (p ProjectedRecordRankings) Len() int

func (ProjectedRecordRankings) Less added in v0.4.0

func (p ProjectedRecordRankings) Less(i, j int) bool

func (ProjectedRecordRankings) Swap added in v0.4.0

func (p ProjectedRecordRankings) Swap(i, j int)

type RecordRankings added in v0.4.0

type RecordRankings []*TeamPowerData

RecordRankings ranks teams based on their performance over multiple weeks

func (RecordRankings) Len added in v0.4.0

func (p RecordRankings) Len() int

func (RecordRankings) Less added in v0.4.0

func (p RecordRankings) Less(i, j int) bool

func (RecordRankings) Swap added in v0.4.0

func (p RecordRankings) Swap(i, j int)

type RecordSortedTeamRankingsData added in v0.4.0

type RecordSortedTeamRankingsData []*TeamRankingData

RecordSortedTeamRankingsData allows information about how teams ranked for a week to be sorted by their records

func (RecordSortedTeamRankingsData) Len added in v0.4.0

func (RecordSortedTeamRankingsData) Less added in v0.4.0

func (s RecordSortedTeamRankingsData) Less(i, j int) bool

func (RecordSortedTeamRankingsData) Swap added in v0.4.0

func (s RecordSortedTeamRankingsData) Swap(i, j int)

type Scheme added in v0.4.0

type Scheme interface {
	ID() string
	DisplayName() string
	Type() string
	CalculateWeeklyRankings(
		week int,
		teams []goff.Team,
		projected bool,
		results chan *WeeklyRanking)
}

A Scheme is a way to rank teams based on their weekly performance

func GetSchemes added in v0.4.0

func GetSchemes() []Scheme

GetSchemes returns the supported rankings formats

type TeamPowerData

type TeamPowerData struct {
	Team                   *goff.Team
	Rank                   int
	ProjectedRank          int
	TotalScore             float64
	ProjectedTotalScore    float64
	OverallRecord          *goff.Record
	ProjectedOverallRecord *goff.Record
	AllRankings            []*TeamRankingData
	AllScores              []*TeamScoreData
	HasProjections         bool
}

TeamPowerData describes how a team performed in the power rankings

type TeamProjectedRanking added in v0.2.0

type TeamProjectedRanking []goff.Team

TeamProjectedRanking ranks teams based on their projected performance for a single week

func (TeamProjectedRanking) Len added in v0.2.0

func (t TeamProjectedRanking) Len() int

func (TeamProjectedRanking) Less added in v0.2.0

func (t TeamProjectedRanking) Less(i int, j int) bool

func (TeamProjectedRanking) Swap added in v0.2.0

func (t TeamProjectedRanking) Swap(i int, j int)

type TeamRanking

type TeamRanking []goff.Team

TeamRanking ranks teams based on their performance for a single week

func (TeamRanking) Len

func (t TeamRanking) Len() int

func (TeamRanking) Less

func (t TeamRanking) Less(i int, j int) bool

func (TeamRanking) Swap

func (t TeamRanking) Swap(i int, j int)

type TeamRankingData added in v0.3.0

type TeamRankingData struct {
	Week      int
	Rank      int
	Score     float64
	Record    *goff.Record
	Projected bool
}

TeamRankingData describes how a team was ranked in comparison to their peer through a particular week of the season.

type TeamScoreData

type TeamScoreData struct {
	Team         *goff.Team
	FantasyScore float64
	Rank         int
	PowerScore   float64
	Record       *goff.Record
	Projected    bool
}

TeamScoreData describes the score information for a single team

type WeeklyRanking

type WeeklyRanking struct {
	Scheme    Scheme
	Week      int
	Rankings  []*TeamScoreData
	Projected bool
}

WeeklyRanking of teams based on their performance for a specific week

Jump to

Keyboard shortcuts

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