Exemple #1
0
        private static void InitializeBetSetter()
        {
            while (true)
            {
                foreach (var watchedLiveGame in watchedLiveGames)
                {
                    BettingAlgorithms.TwoPointO(watchedLiveGame, favouriteMaxDecimal);
                }

                Thread.Sleep(betsetterRefreshMilliseconds);
            }
        }
Exemple #2
0
        private static void Evaluator()
        {
            while (true)
            {
                Console.WriteLine("Evaluating bets");

                var pendingBets = BettingAlgorithms.GetPending().Result;

                if (!pendingBets.Any())
                {
                    Console.WriteLine("No bets to evaluate");
                }

                Console.WriteLine();

                var bla = new List <string>();

                foreach (var bet in pendingBets)
                {
                    if (watchedLiveGames.Any(input => input.CustomId == bet.CustomId))
                    {
                        continue;
                    }

                    var dateSplit = bet.DatePlaced.Split("-");

                    var url = $"https://www.sofascore.com/{bet.Sport.ToLower()}//{dateSplit[0]}-{dateSplit[1]}-{dateSplit[2]}/json";

                    bla.Add(url);

                    using WebClient webClient = new WebClient();

                    var gamesForDate = webClient.DownloadString(url);

                    var games = JsonConvert.DeserializeObject <Sports.RootObject>(gamesForDate);

                    var game = games.sportItem.tournaments.SelectMany(input => input.events).FirstOrDefault(input => input.customId == bet.CustomId);

                    if (game == null)
                    {
                        continue;
                    }

                    if (game.status.type == "finished")
                    {
                        var winner = game.winnerCode;

                        if (winner != 0)
                        {
                            var placedBet = BettingAlgorithms.GetPlacedBet(bet);

                            if (placedBet.BetPlacedOnTeam == winner)
                            {
                                placedBet.Won = true;

                                Console.WriteLine($"{game.name} ({game.sport.name}) won at odds {placedBet.OddsPlaced}", ConsoleColor.Green);
                                Console.WriteLine();
                            }
                            else
                            {
                                placedBet.Won = false;

                                Console.WriteLine($"{game.name} ({game.sport.name}) lost at odds {placedBet.OddsPlaced}", ConsoleColor.Red);
                                Console.WriteLine();
                            }

                            BettingAlgorithms.UpdateBetAndDeletePending(placedBet, bet);
                        }
                    }
                }



                Thread.Sleep(evaluatorRefreshMilliseconds);
            }
        }