private List <MarketIndex> ParseMarketIndexes(XDocument doc)
        {
            if (doc == null)
            {
                return(null);
            }
            List <MarketIndex> marketIndexes = new List <MarketIndex>();

            IEnumerable <XElement> quotes = doc.Root.Descendants("finance");

            foreach (var quote in quotes)
            {
                var index = new MarketIndex();
                index.Symbol            = GetAttributeData(quote, "symbol");;
                index.Last              = GetDecimal(quote, "last");
                index.Change            = GetDecimal(quote, "change");
                index.PercentChange     = GetDecimal(quote, "perc_change");
                index.RetrievalDateTime = DateTime.Now;
                index.Title             = GetAttributeData(quote, "company");
                index.DayHigh           = GetDecimal(quote, "high");
                index.DayLow            = GetDecimal(quote, "low");
                index.Volume            = GetDecimal(quote, "volume");
                index.Open              = GetDecimal(quote, "open");
                marketIndexes.Add(index);
            }
            return(marketIndexes);
        }
示例#2
0
        public bool TryGetIndexData(MarketIndex index, out Dictionary <string, decimal> tickersProportions, out string message)
        {
            /*
             * Nasdaq 100
             *      Webs
             *      https://www.nasdaq.com/market-activity/quotes/nasdaq-ndx-index
             *
             *      Data
             *      https://api.nasdaq.com/api/quote/list-type/nasdaq100
             *
             */

            throw new NotImplementedException();
        }
示例#3
0
        public static void CreateMarketIndex(MarketIndexModel marketIndexModel)
        {
            using (ctaDBEntities entities = new ctaDBEntities())
            {
                MarketIndex mIndex = new MarketIndex()
                {
                    name = marketIndexModel.name, market_id = marketIndexModel.market_id
                };
                entities.MarketIndexes.Add(mIndex);
                entities.SaveChanges();

                if (!(entities.Database.Connection.State == ConnectionState.Closed))
                {
                    entities.Database.Connection.Close();
                }
            }
        }
示例#4
0
        public static void DeleteMarketIndex(int ID)
        {
            using (ctaDBEntities entities = new ctaDBEntities())
            {
                MarketIndex mIndex = entities.MarketIndexes.Where(s => s.Id == ID).FirstOrDefault();
                if (mIndex != null)
                {
                    entities.MarketIndexes.Remove(mIndex);
                    entities.SaveChanges();
                }

                if (!(entities.Database.Connection.State == ConnectionState.Closed))
                {
                    entities.Database.Connection.Close();
                }
            }
        }
示例#5
0
        public static void UpdateMarketIndex(MarketIndexModel marketIndexModel)
        {
            using (ctaDBEntities entities = new ctaDBEntities())
            {
                MarketIndex mIndex = entities.MarketIndexes.Where(s => s.Id == marketIndexModel.Id).FirstOrDefault();
                if (mIndex != null)
                {
                    mIndex.name      = marketIndexModel.name;
                    mIndex.market_id = marketIndexModel.market_id;
                    entities.SaveChanges();
                }

                if (!(entities.Database.Connection.State == ConnectionState.Closed))
                {
                    entities.Database.Connection.Close();
                }
            }
        }
 public bool TryGetIndexData(MarketIndex index, out Dictionary <string, decimal> tickersProportions, out string message)
 {
     throw new NotImplementedException();
 }