public IDictionary <Model.Outcome, IEnumerable <Model.GenericOdd> > GetOdds(Model.GenericMatchCoupon matchCoupon, DateTime timeStamp)
        {
            var returnOdds = new Dictionary <Model.Outcome, IEnumerable <Model.GenericOdd> >();

            var outcomes = Enum.GetNames(typeof(Model.Outcome)).Where(o => o != "NotAssigned");

            string[] bookies      = new string[] { "B365", "BS", "LB", "SB", "SJ", "WH", "BW", "GB", "IW", "VC" };
            var      footballData = this.bookmakerRepository.GetExternalSource("Football Data Odds");
            var      valueSamurai = this.bookmakerRepository.GetExternalSource("Value Samurai");
            var      bookiesDic   = bookies.ToDictionary(b => b, b => this.bookmakerRepository.FindByName(this.bookmakerRepository.GetAlias(b, footballData, valueSamurai)));

            var footballDataBest = this.bookmakerRepository.FindByName("Football Data Odds Best Available");

            var oddsRow = FixturesCouponsOdds.Where(x => x.Field <string>("HomeTeam") == matchCoupon.TeamOrPlayerA &&
                                                    x.Field <string>("AwayTeam") == matchCoupon.TeamOrPlayerB)
                          .FirstOrDefault();

            foreach (var outcome in outcomes)
            {
                var outcomeEnum    = (Model.Outcome)Enum.Parse(typeof(Model.Outcome), outcome);
                var oddsForOutcome = new List <Model.GenericOdd>();

                returnOdds.Add(outcomeEnum, oddsForOutcome);

                //already taken care of?
                //var bestOdd = oddsRow.Field<double>("BbMx" + outcome.Substring(0, 1));
                //oddsForOutcome.Add(CreateConcreateOdd(footballDataBest, bestOdd));

                foreach (var bookieKey in bookiesDic.Keys)
                {
                    var bookie = bookiesDic[bookieKey];
                    var lookup = bookieKey + outcome.Substring(0, 1);

                    var odd = oddsRow.Field <double>(lookup);

                    var genericOdd = CreateConcreateOdd(bookie, odd);
                    oddsForOutcome.Add(genericOdd);
                }
            }
            return(returnOdds);
        }
        public IDictionary <Model.Outcome, IEnumerable <Model.GenericOdd> > GetOdds(Model.GenericMatchCoupon matchCoupon, DateTime timeStamp)
        {
            var returnOdds = new Dictionary <Model.Outcome, IEnumerable <Model.GenericOdd> >();

            var outcomes = Enum.GetNames(typeof(Model.Outcome)).Where(o => o != "NotAssigned" && o != "Draw");

            string[] bookies      = new string[] { "B365", "EX", "LB", "PS", "SJ" };
            var      tennisData   = this.bookmakerRepository.GetExternalSource("Tennis Data Odds");
            var      valueSamurai = this.bookmakerRepository.GetExternalSource("Value Samurai");
            var      bookiesDic   = bookies.ToDictionary(b => b, b => this.bookmakerRepository.FindByName(this.bookmakerRepository.GetAlias(b, tennisData, valueSamurai)));

            var tennisDataBest = this.bookmakerRepository.FindByName("Tennis Data Odds Best Available");

            var oddsRow = this.excelMatches.FirstOrDefault(x => x.Field <string>("URL") == matchCoupon.MatchURL.ToString());

            foreach (var outcome in outcomes)
            {
                var outcomeEnum    = (Model.Outcome)Enum.Parse(typeof(Model.Outcome), outcome);
                var oddsForOutcome = new List <Model.GenericOdd>();

                returnOdds.Add(outcomeEnum, oddsForOutcome);

                foreach (var bookieKey in bookiesDic.Keys)
                {
                    var bookie = bookiesDic[bookieKey];
                    var lookup = bookieKey + (outcome == "HomeWin" ? "1" : "2");

                    var odd = oddsRow.Field <double?>(lookup);

                    if (odd != null)
                    {
                        var genericOdd = CreateConcreateOdd(bookie, odd ?? 0.0);
                        oddsForOutcome.Add(genericOdd);
                    }
                }
            }
            return(returnOdds);
        }
