Now that options data is available at QuantConnect, I was trying to create a log of historical volatility skew for a selected symbol. Here is an example chart of GLD skew based on fixed 90 - 110 moneyness strikes:

http://www.nextedgecapital.com/an-options-market-perspective-of-gold/
http://nextedgecapital.com/wp-content/uploads/2014/11/GLD-vs-90-110-Implied-Volatility-SKEW-Inverted-Scale.png

Attached is my first attempt to collect the data for a portion of the chart. The code interpolates implied volatilities of the nearest expiration contracts daily at a specific time.

This backtest runs out of memory when processing just 2 months of history ("Memory Usage Maxed Out"); also, it runs quite slowly. I suspect contract pre-filtering and ranking could be done more efficiently. How could this code be optimized for a smaller memory use and a more performant option contract selection?