Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
355.030%
Drawdown
47.700%
Expectancy
0
Net Profit
0%
Sharpe Ratio
1.586
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
2.635
Beta
-6.693
Annual Standard Deviation
1.303
Annual Variance
1.697
Information Ratio
1.45
Tracking Error
1.367
Treynor Ratio
-0.309
Total Fees
$1.00
namespace QuantConnect 
{
    public partial class CoveredCallAlgorithm : QCAlgorithm
    {
    	Symbol _optionSymbol;
		// Manual add symbols required in your initialize method:
		public override void Initialize() {
		     SetStartDate(2014, 3, 1);
            SetEndDate(2014, 5, 1);

		    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 (!Portfolio.HoldStock && 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)
		            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");
		    }
		}
    }
}