Esempio n. 1
0
        static IEnumerable <StockQuote> LoadQuotes(string symbol, string path)
        {
            using (var reader = File.OpenText(path))
            {
                reader.ReadLine();
                var prevQuote = default(StockQuote);
                for (var line = reader.ReadLine(); line != null; line = reader.ReadLine())
                {
                    var elements = line.Split(',');

                    var date   = DateTime.ParseExact(elements[0], "d-MMM-yy", CultureInfo.InvariantCulture);
                    var open   = decimal.Parse(elements[1]);
                    var high   = decimal.Parse(elements[2]);
                    var low    = decimal.Parse(elements[3]);
                    var close  = decimal.Parse(elements[4]);
                    var volume = long.Parse(elements[5]);

                    var quote = new StockQuote
                    {
                        Symbol = symbol,
                        Date   = date,
                        Close  = close,
                        High   = high,
                        Low    = low,
                        Open   = open,
                        Volume = volume
                    };

                    yield return(quote);

                    prevQuote = quote;
                }
            }
        }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var scheduler = new MyHistoricalScheduler();
            var quotes    = GetQuotes(scheduler, StockQuote.LoadQuotes());
            var query     = Query(quotes);

            chartUpdater = query.BindToChart(chart, 30);
            scheduler.Run(TimeSpan.FromSeconds(.1));
        }
        static IEnumerable<StockQuote> LoadQuotes(string symbol, string path)
        {
            using (var reader = File.OpenText(path))
            {
                reader.ReadLine();
                var prevQuote = default(StockQuote);
                for (var line = reader.ReadLine(); line != null; line = reader.ReadLine())
                {
                    var elements = line.Split(',');

                    var date = DateTime.ParseExact(elements[0], "d-MMM-yy", CultureInfo.InvariantCulture);
                    var open = decimal.Parse(elements[1]);
                    var high = decimal.Parse(elements[2]);
                    var low = decimal.Parse(elements[3]);
                    var close = decimal.Parse(elements[4]);
                    var volume = long.Parse(elements[5]);

                    var quote = new StockQuote
                    {
                        Symbol = symbol,
                        Date = date,
                        Close = close,
                        High = high,
                        Low = low,
                        Open = open,
                        Volume = volume
                    };

                    yield return quote;

                    prevQuote = quote;
                }
            }
        }