Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public List <MarketDescription> GetMarketsDescriptions()
        {
            lock (_lockObject)
            {
                List <MarketDescription> marketsDictionary = new List <MarketDescription>();

                using (NpgsqlConnection mySqlConnection = new NpgsqlConnection(ConnectionString))
                {
                    mySqlConnection.Open();
                    const string storedProcedure = "sports.GetNBAMarkets";

                    using (NpgsqlCommand mySqlCommand = new NpgsqlCommand(storedProcedure, mySqlConnection))
                    {
                        mySqlCommand.CommandType = CommandType.StoredProcedure;

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

                                return(marketsDictionary);
                            }

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

                                marketsDictionary.Add(md);
                            }

                            return(marketsDictionary);
                        }
                    }
                }
            }
        }
Exemplo n.º 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[WnbaModelDataKeys.Adjust] = ProcesAdjustment(marketDescription, adjustment,
                                                                        ModelData[WnbaModelDataKeys.Adjust]);
                 Logger.Info($"Updated adjustment odds for {GameId} ({marketDescription.ShortName}  {adjustment.Value})");
             }
         }
         ModelUpdateRequired = true;
     }
 }