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); }
public override Stake BestStake(string gameName, GameType gameType, OddsType oddsType) { try { IOdds avgOdds = AverageOdds(gameName, gameType, oddsType); IOdds trueOdds = TrueOdds(avgOdds); var maxOddsStakes = MaxOddsStakes(gameName, gameType, oddsType); Stake bestBet = null; switch (oddsType) { case OddsType.ThreeWay: foreach (Stake stake in maxOddsStakes) { double curRoi = 0; if (stake.Decision.Equals("Win", StringComparison.InvariantCultureIgnoreCase)) { curRoi = (((ThreeWayOdds)stake.BetItem.Odds).Win - ((ThreeWayOdds)trueOdds).Win) / ((ThreeWayOdds)trueOdds).Win; } else if (stake.Decision.Equals("Lose", StringComparison.InvariantCultureIgnoreCase)) { curRoi = (((ThreeWayOdds)stake.BetItem.Odds).Lose - ((ThreeWayOdds)trueOdds).Lose) / ((ThreeWayOdds)trueOdds).Lose; } if (stake.Decision.Equals("Draw", StringComparison.InvariantCultureIgnoreCase)) { curRoi = (((ThreeWayOdds)stake.BetItem.Odds).Draw - ((ThreeWayOdds)trueOdds).Draw) / ((ThreeWayOdds)trueOdds).Draw; } if (null == bestBet || curRoi > bestBet.ROI) { stake.ROI = curRoi; bestBet = stake; } } break; default: break; } return(bestBet); } catch (Exception e) { Console.WriteLine(e.Source); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return(null); }