Overall Statistics Total Orders5Average Win0%Average Loss-0.34%Compounding Annual Return-0.822%Drawdown0.900%Expectancy-0.5Start Equity100000End Equity99867.5Net Profit-0.132%Sharpe Ratio-0.854Sortino Ratio-0.753Probabilistic Sharpe Ratio25.191%Loss Rate50%Win Rate50%Profit-Loss Ratio0Alpha-0.01Beta0.096Annual Standard Deviation0.015Annual Variance0Information Ratio0.138Tracking Error0.123Treynor Ratio-0.137Total Fees$4.00Estimated Strategy Capacity$130000000.00Lowest Capacity AssetIBM 2ZN0UI19JRV52|IBM R735QTJ8XC9XPortfolio Turnover0.95%
#region imports
from AlgorithmImports import *
#endregion

class ProtectivePutAlgorithm(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2014, 1, 1)
self.SetEndDate(2014, 3, 1)
self.SetCash(100000)

self.symbol = option.Symbol
option.set_filter(lambda universe: universe.include_weeklys().naked_put(30, 0))

self.put = None

# use the underlying equity as the benchmark
self.SetBenchmark(self.symbol.Underlying)

def OnData(self, slice):

if self.put and self.Portfolio[self.put].Invested:
return

chain = slice.OptionChains.get(self.symbol)
if not chain:
return

# Find ATM put with the farthest expiry
expiry = max([x.Expiry for x in chain])
put_contracts = sorted([x for x in chain
if x.Right == OptionRight.Put and x.Expiry == expiry],
key=lambda x: abs(chain.Underlying.Price - x.Strike))

if not put_contracts:
return

atm_put = put_contracts[0]

protective_put = OptionStrategies.ProtectivePut(self.symbol, atm_put.Strike, expiry)
self.put = atm_put.Symbol