Overall Statistics
Total Trades
13
Average Win
0.12%
Average Loss
-0.14%
Compounding Annual Return
-1.788%
Drawdown
0.300%
Expectancy
-0.236
Net Profit
-0.142%
Sharpe Ratio
-3.102
Probabilistic Sharpe Ratio
10.300%
Loss Rate
60%
Win Rate
40%
Profit-Loss Ratio
0.91
Alpha
-0.007
Beta
-0.011
Annual Standard Deviation
0.005
Annual Variance
0
Information Ratio
-11.647
Tracking Error
0.074
Treynor Ratio
1.506
Total Fees
$9.00
using QuantConnect.Securities.Option;

namespace QuantConnect.Algorithm.CSharp
{
    public class ModulatedQuantumReplicator : QCAlgorithm
    {
        public Symbol symbol;

        public override void Initialize()
        {
            SetStartDate(2017, 2, 1); 
            SetEndDate(2017, 3, 1);
            SetCash(500000);
            
            var equity = AddEquity("GOOG", Resolution.Minute);
            var option = AddOption("GOOG", Resolution.Minute);
            option.SetFilter(-15, 15, 0, 40);
            
            symbol = option.Symbol;
            SetBenchmark(equity.Symbol);
        }

        public override void OnData(Slice data)
        {
            // If there is undelying assets in portfolio at expiration, liquidate the stocks in order to roll into new contracts
            if (Portfolio["GOOG"].Quantity != 0)
            {
                Liquidate();
            }
            
            if (Portfolio.Invested || data.OptionChains.Count == 0)
            {
                return;
            }
            
            OptionChain chain;
            if (data.OptionChains.TryGetValue(symbol, out chain))
            {
                if (chain.Count() == 0)
                {
                    return;
                }
                
                var expiry = chain.OrderBy(c => c.Expiry).Last().Expiry;
                
                var callContracts = chain
                    .Where(c => c.Expiry == expiry && c.Right == OptionRight.Call)
                    .OrderBy(c => c.Strike)
                    .ToArray();
                    
                var putContracts = chain
                    .Where(c => c.Expiry == expiry && c.Right == OptionRight.Put)
                    .OrderBy(c => c.Strike)
                    .ToArray();
                    
                if (callContracts.Length == 0 || putContracts.Length == 0)
                {
                    return;
                }
                
                var otmPutLower = putContracts[0];
                var otmPut = putContracts[10];
                var otmCall = callContracts[callContracts.Length - 10];
                var otmCallHigher = callContracts.Last();
                
                // if there is no securities in portfolio, trade the options
                Buy(otmPutLower.Symbol, 1);
                Sell(otmPut.Symbol, 1);
                Sell(otmCall.Symbol, 1);
                Buy(otmCallHigher.Symbol, 1);
            }
        } 
    }
}