示例#1
0
 public void OnNext(FootballScore value)
 {
     if (!_stopProcessing)
     {
         ProcessUpdatedScore(value);
     }
 }
示例#2
0
        public FootballScore GetLatestFootballScore(string team1Name, string team2Name)
        {
            FootballScore latestFootballScore = new FootballScore()
            {
                PublishedDateTime = DateTime.MinValue
            };
            //= new FootballScore();
            // 1. load all aliases for the two runners (team1 and team2). will need to add the
            //      method to do that in utilities project.
            NameAliases team1NameAliases = RunnerAliasesHelper.GetNameAliasesForRunner(team1Name);
            NameAliases team2NameAliases = RunnerAliasesHelper.GetNameAliasesForRunner(team2Name);

            // 2. get scorespro rss
            _feed = SyndicationFeed.Load(_xmlReader);
            if (_feed == null)
            {
                return(latestFootballScore);
            }
            foreach (SyndicationItem item in _feed.Items)
            {
                // 3. for each feed:
                //      a. parse into football score object
                //      b. check if it contains both home and away alias
                //      c. if yes then cache it if latest. (same score could appear twice)
                Console.WriteLine(item.Title.Text);
                FootballScore parsedScore = Parser.ParseScoresProFootballScore(item);
                // set parsed score team names according to the caller of this method
                if (team1NameAliases.Aliases.Contains(parsedScore.HomeName) && team2NameAliases.Aliases.Contains(parsedScore.AwayName))
                {
                    parsedScore.HomeName = team1Name;
                    parsedScore.AwayName = team2Name;
                    if (parsedScore.PublishedDateTime > latestFootballScore.PublishedDateTime)
                    {
                        latestFootballScore = parsedScore;
                    }
                }
                if (team2NameAliases.Aliases.Contains(parsedScore.HomeName) && team1NameAliases.Aliases.Contains(parsedScore.AwayName))
                {
                    parsedScore.HomeName = team2Name;
                    parsedScore.AwayName = team1Name;
                    if (parsedScore.PublishedDateTime > latestFootballScore.PublishedDateTime)
                    {
                        latestFootballScore = parsedScore;
                    }
                }
            }
            // 4. return the latest score
            return(latestFootballScore);
        }
示例#3
0
 private void ProcessUpdatedScore(FootballScore newScore)
 {
     LatestScore = newScore;
     // OkashTODO: extract chosen runner score and opponent score.
     if (newScore.HomeName == _chosenRunnerName)
     {
         _chosenRunnerScore   = newScore.HomeScore;
         _opponentRunnerScore = newScore.AwayScore;
     }
     else
     {
         _chosenRunnerScore   = newScore.AwayScore;
         _opponentRunnerScore = newScore.HomeScore;
     }
     Logger.Write(Resources.ProjectName, _matchName, "----New Score Received. [" + newScore.ToString() + "]");
 }
示例#4
0
        public static FootballScore ParseScoresProFootballScore(SyndicationItem itemToParse)
        {
            FootballScore parsedFootballScore = new FootballScore();
            // example score text= Soccer Livescore: (BRA-CA) #Madureira vs #Bangu: 1-1
            string scoreText = itemToParse.Title.Text;

            string[] splitOnColon = scoreText.Split(':');
            string[] splitOnHash  = splitOnColon[1].Split('#');
            parsedFootballScore.HomeName = splitOnHash[1].Substring(0, splitOnHash[1].IndexOf(" vs "));
            parsedFootballScore.AwayName = splitOnHash[2];
            string[] splitOnHyphen = splitOnColon[2].Split('-');
            parsedFootballScore.HomeScore = int.Parse(splitOnHyphen[0].Trim());
            parsedFootballScore.AwayScore = int.Parse(splitOnHyphen[1].Trim());
            // parsing finished. extract other items.
            parsedFootballScore.Description       = itemToParse.Summary.Text;
            parsedFootballScore.PublishedDateTime = itemToParse.PublishDate.DateTime;
            return(parsedFootballScore);
        }
示例#5
0
        public static bool PlaceBet(decimal chosenAmount, decimal riskFreePayoff, DateTime startingTime, FootballScore score)
        {
            int minutesSinceStart = (int)DateTime.Now.Subtract(startingTime).TotalMinutes;

            if (minutesSinceStart < BreakEvenThreshold)
            {
                if ((riskFreePayoff / chosenAmount) >= 0.3M)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if ((minutesSinceStart >= BreakEvenThreshold) && (minutesSinceStart < RescueThreshold))
            {
                if (riskFreePayoff >= 0.0M)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            if (minutesSinceStart >= RescueThreshold)
            {
                if (riskFreePayoff >= (-1 * chosenAmount))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
示例#6
0
 public MatchScoreDto(MatchDto match, FootballScore score)
 {
     Match = match;
     Score = score;
 }
 public MatchScorePredictionDto(MatchDto match, FootballScore score, FootballScore predictionValue)
 {
     Match           = match;
     Score           = score;
     PredictionValue = predictionValue;
 }