Overall Statistics Total Trades2Average Win0%Average Loss0%Compounding Annual Return-6.961%Drawdown0.700%Expectancy0Net Profit-0.604%Sharpe Ratio-6.134Probabilistic Sharpe Ratio0.144%Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha-0.003Beta-0.099Annual Standard Deviation0.008Annual Variance0Information Ratio-8.215Tracking Error0.064Treynor Ratio0.507Total Fees$2.00Estimated Strategy Capacity$9100000.00Lowest Capacity AssetGOOCV 30HNN7PDAXNLY|GOOCV VP83T1ZUHROL
from AlgorithmImports import *

def Initialize(self):
self.SetStartDate(2017, 2, 1)
self.SetEndDate(2017, 3, 5)
self.SetCash(500000)

self.symbol = option.Symbol
option.SetFilter(self.UniverseFunc)

def UniverseFunc(self, universe):
return universe.IncludeWeeklys().Strikes(-15, 15).Expiration(timedelta(0), timedelta(31))

def OnData(self, slice):
if self.Portfolio.Invested: return

# Get the OptionChain
chain = slice.OptionChains.get(self.symbol, None)
if not chain: return

# Get the furthest expiry date of the contracts
expiry = sorted(chain, key = lambda x: x.Expiry, reverse=True)[0].Expiry

# Select the put Option contracts with the furthest expiry
puts = [i for i in chain if i.Expiry == expiry and i.Right == OptionRight.Put]
if len(puts) == 0: return

# Select the ITM and OTM contract strike prices from the remaining contracts
put_strikes = sorted([x.Strike for x in puts])
otm_strike = put_strikes[0]
itm_strike = put_strikes[-1]

option_strategy = OptionStrategies.BearPutSpread(self.symbol, itm_strike, otm_strike, expiry)
self.Buy(option_strategy, 1)