Overall Statistics |
Total Trades 2150 Average Win 0.35% Average Loss -0.43% Compounding Annual Return -59.381% Drawdown 40.700% Expectancy -0.076 Net Profit -36.443% Sharpe Ratio -1.324 Probabilistic Sharpe Ratio 1.975% Loss Rate 49% Win Rate 51% Profit-Loss Ratio 0.81 Alpha -0.482 Beta -0.892 Annual Standard Deviation 0.422 Annual Variance 0.178 Information Ratio -0.744 Tracking Error 0.866 Treynor Ratio 0.626 Total Fees $4097.89 |
class ModulatedOptimizedProcessor(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 12, 16) # Set Start Date self.SetCash(60000) # Set Strategy Cash self.qqq = self.AddEquity('QQQ').Symbol # self.AddEquity() allows the user to subscribe to the data of a ticker # a Symbol is like a ticker, but has more information self.tqqq = self.AddEquity('TQQQ').Symbol self.sqqq = self.AddEquity('SQQQ').Symbol self.AddEquity("SPY") self.tqqq_init_price = -1 # an event scheduler executes the given function on a certain date and/or at a certain time # 'QQQ', self.tqqq, 'TQQQ', etc. are all valid argument parameters self.Schedule.On(self.DateRules.EveryDay(self.qqq), self.TimeRules.BeforeMarketClose(self.qqq, 5), self.ClosePositionsEndOfDay) # 5 indicates execute function 5 minutes before the markets close def OnData(self, data): # make sure we have data for all symbols, if not, return if self.qqq not in data or self.tqqq not in data or self.sqqq not in data: return if not self.Portfolio.Invested: # set holdings of half of total portfolio (cash amount set with self.SetCash()) to TQQQ shares self.SetHoldings(self.tqqq, .5) # get initial price of tqq self.tqqq_init_price = data[self.tqqq].Close self.SetHoldings(self.sqqq, .5) if data[self.tqqq].Close * 1.05 > self.tqqq_init_price: # setting 0% of portfolio's investment in TQQQ # essentially sells all shares of TQQQ self.SetHoldings(self.tqqq, 0) self.SetHoldings(self.qqq, .5) def ClosePositionsEndOfDay(self): # self.Liquidate() with no specific Symbol will Liquidate all holdings self.Liquidate()