Overall Statistics
namespace QuantConnect.Algorithm.CSharp
{
    public class VerticalResistanceThrustAssembly : QCAlgorithm
    {
    	private Symbol spySymbol;
        public override void Initialize()
        {
            SetStartDate(2016, 12, 7);  //Set Start Date
            SetEndDate(2017,1,21);
            SetCash(1000000);             //Set Strategy Cash
			var spy = AddEquity("SPY", Resolution.Minute);
			var symbols = new [] {QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)};
			SetUniverseSelection(new ManualUniverseSelectionModel(symbols));
			spy.SetDataNormalizationMode(DataNormalizationMode.Raw);
    		spySymbol = spy.Symbol;
    		var option = AddOption("SPY");
    		option.SetFilter(-5, 5, TimeSpan.Zero, TimeSpan.FromDays(10));
    		SetBenchmark(spy.Symbol);
        }

        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// Slice object keyed by symbol containing the stock data
        public override void OnData(Slice data)
        {
          if (!Portfolio.Invested)
            {
                OptionChain chain;
                if (data.OptionChains.TryGetValue("SPY", out chain))
                {
                    // find the second call strike under market price expiring today
                    var contract = (
                        from optionContract in chain.OrderByDescending(x => x.Strike)
                        where optionContract.Right == OptionRight.Put
                        where optionContract.Strike < chain.Underlying.Price 
                        select optionContract
                        ).FirstOrDefault();

                    if (contract != null)
                    {
                        SetHoldings(contract.Symbol, -1);
                    }
                }
            }
        }
    }
}