Esempio n. 1
0
        public static List <FinancialPoint> ReadFinancialData(string fileName)
        {
            string       longFileName = string.Empty;
            StreamReader reader;
            var          dataSource = new List <FinancialPoint>();

            try {
                longFileName = FileNamePrefix + fileName;
                Uri uri = new Uri(longFileName, UriKind.RelativeOrAbsolute);
                StreamResourceInfo info = Application.GetResourceStream(uri);
                reader = new StreamReader(info.Stream);
                while (!reader.EndOfStream)
                {
                    string line   = reader.ReadLine();
                    var    values = line.Split(',');
                    var    point  = new FinancialPoint();
                    point.DateTimeArgument = DateTime.ParseExact(values[0], "yyyy.MM.dd", null);
                    point.OpenValue        = double.Parse(values[1], CultureInfo.InvariantCulture);
                    point.HighValue        = double.Parse(values[2], CultureInfo.InvariantCulture);
                    point.LowValue         = double.Parse(values[3], CultureInfo.InvariantCulture);
                    point.CloseValue       = double.Parse(values[4], CultureInfo.InvariantCulture);
                    dataSource.Add(point);
                }
            }
            catch {
                throw new Exception("It's impossible to load " + fileName);
            }
            return(dataSource);
        }
Esempio n. 2
0
        List <FinancialPoint> CreateDataSource()
        {
            XDocument             document = DataLoader.LoadXmlFromResources("/Data/Dell.xml");
            List <FinancialPoint> result   = new List <FinancialPoint>();

            if (document != null)
            {
                foreach (XElement element in document.Element("Dell").Elements())
                {
                    FinancialPoint point = new FinancialPoint();
                    point.Argument   = element.Element("Argument").Value;
                    point.OpenValue  = Convert.ToDouble(element.Element("OpenValue").Value, CultureInfo.InvariantCulture);
                    point.CloseValue = Convert.ToDouble(element.Element("CloseValue").Value, CultureInfo.InvariantCulture);
                    point.LowValue   = Convert.ToDouble(element.Element("LowValue").Value, CultureInfo.InvariantCulture);
                    point.HighValue  = Convert.ToDouble(element.Element("HighValue").Value, CultureInfo.InvariantCulture);
                    result.Add(point);
                }
            }
            return(result);
        }