Example #3
0
        protected IEnumerable <Model.GenericMatchCoupon> FetchOddsForMatches(Model.IValueOptions valueOptions, IEnumerable <Match> matches)
        {
            var coupons      = new List <Model.GenericMatchCoupon>();
            var oddsStrategy = this.oddsProvider.CreateOddsStrategy(valueOptions);
            var timeStamp    = DateTime.Now;

            var tournamentEventIDs = matches.Select(m => m.TournamentEventID)
                                     .Distinct()
                                     .ToDictionary(t => t, t => this.fixtureRepository.GetTournamentEventById(t).EventName);


            foreach (var match in matches)
            {
                var teamOrPlayerA   = this.fixtureRepository.GetTeamOrPlayerById(match.TeamAID);
                var teamOrPlayerB   = this.fixtureRepository.GetTeamOrPlayerById(match.TeamBID);
                var matchCouponURLs = this.bookmakerRepository
                                      .GetMatchCouponURLs(match.Id)
                                      .First(m => m.ExternalSource.Source == valueOptions.OddsSource.Source)
                                      .MatchCouponURLString;

                var coupon = new Model.GenericMatchCoupon
                {
                    TeamOrPlayerA       = teamOrPlayerA.Name,
                    FirstNameA          = teamOrPlayerA.FirstName,
                    TeamOrPlayerB       = teamOrPlayerB.Name,
                    FirstNameB          = teamOrPlayerB.FirstName,
                    TournamentEventName = tournamentEventIDs[match.TournamentEventID],
                    MatchURL            = new Uri(match.MatchCouponURLs.First(m => m.ExternalSource.Source == valueOptions.OddsSource.Source).MatchCouponURLString),
                    InPlay = match.InPlay
                };
                coupon.ActualOdds = oddsStrategy.GetOdds(coupon, valueOptions.CouponDate, timeStamp);
                coupons.Add(coupon);
            }
            var matchesReturn = PersistCoupons(coupons, valueOptions.CouponDate, valueOptions.Tournament.TournamentName);

            return(coupons);
        }
