private void RecalculateBattingAverage(Batter batter, DateTime gameDate) { if (!_pickerOptions.OptionOn(Constants.Options.HotBatters)) { return; } var oldAvg = batter.BattingAverage; // calculate BAV for the period var queryDate = gameDate.AddDays(-1); var statsTo = _playerStatsRepository.Submit( queryDate, batter.PlayerSlug); var statsFrom = _playerStatsRepository.Submit( queryDate.AddDays(-_pickerOptions.IntegerOption( Constants.Options.HotBattersDaysBack)), batter.PlayerSlug); batter.BattingAverage = BattingAverage(statsFrom, statsTo); #if DEBUG Console.WriteLine($@" bavg for { batter.PlayerSlug,-25 } was {oldAvg:#.000} now calculated as {batter.BattingAverage:#.000}" ); #endif }
public bool Likes(Selection selection, out string reasonForDislike) { reasonForDislike = string.Empty; if (!_pickerOptions.OptionOn(Constants.Options.HotBatters)) { return(true); } if (selection.Batter.BattingAverage > _pickerOptions.DecimalOption( Constants.Options.HotBattersMendozaLine)) { return(true); } reasonForDislike = $" {selection.Batter.PlayerSlug} Batting Avg too low"; return(false); }