Exemple #1
0
        private static Dictionary <string, double> ProcesAdjustment(MarketDescription market, Adjustment adjustment, Dictionary <string, double> gameAdjustmentDictionary)
        {
            string oddsAbbreviaiton = market.ShortName;
            string period           = Convert.ToString(market.Period);
            string key = $"{oddsAbbreviaiton},{period}";


            double val  = Math.Abs(adjustment.Value) / .5;
            int    aVal = 11;

            if (adjustment.Value < 0)
            {
                aVal = 11 - ToInt16(val);
            }

            if (adjustment.Value > 0)
            {
                aVal = 11 + ToInt16(val);
            }



            try
            {
                gameAdjustmentDictionary[key] = aVal;
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
            }

            return(gameAdjustmentDictionary);
        }
Exemple #2
0
        public List <MarketDescription> GetMarketsDescriptions()
        {
            lock (_lockObject)
            {
                List <MarketDescription> marketsDictionary = new List <MarketDescription>();

                using (NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnectionString))
                {
                    npgsqlConnection.Open();
                    const string sqlCommandText = "select * from nba.get_markets()";

                    using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(sqlCommandText, npgsqlConnection))
                    {
                        npgsqlCommand.CommandType = CommandType.Text;

                        using (NpgsqlDataReader npgsqlDataReader = npgsqlCommand.ExecuteReader())
                        {
                            if (!npgsqlDataReader.HasRows)
                            {
                                const string message = "GetNBAMarkets() has no rows";
                                Logger.Info(message);

                                return(marketsDictionary);
                            }

                            while (npgsqlDataReader.Read())
                            {
                                MarketDescription md = new MarketDescription
                                {
                                    MarketId  = npgsqlDataReader.GetInt("market_id"),
                                    Name      = npgsqlDataReader.GetString("name"),
                                    ShortName = npgsqlDataReader.GetString("abbr"),
                                    InPlay    = npgsqlDataReader.GetInt("inplay"),
                                    Overtime  = npgsqlDataReader.GetInt("ot"),
                                    Period    = npgsqlDataReader.GetInt("period")
                                };

                                marketsDictionary.Add(md);
                            }

                            return(marketsDictionary);
                        }
                    }
                }
            }
        }
Exemple #3
0
 private void HandleStatsAdjust(string pubsubData, Guid gameId)
 {
     if (GameId == gameId)
     {
         List <Adjustment> adjustments = JsonConvert.DeserializeObject <List <Adjustment> >(pubsubData);
         foreach (Adjustment adjustment in adjustments)
         {
             MarketDescription marketDescription = _marketList.Find(s => s.MarketId == adjustment.MarketId);
             if (marketDescription != null)
             {
                 ModelData[NbaModelDataKeys.Adjust] = ProcesAdjustment(marketDescription, adjustment,
                                                                       ModelData[NbaModelDataKeys.Adjust]);
                 Logger.Info($"Updated adjustment odds for {GameId} ({marketDescription.ShortName}  {adjustment.Value})");
             }
         }
         ModelUpdateRequired = true;
     }
 }