Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 11.485% Drawdown 25.800% Expectancy 0 Net Profit 4.630% Sharpe Ratio 0.542 Probabilistic Sharpe Ratio 37.415% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.021 Beta 0.882 Annual Standard Deviation 0.323 Annual Variance 0.104 Information Ratio -1.002 Tracking Error 0.047 Treynor Ratio 0.198 Total Fees $49.52 |
class ResistanceTransdimensionalSplitter(QCAlgorithm): def Initialize(self): self.SetStartDate(2009, 1, 1) self.SetEndDate(2009, 6, 1) self.SetCash(1000000) spy = self.AddEquity("SPY", Resolution.Minute) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) self.spy = spy.Symbol self.contract = None self.SetWarmUp(200) def OnData(self, data): if self.IsWarmingUp: return if not self.Portfolio[self.spy].Invested: self.SetHoldings(self.spy, 0.9) self.Debug(str(self.Portfolio[self.spy].HoldingsValue)) if self.contract is None: self.contract = self.GetContract() self.SetHoldings(self.contract, 0.1) return def GetContract(self): targetStrike = (self.Securities[self.spy].Price * 0.6) - (self.Securities[self.spy].Price * 0.6)%5 contracts = self.OptionChainProvider.GetOptionContractList(self.spy, self.Time) puts = [x for x in contracts if x.ID.OptionRight == OptionRight.Put] puts = sorted( sorted(puts, key = lambda x: x.ID.Date, reverse = True), key = lambda x: x.ID.StrikePrice) puts = [x for x in puts if x.ID.StrikePrice == targetStrike] puts = [x for x in puts if 270 < (x.ID.Date - self.Time).days <= 420] if len(puts) == 0: return None self.AddOptionContract(puts[0], Resolution.Minute) return puts[0]