Overall Statistics |
Total Trades 17 Average Win 1.02% Average Loss -0.68% Compounding Annual Return 1.329% Drawdown 1.500% Expectancy 0.001 Net Profit 0.714% Sharpe Ratio 0.394 Probabilistic Sharpe Ratio 29.677% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 1.50 Alpha -0.033 Beta 0.193 Annual Standard Deviation 0.024 Annual Variance 0.001 Information Ratio -2.35 Tracking Error 0.089 Treynor Ratio 0.049 Total Fees $11.00 Estimated Strategy Capacity $38000000.00 Lowest Capacity Asset SPY XPFJZXMFFOME|SPY R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class HipsterYellowGreenPanda(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetEndDate(2021, 7, 17) self.SetCash(100000) self.equity_symbol = self.AddEquity("SPY", dataNormalizationMode=DataNormalizationMode.Raw).Symbol self.option_symbol = self.AddOption(self.equity_symbol).Symbol self.contract = None def OnData(self, slice: Slice) -> None: if self.Portfolio[self.equity_symbol].Invested: self.Liquidate(self.equity_symbol) if self.contract is not None and self.Portfolio[self.contract.Symbol].Invested: return if slice.OptionChains.ContainsKey(self.option_symbol): chain = slice.OptionChains[self.option_symbol] # Select call contracts calls = [contract for contract in chain if contract.Right == OptionRight.Call] if len(calls) == 0: return # Select the call contracts with the furthest expiration furthest_expiry = sorted(calls, key = lambda x: x.Expiry, reverse=True)[0].Expiry furthest_expiry_calls = [contract for contract in calls if contract.Expiry == furthest_expiry] # From the remaining contracts, select the one with its strike closest to the underlying price self.contract = sorted(furthest_expiry_calls, key = lambda x: abs(chain.Underlying.Price - x.Strike))[0] self.MarketOrder(self.contract.Symbol, 1)