public void RunModel() { if (!InitialModelDataLoadComplete) { const string message = "LoadModelData() must be called before RunModel()"; Logger.Error(message); throw new Exception(message); } // clear periodMarkets each time PeriodMarkets.Clear(); string saveFile = GetSaveFullFileName(); _analyticaNfl.IsTeamMode = IsTeamMode; Dictionary <int, List <Market> > result = _analyticaNfl.RunModel(ModelData, PeriodMarkets, Started, saveFile); //TODO move game total seconds to config //TODO move check to util method if (!ModelData.ContainsKey(NflModelDataKeys.Egt)) { ModelData.Add(NflModelDataKeys.Egt, new Dictionary <string, double>()); ModelData[NflModelDataKeys.Egt].Add("S", 3600); } if (!ModelData[NflModelDataKeys.Egt].ContainsKey("S")) { ModelData[NflModelDataKeys.Egt].Add("S", 3600); } _distributorNfl.SendMarkets(result, GameId, Description, ModelData[NflModelDataKeys.Egt]); ModelUpdateRequired = false; }
public void RunModel() { if (!InitialModelDataLoadComplete) { const string message = "LoadModelData() must be called before RunModel()"; Logger.Error(message); throw new Exception(message); } // clear periodMarkets each time PeriodMarkets.Clear(); string saveFile = GetSaveFullFileName(); _analyticaNcaafb.IsTeamMode = IsTeamMode; Dictionary <int, List <Market> > result = _analyticaNcaafb.RunModel(ModelData, PeriodMarkets, Started, saveFile); _distributorNcaafb.SendMarkets(result, GameId, Description); ModelUpdateRequired = false; }
public void RunModel() { if (!InitialModelDataLoadComplete) { const string message = "LoadModelData() must be called before RunModel()"; Logger.Error(message); throw new Exception(message); } // clear periodMarkets each time PeriodMarkets.Clear(); string saveFile = GetSaveFullFileName(); _analyticaNcaabb.IsTeamMode = IsTeamMode; Stopwatch stopwatch = Stopwatch.StartNew(); Dictionary <int, List <Market> > result = _analyticaNcaabb.RunModel(ModelData, PeriodMarkets, Started, saveFile); Logger.Info($"{GameId} ({Description}) RunModel() runtime = {stopwatch.Elapsed.Seconds,4} sec"); stopwatch = Stopwatch.StartNew(); if (!ModelData.ContainsKey(NcaabbModelDataKeys.Egt)) { ModelData.Add(NcaabbModelDataKeys.Egt, new Dictionary <string, double>()); ModelData[NcaabbModelDataKeys.Egt].Add("S", 2400); } if (!ModelData[NcaabbModelDataKeys.Egt].ContainsKey("S")) { ModelData[NcaabbModelDataKeys.Egt].Add("S", 2400); } _distributorNcaabb.SendMarkets(result, GameId, Description, ModelData[NcaabbModelDataKeys.Egt]); Logger.Info($"{GameId} ({Description}) SendMarkets() runtime = {stopwatch.Elapsed.Seconds,4} sec"); ModelUpdateRequired = false; }
public void RunModel() { if (!InitialModelDataLoadComplete) { const string message = "LoadModelData() must be called before RunModel()"; Logger.Error(message); throw new Exception(message); } // clear periodMarkets each time PeriodMarkets.Clear(); string saveFile = GetSaveFullFileName(); _analyticaNba.IsTeamMode = IsTeamMode; Stopwatch stopwatch = Stopwatch.StartNew(); Dictionary <int, List <Market> > result = _analyticaNba.RunModel(ModelData, PeriodMarkets, Started, saveFile); Logger.Info($"{GameId} ({Description}) RunModel() runtime = {stopwatch.Elapsed.Seconds,4} sec"); // todo this code does not belong here stopwatch = Stopwatch.StartNew(); if (!ModelData.ContainsKey(NbaModelDataKeys.Egt)) { ModelData.Add(NbaModelDataKeys.Egt, new Dictionary <string, double>()); ModelData[NbaModelDataKeys.Egt].Add("S", GameTimeSeconds); } if (!ModelData[NbaModelDataKeys.Egt].ContainsKey("S")) { ModelData[NbaModelDataKeys.Egt].Add("S", GameTimeSeconds); } if (IsTeamMode) { _distributorNba.SendMarkets(result, GameId, Description, ModelData[NbaModelDataKeys.Egt]); } else { /* * //format results * //todo move to utils * if (result.Count > 0) * { * foreach (Market market in result[1]) * { * string[] playerStr = market.Player.Split('_'); * string side = playerStr[0]; * int number = ToInt16(playerStr[1]); * switch (side) * * { * case "away": * NbaPlayer playerA = AwayTeam.PlayerList.Find(x => x.Number == number); * * if (market.MarketRunnerList[0].Price.IsNotEqualToZero() && market.MarketRunnerList[0].Price.IsNotEqualTo(1)) * { * if (playerA.Stats != null && market.Tp != null && !playerA.Stats.ContainsKey(market.Tp)) * { * playerA.Stats.Add(market.Tp, new OddsAndStats()); * playerA.Side = side; * playerA.comp_id = Convert.ToString(GameId); * playerA.team = Convert.ToString(AwayTeam.TeamId); * //playerA.player_id = Convert.ToString(playerA.PlayerId); * playerA.player = playerA.FullName; * } * * playerA.Stats[market.Tp].odds.Add(market); * } * * break; * * case "home": * Player playerH = HomeTeam.PlayerList.Find(x => x.Number == number); * * if (market.MarketRunnerList[0].Price.IsNotEqualToZero() && market.MarketRunnerList[0].Price.IsNotEqualTo(1)) * { * * if (playerH.Stats != null && market.Tp != null && !playerH.Stats.ContainsKey(market.Tp)) * { * playerH.Stats.Add(market.Tp, new OddsAndStats()); * playerH.Side = side; * playerH.comp_id = Convert.ToString(GameId); * // playerH.player_id = Convert.ToString(playerH.PlayerId); * playerH.team = Convert.ToString(HomeTeam.TeamId); * playerH.player = playerH.FullName; * } * * playerH.Stats[market.Tp].odds.Add(market); * } * * break; * } * } * } * * List<Player> playersMessages = new List<Player>(); * //add stats template to fill in missing elements * List<string> types = new List<string>{ "P", "R", "A", "S", "B", "T", "F3M", "F3A", "F2M", "F2A", "FTM", "FTA" }; * * foreach (Player player in HomeTeam.PlayerList) * { * foreach (KeyValuePair<string, OddsAndStats> playerStatMarket in player.Stats) * { * playerStatMarket.Value.MainMarket = * playerStatMarket.Value.odds.OrderBy(v => v.Weight).First(); * } * * * //check for missing stats and fill them in * foreach (string type in types) * { * if (!player.Stats.ContainsKey(type)) * { * //add new market * Market market = new Market * { * Tp = type, * Target = 0 * }; * * * market.MarketRunnerList.Add(new MarketRunner * { * Total = 0, * Price = 0, * Side = "U" * }); * * market.MarketRunnerList.Add(new MarketRunner * { * Total = 0, * Price = 0.0, * Side = "O" * }); * OddsAndStats os = new OddsAndStats * { * MainMarket = market * }; * player.Stats.Add(type, os); * * } * } * * if (player.comp_id != null && player.Stats.Count != 0) * { * playersMessages.Add(player); * } * } * * foreach (Player player in AwayTeam.PlayerList) * { * foreach (KeyValuePair<string, OddsAndStats> playerStatMarket in player.Stats) * { * playerStatMarket.Value.MainMarket = * playerStatMarket.Value.odds.OrderBy(v => v.Weight).First(); * } * * * // //check for missing stats and fill them in * foreach (string type in types) * { * if (!player.Stats.ContainsKey(type)) * { * //add new market * Market market = new Market * { * Tp = type, * Target = 0 * }; * * * market.MarketRunnerList.Add(new MarketRunner * { * Total = 0, * Price = 0, * Side = "U" * }); * * market.MarketRunnerList.Add(new MarketRunner * { * Total = 0, * Price = 0.0, * Side = "O" * }); * OddsAndStats os = new OddsAndStats * { * MainMarket = market * }; * player.Stats.Add(type, os); * * } * } * * if (player.comp_id != null && player.Stats.Count != 0) * { * playersMessages.Add(player); * } * } * * Dictionary<string, List<Player>> playersMessage = new Dictionary<string, List<Player>> * { * ["players"] = playersMessages * }; * string messageStr = JsonConvert.SerializeObject(playersMessage); * _distributorNba.SendPlayerMarkets(messageStr, GameId, Description); */ } Logger.Info($"{GameId} ({Description}) SendMarkets() runtime = {stopwatch.Elapsed.Seconds,4} sec"); ModelUpdateRequired = false; }