public void CacheSimulator()
        {
            //decimal? lastprice = 0;
            //decimal? prevprice = 0;
            int i         = 0;
            var allStocks = new List <StockSymbol>();

            string[] stocksymbols = new string[] { "HLF", "IPG", "AMD", "DNKN", "POT", "TUES", "JBLU", "ACN", "MSFT", "BAC", "BCS", "AIG", "CMG", "FIT" };
            Random   random       = new Random(DateTime.Now.Millisecond);

            foreach (string s in stocksymbols)
            {
                i++;
                decimal lastprice = 0;
                decimal prevprice = 0;
                lastprice = Convert.ToDecimal(random.Next(140, 400)) * .3213m;
                prevprice = Convert.ToDecimal(lastprice) * 1.532m;
                StockSymbol ss = new StockSymbol()
                {
                    Id = i, Symbol = s, LastPrice = lastprice, PreviousPrice = prevprice
                };
                allStocks.Add(ss);
            }

            //var serializer = new NewtonsoftSerializer();
            //var cacheClient = new StackExchangeRedisCacheClient(serializer);
            string key = "StocksDecisionAllStocks";

            stackCache.Remove(key);
            stackCache.Add(key, allStocks, DateTimeOffset.Now.AddHours(40));
        }
        public StockSymbol GetDataPerSymbol(string symbol)
        {
            string rawdata = GetRawData(symbol);

            StockSymbol stockSymbol = new StockSymbol();

            string cleandata = rawdata.Replace("//", "");

            cleandata = cleandata.Replace("[", "");
            cleandata = cleandata.Replace("]", "");
            var    details        = JObject.Parse(cleandata);
            var    metadata       = JObject.Parse(details["Meta Data"].ToString());
            var    lastRefresh    = DateTime.Parse(metadata["3. Last Refreshed"].ToString()).ToString("yyyy-MM-dd");
            var    stocks         = JObject.Parse(details["Time Series (Daily)"].ToString());
            var    stock          = JObject.Parse(stocks[lastRefresh].ToString());
            string strPreviousDay = GetPreviousWorkingDay(DateTime.Parse(lastRefresh)).ToString("yyyy-MM-dd");
            var    prevStock      = JObject.Parse(stocks[strPreviousDay].ToString());

            stockSymbol.Symbol        = symbol;
            stockSymbol.LastPrice     = decimal.Parse(stock["5. adjusted close"].ToString());
            stockSymbol.PreviousPrice = decimal.Parse(prevStock["5. adjusted close"].ToString());

            return(stockSymbol);
        }