Overall Statistics |
Total Trades 261 Average Win 0.81% Average Loss -0.02% Compounding Annual Return -0.073% Drawdown 2.700% Expectancy -0.218 Net Profit -0.792% Sharpe Ratio -2.638 Sortino Ratio -2.616 Probabilistic Sharpe Ratio 0.002% Loss Rate 98% Win Rate 2% Profit-Loss Ratio 32.87 Alpha -0.015 Beta -0.022 Annual Standard Deviation 0.006 Annual Variance 0 Information Ratio -0.7 Tracking Error 0.145 Treynor Ratio 0.763 Total Fees $231.00 Estimated Strategy Capacity $0 Lowest Capacity Asset SPY 32EE1LPPYNMNA|SPY R735QTJ8XC9X Portfolio Turnover 0.00% |
# region imports from AlgorithmImports import * # endregion class SquareMagentaViper(QCAlgorithm): def Initialize(self): self.SetStartDate(2013, 1, 14) self.SetCash(100000) # Portfolio setup self.Portfolio.MarginCallModel = MarginCallModel.Null # Create Equity Option Universe option = self.AddOption("SPY") self.symbol = option.Symbol # Select put contracts with exiracy between 80 and 90 days option.SetFilter(lambda option_filter_universe: option_filter_universe.PutsOnly().Expiration(85, 90)) # Variables self.last_month = None self.ticket = None def OnData(self, slice: Slice): current_month = self.Time.month if current_month != self.last_month: chain = slice.OptionChains.get(self.symbol) if chain: # we sort the contracts to find OTM contract with farthest expiration expiry = max([x.Expiry for x in chain]) filtered_symbols = [x for x in chain if x.Right == OptionRight.Put and x.Expiry == expiry and x.Strike <= (x.UnderlyingLastPrice * 0.72) and x.Strike >= (x.UnderlyingLastPrice * 0.68)] contracts = sorted(filtered_symbols, key=lambda symbol: symbol.Strike) if len(contracts) == 0: self.Debug('No contracts found..') return elif len(contracts)> 1: contract = contracts[int(len(contracts)/2)] else: contract = contracts[-1] if not self.ticket is None: self.MarketOrder(self.ticket.Symbol, -1) self.ticket = self.MarketOrder(contract.Symbol, 1) self.last_month = current_month