Пример #1
0
        private void ReadHistory()
        {
            var data       = Helper.GetStockHistory(ticker);
            var tmpHistory = new List <Tick>();

            using (StringReader read = new StringReader(data))
            {
                string line;
                while ((line = read.ReadLine()) != null)
                {
                    var values = line.Split(',');

                    if (values[0] == "quote_date")
                    {
                        // first row -> skip
                    }
                    else
                    {
                        var timestamp = DateTime.ParseExact(values[0], "yyyyMMdd", CultureInfo.InvariantCulture).ToLocalTime();
                        var open      = double.Parse(values[3]);
                        var high      = double.Parse(values[4]);
                        var low       = double.Parse(values[5]);
                        var close     = double.Parse(values[6]);
                        var tick      = new Tick()
                        {
                            Timestamp = timestamp, Open = open, High = high, Low = low, Close = close
                        };

                        tmpHistory.Insert(0, tick);
                    }
                }
            }
            foreach (var item in tmpHistory)
            {
                history.Insert(0, item);
                history.CalculateIndicators();
            }
            history = history.OrderBy(v => v.Timestamp).ToList();
        }