public override IOdds TrueOdds(IOdds averageOdds)
        {
            try
            {
                switch (averageOdds.Type)
                {
                case OddsType.ThreeWay:
                    ThreeWayOdds trueOdds = new ThreeWayOdds();
                    var          curOdds  = (ThreeWayOdds)averageOdds;
                    double       payout   = curOdds.Payout();
                    trueOdds.Win  = curOdds.Win / payout;
                    trueOdds.Lose = curOdds.Lose / payout;
                    trueOdds.Draw = curOdds.Draw / payout;
                    return(trueOdds);

                default:
                    break;
                }
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Null reference to averageOdds in TrueOdds calculation");
            }
            catch (DivideByZeroException)
            {
                Console.WriteLine("Divided by Zero in TrueOdds calculation");
            }
            return(null);
        }
Ejemplo n.º 2
0
        protected List <Stake> MaxOddsStakes(string gameName, GameType gameType, OddsType oddsType)
        {
            switch (oddsType)
            {
            case OddsType.ThreeWay:
                Stake [] maxOddsStakes = new Stake[3];
                foreach (BetItem item in CurrentBets)
                {
                    if (item.GameName.Equals(gameName, StringComparison.InvariantCultureIgnoreCase) &&
                        item.GameType == gameType &&
                        oddsType == OddsType.ThreeWay)
                    {
                        ThreeWayOdds itemOdds = (ThreeWayOdds)(item.Odds);
                        if (null == maxOddsStakes[0] || itemOdds.Win > ((ThreeWayOdds)maxOddsStakes[0].BetItem.Odds).Win)
                        {
                            maxOddsStakes[0] = new Stake(item, "Win");
                        }
                        if (null == maxOddsStakes[1] || itemOdds.Lose > ((ThreeWayOdds)maxOddsStakes[1].BetItem.Odds).Lose)
                        {
                            maxOddsStakes[1] = new Stake(item, "Lose");
                        }
                        if (null == maxOddsStakes[2] || itemOdds.Draw > ((ThreeWayOdds)maxOddsStakes[2].BetItem.Odds).Draw)
                        {
                            maxOddsStakes[2] = new Stake(item, "Draw");
                        }
                    }
                }
                return(maxOddsStakes.ToList());

            default:
                break;
            }

            return(null);
        }
Ejemplo n.º 3
0
 public BetItem(string id,
                string gameName,
                GameType gameType,
                List <Team> teams,
                ThreeWayOdds odds,
                bool aggregated,
                DateTime oddsDate,
                DateTime matchDate,
                string bookMaker)
 {
     Init(id, gameName, gameType, teams, aggregated, oddsDate, matchDate, bookMaker);
     Odds = odds;
 }
Ejemplo n.º 4
0
        public IOdds AverageOdds(string gameName, GameType gameType, OddsType oddsType)
        {
            try
            {
                switch (oddsType)
                {
                case OddsType.ThreeWay:
                    ThreeWayOdds avgOdds = new ThreeWayOdds();
                    int          count   = 0;
                    foreach (BetItem item in CurrentBets)
                    {
                        if (item.GameName.Equals(gameName, StringComparison.InvariantCultureIgnoreCase) &&
                            item.GameType == gameType &&
                            oddsType == OddsType.ThreeWay)
                        {
                            avgOdds.Win  += ((ThreeWayOdds)(item.Odds)).Win;
                            avgOdds.Lose += ((ThreeWayOdds)(item.Odds)).Lose;
                            avgOdds.Draw += ((ThreeWayOdds)(item.Odds)).Draw;
                            count++;
                        }
                    }
                    avgOdds.Win  /= count;
                    avgOdds.Lose /= count;
                    avgOdds.Draw /= count;
                    return(avgOdds);

                default:
                    break;
                }
            }
            catch (DivideByZeroException)
            {
                Console.WriteLine("Not enough sample size during average odds calculation");
                Console.WriteLine("GameName:{0}, GameType:{1}, OddesType:{2}", gameName, gameType, oddsType.ToString());
            }
            return(null);
        }