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
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 
{
    public partial class CoveredCallAlgorithm : QCAlgorithm
    {
    	Symbol _optionSymbol;
		// Manual add symbols required in your initialize method:
		public override void Initialize() {
		     SetStartDate(2015, 8, 8);
            SetEndDate(2015,11, 12);

		    var option = AddOption("GOOG", Resolution.Minute);
		    _optionSymbol = option.Symbol;
		    // set our strike/expiry filter for this option chain
		    option.SetFilter(-2, +2, TimeSpan.Zero, TimeSpan.FromDays(10));
		}
		
		// v3.0 Technique: Access data via grouped time slice method handlers:
		public override void OnData(Slice slice) {
		    OptionChain chain;
		    if (slice.OptionChains.TryGetValue(_optionSymbol, 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.Call
		            where optionContract.Expiry == Time.Date
		            where optionContract.Strike < chain.Underlying.Price
		            select optionContract
		            ).Skip(2).FirstOrDefault();
		
		        if (contract != null)
		        {
		            var quantity = CalculateOrderQuantity(contract.Symbol, -1m);
		            MarketOrder(contract.Symbol, quantity);
		            MarketOnCloseOrder(contract.Symbol, -quantity);
		        }else{
		        	Log("no contract");
		        }
		    }else{
		    	Log("no chain available");
		    }
		}
    }
}