Example #4
0
    protected IEnumerable<Model.GenericMatchCoupon> FetchOddsForMatches(Model.IValueOptions valueOptions, IEnumerable<Match> matches)
    {
      var coupons = new List<Model.GenericMatchCoupon>();
      var oddsStrategy = this.oddsProvider.CreateOddsStrategy(valueOptions);
      var timeStamp = DateTime.Now;

      var tournamentEventIDs = matches.Select(m => m.TournamentEventID)
                                      .Distinct()
                                      .ToDictionary(t => t, t => this.fixtureRepository.GetTournamentEventById(t).EventName);


      foreach (var match in matches)
      {
        var teamOrPlayerA = this.fixtureRepository.GetTeamOrPlayerById(match.TeamAID);
        var teamOrPlayerB = this.fixtureRepository.GetTeamOrPlayerById(match.TeamBID);
        var matchCouponURLs = this.bookmakerRepository
                                  .GetMatchCouponURLs(match.Id)
                                  .First(m => m.ExternalSource.Source == valueOptions.OddsSource.Source)
                                  .MatchCouponURLString;

        var coupon = new Model.GenericMatchCoupon
        {
          TeamOrPlayerA = teamOrPlayerA.Name,
          FirstNameA = teamOrPlayerA.FirstName,
          TeamOrPlayerB = teamOrPlayerB.Name,
          FirstNameB = teamOrPlayerB.FirstName,
          TournamentEventName = tournamentEventIDs[match.TournamentEventID],
          MatchURL = new Uri(match.MatchCouponURLs.First(m => m.ExternalSource.Source == valueOptions.OddsSource.Source).MatchCouponURLString),
          InPlay = match.InPlay
        };
        coupon.ActualOdds = oddsStrategy.GetOdds(coupon, valueOptions.CouponDate, timeStamp);
        coupons.Add(coupon);
      }
      var matchesReturn = PersistCoupons(coupons, valueOptions.CouponDate, valueOptions.Tournament.TournamentName);
      return coupons;
    }
    public override async Task<IDictionary<Outcome, IEnumerable<GenericOdd>>> GetOdds(GenericMatchCoupon matchCoupon, DateTime couponDate, DateTime timeStamp)
    {
      ProgressReporterProvider.Current.ReportProgress(string.Format("Getting Oddschecker Mobile odds for {0} vs. {1}", matchCoupon.TeamOrPlayerA, matchCoupon.TeamOrPlayerB), ReporterImportance.High, ReporterAudience.Admin);

      var playerLookup = new Dictionary<string, Outcome>()
      {
        { matchCoupon.TeamOrPlayerA, Outcome.HomeWin },
        { "Draw", Outcome.Draw },
        { matchCoupon.TeamOrPlayerB, Outcome.AwayWin }
      };

      var source =
        this.fixtureRepository
            .GetExternalSource("Odds Checker Mobi");
      var destination =
        this.fixtureRepository
            .GetExternalSource("Value Samurai");

      var outcomeDictionary = new Dictionary<Outcome, IEnumerable<GenericOdd>>();

      var webRepository =
        this.webRepositoryProvider
            .CreateWebRepository(couponDate);

      var html = await webRepository.GetHTML(matchCoupon.MatchURL);

      var oddsTokens =
        WebUtils.ParseWebsite<OddsCheckerMobiCompetitor, OddsCheckerMobiOdds>(html, s => { });

      var currentOutcome = Outcome.NotAssigned;
      var oddsForOutcome = new List<GenericOdd>();
      var missingBookmakerAlias = new List<MissingBookmakerAliasObject>();

      foreach (var oddsToken in oddsTokens)
      {
        if (oddsToken is OddsCheckerMobiCompetitor)
        {
          var competitor = ((OddsCheckerMobiCompetitor)oddsToken).Outcome;
          var currentOutcomeLocal = competitor == "Draw" ? null : this.fixtureRepository.GetAlias(competitor, source, destination, sport);
          currentOutcome = playerLookup[competitor == "Draw" ? competitor : currentOutcomeLocal.Name];

          oddsForOutcome = new List<GenericOdd>();
          outcomeDictionary.Add(currentOutcome, oddsForOutcome);
        }
        else
        {
          var odd = (OddsCheckerMobiOdds)oddsToken;
          var bookmakerName = this.bookmakerRepository.GetAlias(odd.Bookmaker, source, destination);
          var bookmaker = this.bookmakerRepository.FindByName(bookmakerName);
          if (bookmaker == null)
          {
            missingBookmakerAlias.Add(new MissingBookmakerAliasObject
            {
              Bookmaker = odd.Bookmaker,

              ExternalSource = source.Source,
              ExternalSourceID = source.Id
            });
            continue;
          }

          oddsForOutcome.Add(new OddsCheckerOdd()
          {
            OddsBeforeCommission = odd.DecimalOdds,
            CommissionPct = (double)(bookmaker.CurrentCommission ?? 0.0m),
            DecimalOdds = odd.DecimalOdds * (1 - (double)(bookmaker.CurrentCommission ?? 0.0m)),
            BookmakerName = bookmaker.BookmakerName,
            Source = "Odds Checker Mobi",
            BetSlipValue = odd.BetSlipValue,
            TimeStamp = timeStamp,
            Priority = bookmaker.Priority
          });
        }
      }
      if (missingBookmakerAlias.Count() != 0)
        throw new MissingBookmakerAliasException(missingBookmakerAlias, "Missing bookmaker alias");

      return outcomeDictionary;
    }
    public override async Task<IDictionary<Outcome, IEnumerable<GenericOdd>>> GetOdds(GenericMatchCoupon matchCoupon, DateTime couponDate, DateTime timeStamp)
    {
      ProgressReporterProvider.Current.ReportProgress(string.Format("Getting Oddschecker Web odds for {0} vs. {1}", matchCoupon.TeamOrPlayerA, matchCoupon.TeamOrPlayerB), ReporterImportance.High, ReporterAudience.Admin);

      var playerLookup = new Dictionary<string, Outcome>()
      {
        { matchCoupon.TeamOrPlayerA, Outcome.HomeWin },
        { "Draw", Outcome.Draw },
        { matchCoupon.TeamOrPlayerB, Outcome.AwayWin }
      };

      var source =
        this.fixtureRepository
            .GetExternalSource("Odds Checker Web");

      var destination =
        this.fixtureRepository
            .GetExternalSource("Value Samurai");

      var outcomeDictionary = new Dictionary<Outcome, IEnumerable<GenericOdd>>();

      var webRepository =
        this.webRepositoryProvider
            .CreateWebRepository(couponDate);

      var html = await webRepository.GetHTML(matchCoupon.MatchURL);

      var oddsTokens = new List<IRegexableWebsite>();

      oddsTokens.AddRange(WebUtils.ParseWebsite<OddsCheckerWebMarketID, OddsCheckerWebCard>(html, s => { }));
      oddsTokens.AddRange(WebUtils.ParseWebsite<OddsCheckerWebCompetitor, OddsCheckerWebOdds>(html, s => { }));

      #region deprecated
      //deprecated - redirection used to be handled by javascript.  We now get an easy to hack URL
      //var oddsCheckerJSFile = this.bookmakerRepository.GetOddsCheckerJavaScript();

      //var jint = new JintEngine();
      //jint.Run(oddsCheckerJSFile);
      #endregion

      string webCard = ((OddsCheckerWebCard)oddsTokens.First(o => o is OddsCheckerWebCard)).CardID;
      string webMarketID = ((OddsCheckerWebMarketID)oddsTokens.First(o => o is OddsCheckerWebMarketID)).MarketID;

      var bestBookies =
        (from odd in oddsTokens.OfType<OddsCheckerWebOdds>()
         group odd by odd.OddsCheckerID into groupedOdds
         select new
         {
           ID = groupedOdds.Key,
           BestBookies = groupedOdds.Where(x => x.IsBestOdd).Aggregate(string.Empty, (acc, item) => acc + "," + item.BookmakerID)
         })
        .ToDictionary(x => x.ID, x => x.BestBookies);

      var currentOutcome = Outcome.NotAssigned;
      var oddsForOutcome = new List<GenericOdd>();
      var missingBookmakerAlias = new List<MissingBookmakerAliasObject>();

      foreach (var oddsToken in oddsTokens)
      {
        if (oddsToken is OddsCheckerWebCompetitor)
        {
          var competitor = ((OddsCheckerWebCompetitor)oddsToken).Outcome;
          var currentOutcomeLocal = competitor == "Draw" ? null : this.fixtureRepository.GetAlias(competitor, source, destination, sport);
          currentOutcome = playerLookup[competitor == "Draw" ? competitor : currentOutcomeLocal.Name];

          oddsForOutcome = new List<GenericOdd>();
          outcomeDictionary.Add(currentOutcome, oddsForOutcome);
        }
        else if (oddsToken is OddsCheckerWebOdds)
        {
          var odd = (OddsCheckerWebOdds)oddsToken;
          if (odd.BookmakerID == "SI" || odd.BookmakerID == "SX")
            continue;
          var bookmaker = this.bookmakerRepository.FindByOddsCheckerID(odd.BookmakerID);
          if (bookmaker == null)
          {
            missingBookmakerAlias.Add(new MissingBookmakerAliasObject
            {
              Bookmaker = odd.BookmakerID,

              ExternalSource = source.Source,
              ExternalSourceID = source.Id

            });
            continue;
          }

          var clickThroughURL = string.Format("http://www.oddschecker.com/betslip?bk={0}&mkid={1}&pid={2}&cardId={3}&bestBookies={4}",
            odd.BookmakerID, webMarketID, odd.OddsCheckerID, webCard, bestBookies[odd.OddsCheckerID]);
          //var bSlip = string.Format("www.oddschecker.com{0}", jint.CallFunction("bSlip", odd.BookmakerID, odd.MarketIDOne, odd.MarketIDTwo, odd.OddsText).ToString());

          oddsForOutcome.Add(new OddsCheckerOdd()
          {
            OddsBeforeCommission = odd.DecimalOdds,
            CommissionPct = (double)(bookmaker.CurrentCommission ?? 0.0m),
            DecimalOdds = odd.DecimalOdds * (1 - (double)(bookmaker.CurrentCommission ?? 0.0m)),
            BookmakerName = bookmaker.BookmakerName,
            Source = "Odds Checker Web",
            ClickThroughURL = new Uri(clickThroughURL),
            TimeStamp = timeStamp,
            Priority = bookmaker.Priority
          });
        }
      }
      if (missingBookmakerAlias.Count() != 0)
        throw new MissingBookmakerAliasException(missingBookmakerAlias, "Missing bookmaker alias");

      return outcomeDictionary;
    }
 public abstract Task<IDictionary<Outcome, IEnumerable<GenericOdd>>> GetOdds(GenericMatchCoupon matchCoupon, DateTime couponDate, DateTime timeStamp);
