Overall Statistics |
Total Trades 5 Average Win 9.98% Average Loss 0% Compounding Annual Return 103.352% Drawdown 48.700% Expectancy 0 Net Profit 26.682% Sharpe Ratio 1.562 Probabilistic Sharpe Ratio 48.246% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 1.285 Beta -1.852 Annual Standard Deviation 1.003 Annual Variance 1.006 Information Ratio 1.256 Tracking Error 1.368 Treynor Ratio -0.846 Total Fees $5.50 Estimated Strategy Capacity $38000.00 Lowest Capacity Asset SPY 31KBXAXFTE8SM|SPY R735QTJ8XC9X |
class TransdimensionalPrism(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetEndDate(2020, 5, 1) self.SetCash(10000) # Set Strategy Cash self.SetWarmUp(15) #SPY DATA spy = self.AddEquity("SPY", Resolution.Minute) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) self.spy = spy.Symbol self.spycontract = None #TQQQ DATA tqqq = self.AddEquity("TQQQ", Resolution.Minute) tqqq.SetDataNormalizationMode(DataNormalizationMode.Raw) self.tqqq = tqqq.Symbol self.tqqqcontract = None self.uNos = { self.spy : self.spycontract, self.tqqq : self.tqqqcontract } def OnData(self, data): if not self.Portfolio[self.spy].Invested: self.SetHoldings(self.spy, 0.9) # DO HEDGE ''' for contract in self.uNos.values(): if contract is None: contract = self.GetContract() return ''' self.getContract() self.timeDC() self.setContracts() self.exerciseContracts() self.trial() def getContract(self): for underlying,contract in self.uNos.items(): if contract is None: targetStrike = (self.Securities[underlying].Price * 0.6) - (self.Securities[underlying].Price * 0.6)%5 xcontracts = self.OptionChainProvider.GetOptionContractList(underlying, self.Time) puts = [x for x in xcontracts 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) self.uNos[underlying] = puts[0] def timeDC(self): if self.spycontract is None: return if (self.spycontract.ID.Date - self.Time).days < 180: self.Liquidate(self.spycontract) self.RemoveSecurity(self.spycontract) self.spycontract = None return def setContracts(self): for underlying, contract in self.uNos.items(): if contract is None: continue if not self.Portfolio[contract].Invested: self.SetHoldings(contract, 0.05) def exerciseContracts(self): for underlying, contract in self.uNos.items(): if contract is None: continue #Exercise When reach strike price if self.Securities[underlying].Price < contract.ID.StrikePrice: self.Liquidate(contract) #self.RemoveSecurity(contract) self.RemoveOptionContract(contract) self.uNos[underlying] = None def trial(self): pass