Overall Statistics |
Total Trades 13 Average Win 0.02% Average Loss 0% Compounding Annual Return -0.403% Drawdown 0.100% Expectancy 0 Net Profit -0.023% Sharpe Ratio -0.836 Probabilistic Sharpe Ratio 30.939% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.002 Beta -0.026 Annual Standard Deviation 0.003 Annual Variance 0 Information Ratio -2.202 Tracking Error 0.091 Treynor Ratio 0.11 Total Fees $13.00 Estimated Strategy Capacity $3200000.00 Lowest Capacity Asset SPY 31OJK5DKMZHPI|SPY R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class DeterminedRedOrangeChimpanzee(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 4, 10) # Set Start Date self.SetEndDate(2021, 5, 1) self.SetCash(100000) # Set Strategy Cash self.option = self.AddOption("SPY") self.option.PriceModel = OptionPriceModels.CrankNicolsonFD() self.option.SetFilter(minStrike=-10, maxStrike=10, minExpiry=timedelta(days=0), maxExpiry=timedelta(days=90)) self.SetWarmUp(30, Resolution.Daily) self.delta_threshold = 5 self.contract = None def OnData(self, data: Slice): if self.IsWarmingUp: return for canonical_symbol, chain in data.OptionChains.items(): if self.contract is None: # Buy contract(s) puts = [contract for contract in chain if contract.Right == OptionRight.Put] expiry = sorted(puts, key=lambda contract: contract.Expiry)[-1].Expiry puts = [contract for contract in puts if contract.Expiry == expiry] self.contract = sorted(puts, key=lambda contract: abs(contract.Strike - contract.UnderlyingLastPrice))[0] self.MarketOrder(self.contract.Symbol, 1) # Manage delta exposure if not self.Portfolio.Invested: return contracts = [kvp.Value for kvp in chain.Contracts if self.Portfolio[kvp.Key].Invested] contract_deltas = [chain.Contracts.get(contract.Symbol).Greeks.Delta * self.Portfolio[contract.Symbol].Quantity for contract in contracts] contract_delta = sum(contract_deltas) * self.option.ContractMultiplier underlying_delta = self.Portfolio["SPY"].Quantity net_delta = contract_delta + underlying_delta quantity = -int(net_delta) if abs(quantity) >= self.delta_threshold: self.MarketOrder("SPY", quantity)