Overall Statistics 
Total Trades
9
Average Win
1.97%
Average Loss
1.50%
Compounding Annual Return
6.283%
Drawdown
1.100%
Expectancy
0.074
Net Profit
1.058%
Sharpe Ratio
4.141
Loss Rate
60%
Win Rate
40%
ProfitLoss Ratio
1.32
Alpha
0.048
Beta
0.016
Annual Standard Deviation
0.015
Annual Variance
0
Information Ratio
6.663
Tracking Error
0.144
Treynor Ratio
3.896
Total Fees
$2.00

# QUANTCONNECT.COM  Democratizing Finance, Empowering Individuals. # Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from datetime import timedelta class ButterflySpreadAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 4, 1) self.SetEndDate(2017, 5, 30) self.SetCash(150000) 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(9, 9, timedelta(30), timedelta(60)) # use the underlying equity GOOG as the benchmark self.SetBenchmark(equity.Symbol) def OnData(self,slice): # if there is no securities in portfolio, trade the options if not self.Portfolio.Invested and self.Time.hour != 0 and self.Time.minute != 0: for i in slice.OptionChains: if i.Key != self.symbol: continue chain = i.Value # sorted the optionchain 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] # sorted the contracts according to their strike prices call_contracts = sorted(call,key = lambda x: x.Strike) if len(call_contracts) == 0: continue # choose OTM call self.otm_call = call_contracts[1] # choose ITM call self.itm_call = call_contracts[0] # choose ATM call self.atm_call = sorted(call_contracts,key = lambda x: abs(chain.Underlying.Price  x.Strike))[0] self.Sell(self.atm_call.Symbol ,2) self.Buy(self.itm_call.Symbol ,1) self.Buy(self.otm_call.Symbol ,1) def OnOrderEvent(self, orderEvent): self.Log(str(orderEvent))