Overall Statistics |
Total Trades 4 Average Win 1.38% Average Loss -0.08% Compounding Annual Return 11.892% Drawdown 22.700% Expectancy 8.529 Net Profit 87.023% Sharpe Ratio 0.739 Probabilistic Sharpe Ratio 20.463% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 18.06 Alpha 0.034 Beta 0.557 Annual Standard Deviation 0.12 Annual Variance 0.014 Information Ratio -0.085 Tracking Error 0.104 Treynor Ratio 0.159 Total Fees $2.00 Estimated Strategy Capacity $0 Lowest Capacity Asset MSFT R735QTJ8XC9X Portfolio Turnover 0.02% |
#region imports from AlgorithmImports import * #endregion class TransdimensionalCalibratedRadiator(QCAlgorithm): def Initialize(self): self.SetStartDate(2018, 1, 1) # Set Start Date self.SetCash(30000) # Set Strategy Cash option = self.AddOption("MSFT") self.symbol = option.Symbol option.SetFilter(-29, 29, timedelta(11), timedelta(11)) def OnData(self, slice: Slice) -> None: if self.Portfolio.Invested: return # Get the OptionChain chain = slice.OptionChains.GetValue(self.symbol) if chain is None: return lowerBound = chain.Underlying.Price * 0.972 upperBound = chain.Underlying.Price * 1.05 if not chain: return # Get the furthest expiration date of the contracts expiry = sorted(chain, key = lambda x: x.Expiry, reverse=True)[0].Expiry # Select the put Option contracts with the furthest expiry puts = [i for i in chain if i.Expiry == expiry and i.Right == OptionRight.Put] if len(puts) == 0: return # Select the ITM and OTM contract strikes from the remaining contracts put_strikes = sorted([x.Strike for x in puts]) #filtered_strikes = put_strikes[put_strikes.Values[0]> lowerBound and put_strikes.Values[0] < upperBound] filtered_strikes = [x for x in put_strikes if x> lowerBound and x < upperBound] otm_strike = filtered_strikes[0] itm_strike = filtered_strikes[-1] option_strategy = OptionStrategies.BullPutSpread(self.symbol, itm_strike, otm_strike, expiry) self.Buy(option_strategy, 1) # for chain in data.OptionChains.Values: # lowerBound = chain.Underlying.Price * 0.9 # upperBound = chain.Underlying.Price * 1.0 # # Option contracts sorted by their strikes # contracts = sorted(chain, key=lambda x: x.Strike) # # The contracts from -5% to 5% # selectedContracts = [x for x in contracts if x.Strike > lowerBound and x.Strike < upperBound and x.Symbol.ID.OptionRight == OptionRight.Put ] # # For validation we get the strikes of the selected contracts # strikes = [x.Strike for x in contracts if x.Strike > lowerBound and x.Strike < upperBound] # self.Log(f"Lower Bound: {lowerBound} \n Upper Bound: {upperBound} \n Strikes: {strikes}") # self.longOption = selectedContracts[0] # self.shortOption = selectedContracts[0] # self.Buy(self.longOption.Symbol, 1) # self.Sell(self.shortOption.Symbol, 1)