title: Best way to store lots of stock data in memory (variable)
body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>RecentPrice = PriceData[StockID].Values.Last();
  </code></pre>
  
  <p>Or I could iterate backwards through that stock's SortedDictionary until I hit a key older than the time range I'm looking for.</p>
  
  <p>However I feel like there has to be a better (more efficient) method.  Any ideas?</p>
  
  <p><strong>Edit:</strong>  Instead of an array of SortedDictionaries... a Dictionary of SortedDictionaries might be better. 
  For example:</p>
  
  <pre><code>public static Dictionary&lt;int, SortedDictionary&lt;DateTime, StockData&gt;&gt; PriceData = 
      new Dictionary&lt;int, SortedDictionary&lt;DateTime, StockData&gt;&gt;();
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>RecentPrice = PriceData[StockID].Values.Last();
  </code></pre>
  
  <p>Thanks!</p>