Overall Statistics |
Total Trades 6 Average Win 0.00% Average Loss -0.01% Compounding Annual Return -2.485% Drawdown 0.300% Expectancy -0.656 Net Profit -0.211% Sharpe Ratio -6.562 Probabilistic Sharpe Ratio 0.038% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 0.03 Alpha 0.005 Beta -0.047 Annual Standard Deviation 0.003 Annual Variance 0 Information Ratio -8.131 Tracking Error 0.061 Treynor Ratio 0.383 Total Fees $3.00 Estimated Strategy Capacity $0 Lowest Capacity Asset SPY R735QTJ8XC9X |
#region imports from AlgorithmImports import * #endregion # https://quantpedia.com/Screener/Details/20 class VolatilityRiskPremiumStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 2, 1) self.SetEndDate(2017, 3, 5) self.SetCash(500000) option = self.AddOption("SPY", Resolution.Minute) self.symbol = option.Symbol option.SetFilter(self.UniverseFunc) def UniverseFunc(self, universe): return universe.IncludeWeeklys().Strikes(-20, 20).Expiration(timedelta(0), timedelta(31)) def OnData(self, slice: Slice) -> None: if self.Portfolio.Invested: return # Get the OptionChain chain = slice.OptionChains.get(self.symbol, None) if not chain: return # Get the nearest expiration date of the contracts expiry = sorted(chain, key = lambda x: x.Expiry)[0].Expiry # Select the put Option contracts puts = [i for i in chain if i.Expiry == expiry and i.Right == OptionRight.Put] if len(puts) == 0: return # Select the ATM strike price from the remaining contracts underlying_price = chain.Underlying.Price atm_strikes = sorted([x.Strike for x in puts], key=lambda x: abs(x - underlying_price))[0] option_strategy = OptionStrategies.Straddle(self.symbol, atm_strikes, expiry) # Select 15% OTM put otm_put = sorted(puts, key=lambda x: abs(x.Strike - 0.85*underlying_price))[0] self.Buy(option_strategy, 1) self.Sell(otm_put.Symbol, 1)