Representing historical prices of certain financial instruments I have an object which represents historical prices of certain financial instruments as below:

 class DailyPrice
        {
            public DateTime? Date { get; set; }
            public double? Price { get; set; }  
        }


This needs to be converted into QuarterlyPrice objects which will have all daily prices aggregated:

class QuarterlyPrice
        {
            public QuarterlyPrice()
            {
                DailyViews = new List&lt;DailyPrice&gt;();
            }
            public DateTime? Date { get; set; }
            public double? Price { get; set; }
            public List&lt;DailyPrice&gt; DailyViews { get; set; }
        }


Now I need to aggregate the daily prices into quarterly prices. I already have the logic of finding the quarters given a date range and the aggregation logic is as follows:

class Aggregater
        {
            public IEnumerable&lt;QuarterlyPrice&gt; GetQuarterlyAggViews(List&lt;DailyPrice&gt; dailyViews)
            {
                var dates = dailyViews.Where(x =&gt; x.Date.HasValue).Select(x =&gt; x.Date.Value).ToList();
                var dictionary = dailyViews.ToDictionary(x =&gt; x.Date.Value, x =&gt; x);

                //Will give me quarterly dates from the last to fist.
                var allQuarters = dates.Last().GetAllQuarters(dates.First());

                foreach (var quarter in allQuarters)
                {
                    var quarterlyPrice = new QuarterlyPrice();
                    var daily = dictionary.Where(x =&gt; x.Key &lt;= quarter).Select(lx =&gt; lx.Value).ToList();
                    quarterlyPrice.DailyPrice.AddRange(daily);
                    quarterlyPrice.Date = quarter;
                    quarterlyPrice.Price = daily.Sum(x =&gt; x.Price);
                    yield return quarterlyPrice;
                }
            }
        }


My questions are the following:


My daily prices can spawn 10-20 years and there will be as many daily price object. While aggregating them I'm putting them in the dictionary assuming the lookup would be quicker. Is this the correct thing to do? Is there a way to optimize the look up a bit further?
How can I write a better aggregation logic for converting daily to quarterly price?


Note: The daily price list is sorted using .NET 4.0.
What about a slightly different way of creating your classes?

class Quarter
{
    int Year { get; set; }
    List&lt;DailyPrice&gt; Prices { get; set; }
}
class DailyPrice
{
    public DailyPrice(DateTime? date, double? price)
    {
        Date = date;
        Price = price;
        QuarterPeriod = FindOrCreateQuarterObject(this);
    }
    public DateTime? Date { get; set; }
    public double? Price { get; set; }
    public Quarter QuarterPeriod { get; set; }
}


As you create your DailyPrice objects, you can add to the pointer list in the appropriate quarter.  That way if you are collecting aggregate data by quarter all you have to do is spin through your quarters, and then do the aggregation on each quarter's list.

It takes a little more time upfront, and a few more pointers, but you'll save time if you plan to do multiple calculations.