Beispiel #1
0
        internal void ProcessMatch(MatchObject match)
        {
            var startTimeDouble           = Convert.ToDouble(match.CommenceTime);
            var pinnacleLastUpdatedDouble = Convert.ToDouble(match.PinnacleLastUpdated);
            var betfairLastUpdatedDouble  = Convert.ToDouble(match.BetfairLastUpdated);

            var startTime           = new DateTime(1970, 1, 1).AddSeconds(startTimeDouble);
            var pinnacleLastUpdated = new DateTime(1970, 1, 1).AddSeconds(pinnacleLastUpdatedDouble);
            var betfairLastUpdated  = new DateTime(1970, 1, 1).AddSeconds(betfairLastUpdatedDouble);

            if (match.PinnacleHomeOdds > 0.0m && match.BetfairHomeOdds > 0.0m && Convert.ToInt64(match.PinnacleLastUpdated) < Convert.ToInt64(match.CommenceTime))
            {
                decimal vig     = CalculateOdds.getVig(match);
                decimal vigHome = CalculateOdds.getVigOdds(match.PinnacleHomeOdds, vig);
                decimal vigDraw = CalculateOdds.getVigOdds(match.PinnacleDrawOdds, vig);
                decimal vigAway = CalculateOdds.getVigOdds(match.PinnacleAwayOdds, vig);

                decimal betfairHome = CalculateOdds.getBetfairOdds(match.BetfairHomeOdds);
                decimal betfairDraw = CalculateOdds.getBetfairOdds(match.BetfairDrawOdds);
                decimal betfairAway = CalculateOdds.getBetfairOdds(match.BetfairAwayOdds);

                decimal valueHome = CalculateOdds.getValueOdds(vigHome, betfairHome);
                decimal valueDraw = CalculateOdds.getValueOdds(vigDraw, betfairDraw);
                decimal valueAway = CalculateOdds.getValueOdds(vigAway, betfairAway);

                if (DatabaseCalls.DoesRecordExist(match, startTime))
                {
                    int matchID = DatabaseCalls.getMatchRecordID(match, startTime);
                    DatabaseCalls.UpdateMatchRecord(matchID, match, vigHome, vigDraw, vigAway, match.BetfairHomeOdds, match.BetfairDrawOdds,
                                                    match.BetfairAwayOdds, valueHome, valueDraw, valueAway, pinnacleLastUpdated);
                }
                else
                {
                    DatabaseCalls.AddMatchRecord(match, vigHome, vigDraw, vigAway, match.BetfairHomeOdds, match.BetfairDrawOdds,
                                                 match.BetfairAwayOdds, valueHome, valueDraw, valueAway, pinnacleLastUpdated, startTime);
                    //add it
                    //write to historic table
                }

                //Add to historic record anyway
                DatabaseCalls.AddMatchRecordHistoric(match, vigHome, vigDraw, vigAway, match.BetfairHomeOdds, match.BetfairDrawOdds,
                                                     match.BetfairAwayOdds, valueHome, valueDraw, valueAway, pinnacleLastUpdated, startTime);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            MatchData          md           = new MatchData();
            List <string>      leagueData   = md.GetMatchData();
            List <MatchObject> matchObjects = new List <MatchObject>();

            foreach (var league in leagueData)
            {
                JsonFactory js = new JsonFactory();

                //delete all from match
                DatabaseCalls.DeleteMatchRecords();
                System.Threading.Thread.Sleep(1000);
                List <MatchObject> leagueMatches = js.GetMatchesForLeague(league);

                foreach (var match in leagueMatches)
                {
                    md.ProcessMatch(match);
                }
            }
        }