Overall Statistics |
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 218.748% Drawdown 61.700% Expectancy 0 Net Profit 47.149% Sharpe Ratio 3.272 Probabilistic Sharpe Ratio 55.678% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 4.513 Beta -2.792 Annual Standard Deviation 1.509 Annual Variance 2.278 Information Ratio 2.724 Tracking Error 1.869 Treynor Ratio -1.769 Total Fees $3.75 Estimated Strategy Capacity $31000000.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 #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.1) 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