I'm trying to store a significant amount of stock market quote data into a variable for querying against in memory. I need to be able to quickly find out the most recent market data for a stock ID, and query specific lengths of history for a specific stock.
For example, I might receive data on stock ID 5342 (always numeric) every few seconds... my original thought is to build an array of SortedDictionary's, with the SortedDictionary key being the DateTime of the quote, and its value being my custom struct of market data. Then the outer array would be the stock IDs... so I could call:
RecentPrice = PriceData[StockID].Values.Last();
Or I could iterate backwards through that stock's SortedDictionary until I hit a key older than the time range I'm looking for.
However I feel like there has to be a better (more efficient) method. Any ideas?
Edit: Instead of an array of SortedDictionaries... a Dictionary of SortedDictionaries might be better. For example:
public static Dictionary<int, SortedDictionary<DateTime, StockData>> PriceData =
new Dictionary<int, SortedDictionary<DateTime, StockData>>();
then:
RecentPrice = PriceData[StockID].Values.Last();
Thanks!