Example #8
0
    public override IDictionary<Outcome, IEnumerable<GenericOdd>> GetOdds(GenericMatchCoupon matchCoupon, DateTime couponDate, DateTime timeStamp)
    {
      var playerLookup = new Dictionary<string, Outcome>()
      {
        { matchCoupon.TeamOrPlayerA, Outcome.HomeWin },
        { "Draw", Outcome.Draw },
        { matchCoupon.TeamOrPlayerB, Outcome.AwayWin }
      };

      var source = this.fixtureRepository.GetExternalSource("Best Betting");
      var destination = this.fixtureRepository.GetExternalSource("Value Samurai");

      var outcomeDictionary = new Dictionary<Outcome, IEnumerable<GenericOdd>>();

      var webRepository = this.webRepositoryProvider.CreateWebRepository(couponDate);

      var oddsHTML = webRepository.GetHTML(new Uri[] { matchCoupon.MatchURL }, s => ProgressReporterProvider.Current.ReportProgress(s, ReporterImportance.Low, ReporterAudience.Admin)).First();
      var oddsTokens = WebUtils.ParseWebsite<BestBettingOddsCompetitor, BestBettingOdds>(
        oddsHTML, s => ProgressReporterProvider.Current.ReportProgress(s, ReporterImportance.Medium, ReporterAudience.Admin));

      var currentOutcome = Outcome.NotAssigned;
      var oddsForOutcome = new List<GenericOdd>();
      var missingBookmakerAlias = new List<MissingBookmakerAliasObject>();

      foreach (var oddsToken in oddsTokens)
      {
        if (oddsToken is BestBettingOddsCompetitor)
        {
          var competitor = ((BestBettingOddsCompetitor)oddsToken).Competitor;

          var currentOutcomeLocal = competitor == "Draw" ? null : this.fixtureRepository.GetAlias(((BestBettingOddsCompetitor)oddsToken).Competitor, source, destination, this.sport);
          currentOutcome = playerLookup[competitor == "Draw" ? competitor : currentOutcomeLocal.Name];

          oddsForOutcome = new List<GenericOdd>();
          outcomeDictionary.Add(currentOutcome, oddsForOutcome);
        }
        else
        {
          var odd = (BestBettingOdds)oddsToken;
          var bookmakerName = this.bookmakerRepository.GetAlias(odd.Bookmaker, source, destination);
          var bookmaker = this.bookmakerRepository.FindByName(bookmakerName);
          if (bookmaker == null)
          {
            missingBookmakerAlias.Add(new MissingBookmakerAliasObject
            {
              Bookmaker = odd.Bookmaker,
              ExternalSource = source.Source
            });
            continue;
          }

          oddsForOutcome.Add(new BestBettingOdd()
          {
            OddsBeforeCommission = odd.DecimalOdds,
            CommissionPct = (double)(bookmaker.CurrentCommission ?? 0.0m),
            DecimalOdds = odd.DecimalOdds * (1 - (double)(bookmaker.CurrentCommission ?? 0.0m)),
            BookmakerName = bookmaker.BookmakerName,
            Source = "Best Betting",
            TimeStamp = timeStamp,
            Priority = bookmaker.Priority,
            ClickThroughURL = odd.ClickThroughURL
          });
        }

      }
      if (missingBookmakerAlias.Count() != 0)
        throw new MissingBookmakerAliasException(missingBookmakerAlias, "Missing bookmaker alias");

      return outcomeDictionary;
    }