Documentation
¶
Index ¶
- Variables
- func Load538GenericBallot() float64
- func Load538GovForecast() (forecast_538 map[string]float64, parties_538 map[string]map[string]string)
- func Load538HouseElasticities() map[string]float64
- func Load538HouseForecast() (forecast_538 map[string]float64, parties_538 map[string]map[string]string, ...)
- func Load538Polls() (polls_538_senate, polls_538_house, polls_538_gov map[string][]Poll)
- func Load538SenateElasticities() map[string]float64
- func Load538SenateForecast() (forecast_538 map[string]float64, parties_538 map[string]map[string]string)
- func Load2016SenatePolls() map[string][]Poll
- func LoadCNNGovResults(year string) map[string][2]float64
- func LoadCNNHouseForecast() map[string]float64
- func LoadCNNHouseResults(year string) map[string][2]float64
- func LoadCNNSenateForecast() map[string]float64
- func LoadCNNSenateResults(year string) map[string][2]float64
- func LoadCache(url, file string, maxAge time.Duration, parser func(r io.Reader) interface{}) interface{}
- func LoadCookGovRatingsHtml(id uint64) (ratings map[string][2]float64, incumbents map[string]string, ...)
- func LoadCookHouseRatingsHtml(id uint64) (ratings map[string][2]float64, incumbents map[string]string, ...)
- func LoadCookRatings(file string) (ratings []map[string]string)
- func LoadCookSenateRatingsHtml(id uint64) (ratings map[string][2]float64, incumbents map[string]string, ...)
- func LoadFECRaces(office string, year int) map[string]float64
- func LoadFECRacesOld(office string, year int) map[string]float64
- func LoadNYTHouseResults(year string) map[string][2]float64
- func LoadNYTLivePolls() (housePolls, senatePolls map[string][]Poll)
- func LoadNYTSenateResults(year string) map[string][2]float64
- func LoadOpenSecretsRace(mode, st string) map[string]float64
- type CNNForecast
- type CNNForecastDistrict
- type CNNForecastHistory
- type CNNForecastPrediction
- type CNNForecastRaceDetails
- type CNNForecastSeat
- type CNNForecastTopline
- type CNNForecastToplineHistory
- type CandidateForecast538
- type DistrictForecast538
- type Forecast538
- type GenericBallot538
- type GenericEstimate538
- type ModelForecast538
- type ModelForecasts538
- type SeatForecast538
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Pre-computed in historical_optimize.go COOK_WEIGHT = 302.0708670497893 COOK_PVI_WEIGHT = 0.3588032283134363 CookConfidence = [][2]float64{{0.67, 0.33}, {0.56, 0.44}, {0.535, 0.465}, {0.5, 0.5}, {0.5, 0.5}, {0.465, 0.535}, {0.44, 0.56}, {0.33, 0.67}} // Based on 538's analysis of expert forecast margins )
View Source
var (
FEC_API_KEY = "DEMO_KEY" // Allows 40 API calls per time period, we only need 27, but you can set this if you like
)
View Source
var (
USStateAbbrev = map[string]string{
"Alabama": "AL",
"Alaska": "AK",
"Arizona": "AZ",
"Arkansas": "AR",
"California": "CA",
"Colorado": "CO",
"Connecticut": "CT",
"Delaware": "DE",
"Florida": "FL",
"Georgia": "GA",
"Hawaii": "HI",
"Idaho": "ID",
"Illinois": "IL",
"Indiana": "IN",
"Iowa": "IA",
"Kansas": "KS",
"Kentucky": "KY",
"Louisiana": "LA",
"Maine": "ME",
"Maryland": "MD",
"Massachusetts": "MA",
"Michigan": "MI",
"Minnesota": "MN",
"Mississippi": "MS",
"Missouri": "MO",
"Montana": "MT",
"Nebraska": "NE",
"Nevada": "NV",
"New Hampshire": "NH",
"New Jersey": "NJ",
"New Mexico": "NM",
"New York": "NY",
"North Carolina": "NC",
"North Dakota": "ND",
"Ohio": "OH",
"Oklahoma": "OK",
"Oregon": "OR",
"Pennsylvania": "PA",
"Rhode Island": "RI",
"South Carolina": "SC",
"South Dakota": "SD",
"Tennessee": "TN",
"Texas": "TX",
"Utah": "UT",
"Vermont": "VT",
"Virginia": "VA",
"Washington": "WA",
"West Virginia": "WV",
"Wisconsin": "WI",
"Wyoming": "WY",
}
)
Functions ¶
func Load538GenericBallot ¶
func Load538GenericBallot() float64
func Load538GovForecast ¶
func Load538HouseForecast ¶
func Load538Polls ¶
func Load538Polls() (polls_538_senate, polls_538_house, polls_538_gov map[string][]Poll)
func Load538SenateForecast ¶
func Load2016SenatePolls ¶
func Load2016SenatePolls() map[string][]Poll
func LoadCNNGovResults ¶
func LoadCNNHouseForecast ¶
func LoadCNNHouseResults ¶
func LoadCNNSenateForecast ¶
func LoadCNNSenateResults ¶
func LoadCookGovRatingsHtml ¶
func LoadCookRatings ¶
func LoadFECRacesOld ¶
Apparently this is missing about 30% of candidates for some fucking reason. Good job, FEC. Instead, use the bulk zip file above.
func LoadNYTHouseResults ¶
func LoadNYTLivePolls ¶
func LoadNYTLivePolls() (housePolls, senatePolls map[string][]Poll)
Load ongoing polls from https://www.nytimes.com/interactive/2018/upshot/elections-polls.html Partial data is better than no data
func LoadOpenSecretsRace ¶
Not used. Using FEC instead
Types ¶
type CNNForecast ¶
type CNNForecast struct {
Topline CNNForecastTopline `json:"topline"`
Competitive []CNNForecastRaceDetails `json:"competitive"`
Swing []CNNForecastRaceDetails `json:"swing"`
Districts []CNNForecastDistrict `json:"districts"`
Seats []CNNForecastSeat `json:"seats"`
LastUpdatedEDT string `json:"lastUpdatedEDT"`
}
type CNNForecastDistrict ¶
type CNNForecastDistrict struct {
ID string `json:"id"`
State string `json:"state"`
District string `json:"district"`
Prediction float64 `json:"prediction"`
LowMargin float64 `json:"lowMargin"`
HiMargin float64 `json:"hiMargin"`
Rcand string `json:"rcand,omitempty"`
Rlast string `json:"rlast,omitempty"`
Dcand string `json:"dcand,omitempty"`
Dlast string `json:"dlast,omitempty"`
}
type CNNForecastHistory ¶
type CNNForecastPrediction ¶
type CNNForecastRaceDetails ¶
type CNNForecastRaceDetails struct {
ID string `json:"id"`
State string `json:"state"`
District string `json:"district"`
Prediction float64 `json:"prediction"`
LowMargin float64 `json:"lowMargin"`
HiMargin float64 `json:"hiMargin"`
Predictions []CNNForecastPrediction `json:"predictions"`
LastHouseResultDemocraticMargin float64 `json:"last_house_result_democratic_margin"`
UnopposedPrior bool `json:"unopposedPrior"`
ExcludedCurrent bool `json:"excludedCurrent"`
}
type CNNForecastSeat ¶
type CNNForecastSeat struct {
Seat string `json:"seat"`
LowMargin float64 `json:"lowMargin"`
Prediction float64 `json:"prediction"`
HiMargin float64 `json:"hiMargin"`
History []CNNForecastHistory `json:"history"`
Predictions []CNNForecastPrediction `json:"predictions"`
Dcand string `json:"dcand,omitempty"`
Dlast string `json:"dlast,omitempty"`
Rcand string `json:"rcand,omitempty"`
Rlast string `json:"rlast,omitempty"`
Dcand2 string `json:"dcand2"`
Icand string `json:"icand,omitempty"`
Ilast string `json:"ilast,omitempty"`
}
type CNNForecastTopline ¶
type CNNForecastTopline struct {
Timestamp string `json:"timestamp"`
Party string `json:"party"`
MarginHigh float64 `json:"marginHigh"`
MarginWin float64 `json:"marginWin"`
MarginLow float64 `json:"marginLow"`
DaysOut int `json:"daysOut"`
Race string `json:"race"`
Predictions []CNNForecastPrediction `json:"predictions"`
History []CNNForecastToplineHistory `json:"history"`
}
type CNNForecastToplineHistory ¶
type CNNForecastToplineHistory struct {
CNNForecastHistory
DaysOut int `json:"daysOut"`
}
type CandidateForecast538 ¶
type CandidateForecast538 struct {
Candidate string `json:"candidate"`
Party string `json:"party"`
Date string `json:"date"`
Models ModelForecasts538 `json:"models"`
}
type DistrictForecast538 ¶
type DistrictForecast538 struct {
State string `json:"state"`
District string `json:"district"`
Forecast []CandidateForecast538 `json:"forecast"`
}
type Forecast538 ¶
type Forecast538 struct {
//CongressPartySplits []CongressPartySplit538 `json:"congress_party_splits"`
//SeatChances []SeatChance538 `json:"seat_chances"`
//NationalTrends []NationalTrend538 `json:"nationalTrends"`
DistrictForecasts []DistrictForecast538 `json:"districtForecasts"` // House
SeatForecasts []SeatForecast538 `json:"seatForecasts"` // Senate
}
type GenericBallot538 ¶
type GenericBallot538 struct {
Date string `json:"date"`
Subgroup string `json:"subgroup"`
Revised GenericEstimate538 `json:"revised"`
Original GenericEstimate538 `json"original"`
}
type GenericEstimate538 ¶
type ModelForecast538 ¶
type ModelForecasts538 ¶
type ModelForecasts538 struct {
Lite ModelForecast538 `json:"lite"`
Classic ModelForecast538 `json:"classic"`
Deluxe ModelForecast538 `json:"deluxe"`
}
type SeatForecast538 ¶
type SeatForecast538 struct {
State string `json:"state"`
Class int `json:"class"`
Forecast []CandidateForecast538 `json:"forecast"`
}
Click to show internal directories.
Click to hide internal directories.