static void Main(string[] args) { InitializeLog4net(); // Cargamos la configuracion Log.Info("Cargando configuracion"); Configuration configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(@"./Configuration.json")); // Cargamos nombres de equipos Log.Info("Cargando nombres de equipos de 'TeamsNames.json'"); var jObject = JObject.Parse(File.ReadAllText(@"./TeamsNames.json")); var jToken = jObject.GetValue("TeamsNames"); Teams.TeamsNames = (Dictionary <string, List <string> >)jToken.ToObject(typeof(Dictionary <string, List <string> >)); Log.Info($"Se han cargado {Teams.TeamsNames.Values.Sum(x => x.Count) } nombres de equipos"); QuinEagleCalculator qc = new QuinEagleCalculator() { configuration = configuration }; qc.Configure(); // Cargamos los emparejamientos Log.Info("Cargando Emparejamientos"); FixtureRequester fr = new FixtureRequester() { QuinielaFixtureURL = configuration.QuinielaFixtureURL }; fr.LoadFixtures(); var fixtures = fr.GetFixtures(); fr.PrintFixtures(); List <Fixture> predictions = new List <Fixture>(); fixtures.ForEach(a => { QuinielaResult qr = QuinielaResult.VOID; Fixture f = new Fixture() { AwayTeam = a.AwayTeam, HomeTeam = a.HomeTeam }; f.Probability = qc.GetResult(a, out qr); f.Result = qr; predictions.Add(f); }); qc.SetMaxDoubleBets(ref predictions); predictions.ForEach(a => Log.Info(a.ToString())); Log.Info($"Media calculada = {predictions.Select( a => a.Probability ).Average()}%"); Console.ReadKey(); }
/// <param name="args"></param> public static void Main(string[] args) { // Log4Net InitializeLog4net(); // Cargamos la configuracion Log.Info("Cargando configuracion"); Configuration configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText(@"./Configuration.json")); // Cargamos nombres de equipos Log.Info("Cargando nombres de equipos de 'TeamsNames.json'"); var jObject = JObject.Parse(File.ReadAllText(@"./TeamsNames.json")); var jToken = jObject.GetValue("TeamsNames"); Teams.TeamsNames = (Dictionary <string, List <string> >)jToken.ToObject(typeof(Dictionary <string, List <string> >)); Log.Info($"Se han cargado {Teams.TeamsNames.Values.Sum(x => x.Count) } nombres de equipos"); QuinEagleCalculator qc = new QuinEagleCalculator() { configuration = configuration }; qc.Configure(); // Cargamos todos los partidos en una lista List <Match> matches = _getMatchesStoredDB(qc); // Seleccionamos todas las jornadas y años que tenemos partidos //List<JourneyDateClassification> journeys = matches.Select(a => new JourneyDateClassification(){ journey = a.Journey, season = a.season }) // .Distinct(new JourneyDateClassification.DistinctJourneyDateClassificationComparer()) // .ToList(); // Cogemos todas las clasificaciones y las almacenamos para estas jornadas de estos años //Dictionary<int, Dictionary<LeagueEnum, LeagueTable>> classifications = _getClassifications(journeys, configuration); List <Match> predictions = new List <Match>(); matches.ForEach(m => { Match match = m.Clone(); QuinielaResult qr = QuinielaResult.VOID; match.fixture.Probability = qc.GetResult(m.fixture, out qr); match.fixture.Result = qr; predictions.Add(match); }); /* * int aciertos = matches.Where(a => predictions.Any( * b => b.fixture.AwayTeam == a.fixture.AwayTeam && * b.fixture.HomeTeam == a.fixture.HomeTeam && * b.fixture.Journey == a.fixture.Journey && * (b.fixture.Result & a.fixture.Result) != QuinielaResult.VOID)).Count(); */ var aciertos = predictions.Where(a => matches.Any( b => b.fixture.AwayTeam == a.fixture.AwayTeam && b.fixture.HomeTeam == a.fixture.HomeTeam && b.fixture.Journey == a.fixture.Journey && (b.fixture.Result & a.fixture.Result) != QuinielaResult.VOID)).ToList(); Log.Info("TOTALES"); Log.Info(matches.Count); Log.Info($"1: {matches.Count( a => a.fixture.Result == QuinielaResult.ONE )} || {( float )matches.Count( a => a.fixture.Result == QuinielaResult.ONE ) / ( float )matches.Count * 100f } %"); Log.Info($"X: {matches.Count( a => a.fixture.Result == QuinielaResult.X )} || {( float )matches.Count( a => a.fixture.Result == QuinielaResult.X ) / ( float )matches.Count * 100f } %"); Log.Info($"2: {matches.Count( a => a.fixture.Result == QuinielaResult.TWO )} || {( float )matches.Count( a => a.fixture.Result == QuinielaResult.TWO ) / ( float )matches.Count * 100f } %"); Log.Info("---------------"); Log.Info("PREDICCIONES"); Log.Info($"1: {predictions.Count( a => a.fixture.Result == QuinielaResult.ONE )} || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.ONE ) / ( float )predictions.Count * 100f } %"); Log.Info($"X: {predictions.Count( a => a.fixture.Result == QuinielaResult.X )} || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.X ) / ( float )predictions.Count * 100f } %"); Log.Info($"2: {predictions.Count( a => a.fixture.Result == QuinielaResult.TWO )} || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.TWO ) / ( float )predictions.Count * 100f } %"); Log.Info("---------------"); Log.Info($"Aciertos {aciertos.Count} de {predictions.Count}"); Log.Info($"Total: {(float)aciertos.Count / (float)predictions.Count * 100f} %"); Log.Info("Aciertos por prediccion"); Log.Info($"1: {aciertos.Count( a => a.fixture.Result == QuinielaResult.ONE )} || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.ONE ) / ( float )aciertos.Count * 100f } %"); Log.Info($"X: {aciertos.Count( a => a.fixture.Result == QuinielaResult.X )} || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.X ) / ( float )aciertos.Count * 100f } %"); Log.Info($"2: {aciertos.Count( a => a.fixture.Result == QuinielaResult.TWO )} || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.TWO ) / ( float )aciertos.Count * 100f } %"); Log.Info("---------------"); Log.Info("Aciertos por predicciones"); Log.Info($"1: {aciertos.Count( a => a.fixture.Result == QuinielaResult.ONE )} aciertos de {predictions.Count(a => (a.fixture.Result & QuinielaResult.ONE) != QuinielaResult.VOID)} predicciones || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.ONE ) / ( float )predictions.Count( a => ( a.fixture.Result & QuinielaResult.ONE ) != QuinielaResult.VOID ) * 100f } %"); Log.Info($"X: {aciertos.Count( a => a.fixture.Result == QuinielaResult.X )} aciertos de {predictions.Count( a => ( a.fixture.Result & QuinielaResult.X ) != QuinielaResult.VOID )} predicciones || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.X ) / ( float )predictions.Count( a => ( a.fixture.Result & QuinielaResult.X ) != QuinielaResult.VOID ) * 100f } %"); Log.Info($"2: {aciertos.Count( a => a.fixture.Result == QuinielaResult.TWO )} aciertos de {predictions.Count( a => ( a.fixture.Result & QuinielaResult.TWO ) != QuinielaResult.VOID )} predicciones || {( float )aciertos.Count( a => a.fixture.Result == QuinielaResult.TWO ) / ( float )predictions.Count( a => ( a.fixture.Result & QuinielaResult.TWO ) != QuinielaResult.VOID ) * 100f } %"); Log.Info("---------------"); Log.Info("Predicciones por resultado real"); Log.Info($"1: {predictions.Count( a => (a.fixture.Result & QuinielaResult.ONE) != QuinielaResult.VOID)} predicciones de {matches.Count( a => a.fixture.Result == QuinielaResult.ONE )} resultados reales || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.ONE ) / ( float )matches.Count( a => a.fixture.Result == QuinielaResult.ONE ) * 100f } %"); Log.Info($"X: {predictions.Count( a => ( a.fixture.Result & QuinielaResult.X ) != QuinielaResult.VOID )} predicciones de {matches.Count( a => a.fixture.Result == QuinielaResult.X )} resultados reales || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.X ) / ( float )matches.Count( a => a.fixture.Result == QuinielaResult.X ) * 100f } %"); Log.Info($"2: {predictions.Count( a => ( a.fixture.Result & QuinielaResult.TWO ) != QuinielaResult.VOID )} predicciones de {matches.Count( a => a.fixture.Result == QuinielaResult.TWO )} resultados reales || {( float )predictions.Count( a => a.fixture.Result == QuinielaResult.TWO ) / ( float )matches.Count( a => a.fixture.Result == QuinielaResult.TWO ) * 100f } %"); Log.Debug("---------------"); Log.Debug("Valores de 1s"); var Puntos1 = predictions.Where(a => matches.Any(b => b.fixture.AwayTeam == a.fixture.AwayTeam && b.fixture.HomeTeam == a.fixture.HomeTeam && b.fixture.Journey == a.fixture.Journey && b.fixture.Result == QuinielaResult.ONE)).ToList();; Puntos1.ForEach(a => Log.Debug(a.fixture.Probability)); Log.Debug("---------------"); Log.Debug("Valores de Xs"); var PuntosX = predictions.Where(a => matches.Any(b => b.fixture.AwayTeam == a.fixture.AwayTeam && b.fixture.HomeTeam == a.fixture.HomeTeam && b.fixture.Journey == a.fixture.Journey && b.fixture.Result == QuinielaResult.X)).ToList();; PuntosX.ForEach(a => Log.Debug(a.fixture.Probability)); Log.Debug("---------------"); Log.Debug("Valores de 2s"); var Puntos2 = predictions.Where(a => matches.Any(b => b.fixture.AwayTeam == a.fixture.AwayTeam && b.fixture.HomeTeam == a.fixture.HomeTeam && b.fixture.Journey == a.fixture.Journey && b.fixture.Result == QuinielaResult.TWO)).ToList();; Puntos2.ForEach(a => Log.Debug(a.fixture.Probability)); Console.ReadKey(); }