Overall Statistics Total Trades2Average Win0%Average Loss-1.22%Compounding Annual Return-43.585%Drawdown1.500%Expectancy-1Net Profit-1.221%Sharpe Ratio-10.646Loss Rate100%Win Rate0%Profit-Loss Ratio0Alpha-0.188Beta-16.051Annual Standard Deviation0.041Annual Variance0.002Information Ratio-10.962Tracking Error0.042Treynor Ratio0.027Total Fees\$1.00
```from datetime import timedelta

class optionExample(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2016, 1, 1)
self.SetEndDate(2016, 1, 8)
self.SetCash(100000)

self.option_symbol = option.Symbol

# set our strike/expiry filter for this option chain
option.SetFilter(self.UniverseFunc)

def OnData(self,slice):

if self.Time.hour == 15 and self.Time.minute == 30:
option_invested = [x.Key.Value for x in self.Portfolio if x.Value.Invested and x.Value.Type==SecurityType.Option]
#  Print to log
for contract in option_invested:
quantity = self.Portfolio[contract].Quantity
lastPrice = self.Securities[contract].Price
self.Log("Contract: " + str(contract) + " - Quantity: " + str(quantity) + " - Last Price: " + str(lastPrice))

if not self.Portfolio.Invested:
for i in slice.OptionChains:
chain = i.Value
call = [i for i in chain if i.Right == OptionRight.Call]
contracts =  sorted(sorted(call, key=lambda x: x.Expiry, reverse=True),
key=lambda x: abs(x.UnderlyingLastPrice - x.Strike))
atm_contract = contracts

# Sell ATM Call Option Contract
if len(contracts) == 0: continue
symbol = contracts.Symbol

# Place market price.
self.MarketOrder(symbol, 1)

def UniverseFunc(self, universe):
# include weekly contracts
return universe.IncludeWeeklys().Expiration(TimeSpan.FromDays(0),TimeSpan.FromDays(7)).Strikes(-2,2)```