Exemplo n.º 1
0
        /// <summary>
        /// fetch a quick quote from the yahoo service. returns a quick quote object.
        /// </summary>
        /// <param name="sym"></param>
        /// <returns></returns>
        public static QuickQuote Fetch(string sym)
        {
            QuickQuote qq = new QuickQuote();

            if (sym == "")
            {
                return(qq);
            }
            WebClient wc  = new WebClient();
            string    res = wc.DownloadString(baseurl + sym);

            res = res.Replace("\"", "");
            string [] r = res.Split(',');
            qq.Symbol  = r[(int)q.sym];
            qq.Company = r[(int)q.company];
            try
            {
                qq.time  = DateTime.Parse(r[(int)q.time]);
                qq.date  = DateTime.Parse(r[(int)q.date]);
                qq.price = Convert.ToDecimal(r[(int)q.last]);
                qq.vol   = Convert.ToInt32(r[(int)q.vol]);
                qq.open  = Convert.ToDecimal(r[(int)q.open]);
                qq.low   = Convert.ToDecimal(r[(int)q.low]);
                qq.high  = Convert.ToDecimal(r[(int)q.high]);
            }
            catch (Exception) {}
            return(qq);
        }
Exemplo n.º 2
0
        /// <summary>
        /// fetch a quick quote from the yahoo service. returns a quick quote object.
        /// </summary>
        /// <param name="sym"></param>
        /// <returns></returns>
        public static QuickQuote Fetch(string sym)
        {
            QuickQuote qq = new QuickQuote();
            if (sym == "") return qq;
            WebClient wc = new WebClient();
            string res  = wc.DownloadString(baseurl + sym);
            res = res.Replace("\"", "");
            string [] r = res.Split(',');
            qq.Symbol = r[(int)q.sym];
            qq.Company = r[(int)q.company];
            decimal v;
            try 
            {
                qq.time = DateTime.Parse(r[(int)q.time]);
                qq.date = DateTime.Parse(r[(int)q.date]);
                qq.price = Convert.ToDecimal(r[(int)q.last]);
                qq.vol = Convert.ToInt32(r[(int)q.vol]);
                qq.open = Convert.ToDecimal(r[(int)q.open]);
                qq.low = Convert.ToDecimal(r[(int)q.low]);
                qq.high = Convert.ToDecimal(r[(int)q.high]);
                if (decimal.TryParse(r[(int)q.change].Replace("%", string.Empty), out v))
                    qq.change = v;
                if (decimal.TryParse(r[(int)q.changeper].Replace("%", string.Empty), out v))
                    qq.changeper = v;
                if (decimal.TryParse(r[(int)q.eps], out v))
                    qq.eps = v;
                if (decimal.TryParse(r[(int)q.pe], out v))
                    qq.pe = v;
                if (decimal.TryParse(r[(int)q.marketcap], out v))
                    qq.marketcap = v;
                if (decimal.TryParse(r[(int)q.afterhour], out v))
                    qq.afterhours = v;
                
                // get 52week range
                string [] range = r[(int)q.fiftytworange].Split(',');
                // if we have two records, try to parse
                if (range.Length == 2)
                {
                    
                    if (decimal.TryParse(r[0], out v))
                        qq.low52 = v;
                    if (decimal.TryParse(r[1], out v))
                        qq.high52 = v;
                }
            }
            catch (Exception) {}
            return qq;

        }
Exemplo n.º 3
0
 /// <summary>
 /// fetch a quick quote from the yahoo service. returns a quick quote object.
 /// </summary>
 /// <param name="sym"></param>
 /// <returns></returns>
 public static QuickQuote Fetch(string sym)
 {
     QuickQuote qq = new QuickQuote();
     if (sym == "") return qq;
     WebClient wc = new WebClient();
     string res  = wc.DownloadString(baseurl + sym);
     res = res.Replace("\"", "");
     string [] r = res.Split(',');
     qq.Symbol = r[(int)q.sym];
     qq.Company = r[(int)q.company];
     try
     {
         qq.time = DateTime.Parse(r[(int)q.time]);
         qq.date = DateTime.Parse(r[(int)q.date]);
         qq.price = Convert.ToDecimal(r[(int)q.last]);
         qq.vol = Convert.ToInt32(r[(int)q.vol]);
         qq.open = Convert.ToDecimal(r[(int)q.open]);
         qq.low = Convert.ToDecimal(r[(int)q.low]);
         qq.high = Convert.ToDecimal(r[(int)q.high]);
     }
     catch (Exception) {}
     return qq;
 }
Exemplo n.º 4
0
        /// <summary>
        /// fetch a quick quote from the yahoo service. returns a quick quote object.
        /// </summary>
        /// <param name="sym"></param>
        /// <returns></returns>
        public static QuickQuote Fetch(string sym)
        {
            QuickQuote qq = new QuickQuote();

            if (sym == "")
            {
                return(qq);
            }
            WebClient wc  = new WebClient();
            string    res = wc.DownloadString(baseurl + sym);

            res = res.Replace("\"", "");
            string [] r = res.Split(',');
            qq.symbol  = r[(int)q.sym];
            qq.Company = r[(int)q.company];
            decimal v;

            try
            {
                qq.time  = DateTime.Parse(r[(int)q.time]);
                qq.date  = DateTime.Parse(r[(int)q.date]);
                qq.price = Convert.ToDecimal(r[(int)q.last]);
                qq.vol   = Convert.ToInt32(r[(int)q.vol]);
                qq.open  = Convert.ToDecimal(r[(int)q.open]);
                qq.low   = Convert.ToDecimal(r[(int)q.low]);
                qq.high  = Convert.ToDecimal(r[(int)q.high]);
                if (decimal.TryParse(r[(int)q.change].Replace("%", string.Empty), out v))
                {
                    qq.change = v;
                }
                if (decimal.TryParse(r[(int)q.changeper].Replace("%", string.Empty), out v))
                {
                    qq.changeper = v;
                }
                if (decimal.TryParse(r[(int)q.eps], out v))
                {
                    qq.eps = v;
                }
                if (decimal.TryParse(r[(int)q.pe], out v))
                {
                    qq.pe = v;
                }
                if (decimal.TryParse(r[(int)q.marketcap], out v))
                {
                    qq.marketcap = v;
                }
                if (decimal.TryParse(r[(int)q.afterhour], out v))
                {
                    qq.afterhours = v;
                }

                // get 52week range
                string [] range = r[(int)q.fiftytworange].Split(',');
                // if we have two records, try to parse
                if (range.Length == 2)
                {
                    if (decimal.TryParse(r[0], out v))
                    {
                        qq.low52 = v;
                    }
                    if (decimal.TryParse(r[1], out v))
                    {
                        qq.high52 = v;
                    }
                }
            }
            catch (Exception) {}
            return(qq);
        }