I am trying to store a significant portion of stock market quotation data in a variable for a query in memory. I need to quickly find out the latest market data for a stock identifier and request specific history lengths for a specific stock.
For example, I could get data on a stock ID 5342 (always numeric) every few seconds ... my original thought was to build an array of SortedDictionary, with the SortedDictionary key being a DateTime quote, and its value is my custom market data structure. Then the external array will be the stock identifier ... so that I could call:
RecentPrice = PriceData[StockID].Values.Last();
Or I could scroll back through this stock of SortedDictionary until I press a key older than the range of time I'm looking for.
However, I feel that there should be a better (more efficient) method. Any ideas?
Edit: Instead of an array of SortedDictionaries ... A SortedDictionaries dictionary could be better. For instance:
public static Dictionary<int, SortedDictionary<DateTime, StockData>> PriceData = new Dictionary<int, SortedDictionary<DateTime, StockData>>();
then
RecentPrice = PriceData[StockID].Values.Last();
Thanks!
source share