Overall Statistics
Total Trades
8
Average Win
0%
Average Loss
0%
Compounding Annual Return
-24.540%
Drawdown
0.900%
Expectancy
0
Net Profit
-0.372%
Sharpe Ratio
-2.571
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.302
Beta
-0.965
Annual Standard Deviation
0.072
Annual Variance
0.005
Information Ratio
-5.309
Tracking Error
0.13
Treynor Ratio
0.192
Total Fees
$2.00
from datetime import timedelta
class algorithm(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2017, 1, 1)
        self.SetEndDate(2017, 1, 5)
        self.SetCash(100000)
        equity = self.AddEquity("GOOG", Resolution.Minute)
        option = self.AddOption("GOOG", Resolution.Minute)
        self.symbol = option.Symbol
        # set our strike/expiry filter for this option chain
        option.SetFilter(-15, 15, timedelta(35), timedelta(50))
        # use the underlying equity GOOG as the benchmark
        self.SetBenchmark(equity.Symbol)
    
    def OnData(self, data):        
        for i in data.OptionChains:
            if i.Key != self.symbol: continue
            chain = i.Value
            # sorted the option chain by expiration date and choose the furthest date
            expiry = sorted(chain,key = lambda x: x.Expiry, reverse=True)[0].Expiry
            # filter the call options from the contracts expires on that date
            call = [i for i in chain if i.Expiry == expiry and i.Right == 0]
            call_contracts = sorted(call,key = lambda x: x.Strike)
            if len(call_contracts) == 0: continue
            # choose the deep OTM call option
            self.call = call_contracts[-1]
            put_contracts = sorted([i for i in chain if i.Expiry == expiry and i.Right == 1], key = lambda x: x.Strike)
            # choose the deep OTM put option
            self.put = put_contracts[0]
            self.Sell(self.call.Symbol ,1)
            self.Sell(self.put.Symbol ,1)