예제 #1
0
        static void Main(string[] args)
        {
            List <AlphaVantage> values = File.ReadAllLines("daily_MSFT.csv")
                                         .Skip(1)
                                         .Select(v => AlphaVantage.FromCsv(v))
                                         .ToList();

            Console.WriteLine("hello world!\nAverage MSFT for the past 7 days = $" + (float)avgMSFT(values));

            List <AlphaVantage> values2 = File.ReadAllLines("daily_AAPL.csv")
                                          .Skip(1)
                                          .Select(v => AlphaVantage.FromCsv(v))
                                          .ToList();

            Console.WriteLine("Highest Closing Price within the last 6 months = $" + (float)hiCloseAAPL(values2));

            List <AlphaVantage> values3 = File.ReadAllLines("daily_BA.csv")
                                          .Skip(1)
                                          .Select(v => AlphaVantage.FromCsv(v))
                                          .ToList();

            Console.WriteLine("Here are the differences between the opening and closing prices of BA");
            foreach (decimal temp in diffOpClBA(values3))
            {
                Console.WriteLine("$" + temp);
            }
        }
예제 #2
0
        public static AlphaVantage FromCsv(string csvLine)
        {
            string[]     values      = csvLine.Split(',');
            AlphaVantage dailyValues = new AlphaVantage();

            dailyValues.timestamp = Convert.ToDateTime(values[0]);
            dailyValues.open      = Convert.ToDecimal(values[1]);
            dailyValues.high      = Convert.ToDecimal(values[2]);
            dailyValues.low       = Convert.ToDecimal(values[3]);
            dailyValues.close     = Convert.ToDecimal(values[4]);
            dailyValues.volume    = Convert.ToDecimal(values[5]);
            return(dailyValues);
        }