Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
namespace QuantConnect.Algorithm.CSharp
{
    public class ModulatedResistanceContainmentField : QCAlgorithm
    {	
    	// pointer to hold our options symbol
    	Symbol optionSymbol;
    	// pointer to hold contract we want to call history for
    	OptionContract atmContract;

        public override void Initialize()
        {
            SetStartDate(2020, 2, 20);  //Set Start Date
            SetCash(100000);             //Set Strategy Cash
            // Add our equity symbol
            AddEquity("SPY", Resolution.Minute);
            // Add options data for our equity symbol
			var option = AddOption("SPY");
			// Filter options to ones expiring within 2 weeks
			option.SetFilter(0,14);
			
			// Store symbol for SPY options
			optionSymbol = option.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)
        {
	        // Get option chain from slice data if that options symbol exists
			OptionChain chain;
			if (data.OptionChains.TryGetValue(optionSymbol, out chain))
			{
				// we find at the money (ATM) put contract with farthest expiration and store in pointer
			    atmContract = chain
			        .OrderByDescending(x => x.Expiry)
			        .ThenBy(x => Math.Abs(chain.Underlying.Price - x.Strike))
			        .ThenByDescending(x => x.Right)
			        .FirstOrDefault();
			}
			
			// if we have picked a contract, let's get the last 10 minutes of historical data
			if(atmContract != null){
        		var historicalData = History(atmContract.Symbol, 10, Resolution.Minute);
        		foreach(var bar in historicalData){
        			Debug($"{bar.Time} , {bar.Close}");
        		}
        	}
        }
        
        

    }
}