Overall Statistics |
Total Trades 224 Average Win 0.03% Average Loss 0% Compounding Annual Return 3.343% Drawdown 0.500% Expectancy 0 Net Profit 3.750% Sharpe Ratio 2.023 Probabilistic Sharpe Ratio 92.198% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.024 Beta 0.008 Annual Standard Deviation 0.011 Annual Variance 0 Information Ratio 0.509 Tracking Error 0.176 Treynor Ratio 2.952 Total Fees $113.00 Estimated Strategy Capacity $1000.00 Lowest Capacity Asset PG 324FMVNTEE44M|PG R735QTJ8XC9X |
#region imports from AlgorithmImports import * #endregion from datetime import timedelta class LongStrangleAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 1, 1) #self.SetEndDate(2022, 2, 15) self.SetCash(100000) equity = self.AddEquity("PG", Resolution.Minute) option = self.AddOption("PG", Resolution.Minute) self.symbol = option.Symbol # set our strike/expiry filter for this option chain #option.SetFilter(-15, 15, timedelta(0), timedelta(7)) option.SetFilter(lambda option_filter_universe: option_filter_universe.IncludeWeeklys().Strikes(-20, 20).Expiration(0, 7)) # use the underlying equity GOOG as the benchmark self.SetBenchmark(equity.Symbol) def OnData(self,slice): optionchain = slice.OptionChains for i in slice.OptionChains: if i.Key != self.symbol: continue chains = i.Value contract_list = [x for x in chains] # if there is no contracts in this optionchain, pass the instance if (slice.OptionChains.Count == 0) or (len(contract_list) == 0): return # if there is no securities in portfolio, trade the options if not self.Portfolio.Invested: self.TradeOptions(optionchain) def TradeOptions(self,optionchain): for i in optionchain: 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 the deep OTM call option self.call = call_contracts[-1] # select the put options which have the same expiration date with the call option # sort the put options by strike price 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) def OnOrderEvent(self, orderEvent): self.Log(str(orderEvent))