Beispiel #1
0
        private void RaisePricesFromCsv()
        {
            // read csv file line-by-line.
            using (var reader = new StreamReader(fileName)) {
                string s;

                reader.ReadLine();
                while ((s = reader.ReadLine()) != null)
                {
                    var data = s.Split(new char[] { ',', ' ' },
                                       StringSplitOptions.RemoveEmptyEntries);

                    if (data.Length < 5)
                    {
                        continue;
                    }

                    var p = new PriceItem {
                        Date  = DateTime.Parse(data[0]),
                        Last  = decimal.Parse(data[1]),
                        Bid   = decimal.Parse(data[3]),
                        Offer = decimal.Parse(data[4]),
                    };
                    RaiseNewPrice(p);
                }
            }
        }
Beispiel #2
0
        public void AddSeedPrice(DateTime date, decimal last,
                                 decimal bid, decimal offer)
        {
            var item = new PriceItem {
                Date  = date,
                Last  = last,
                Bid   = bid,
                Offer = offer
            };

            prices.Add(item);
        }
Beispiel #3
0
 protected void RaiseNewPrice(PriceItem item)
 {
     NewPrice?.Invoke(this, new NewPriceEventArgs(item));
 }
Beispiel #4
0
 public NewPriceEventArgs(PriceItem item)
 {
     NewPrice = item;
 }