Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 51.821% Drawdown 7.500% Expectancy 0 Net Profit 5.157% Sharpe Ratio 1.916 Probabilistic Sharpe Ratio 58.691% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.441 Beta 0.009 Annual Standard Deviation 0.233 Annual Variance 0.054 Information Ratio -0.317 Tracking Error 0.262 Treynor Ratio 48.653 Total Fees $1.54 Estimated Strategy Capacity $770000000.00 |
# MOMP test. # --------------------------------- STOCK = 'QQQ'; RETURN_PERIOD = 126; # --------------------------------- class EnergeticOrangeBat(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 3, 1) self.SetEndDate(2021, 6, 1) self.SetCash(100000) self.stock = self.AddEquity(STOCK, Resolution.Daily).Symbol # Warm up with history, not automatic self.mom0 = self.MOMP(self.stock, RETURN_PERIOD, Resolution.Daily) history = self.History(self.stock, RETURN_PERIOD, Resolution.Daily) for time, row in history.loc[self.stock].iterrows(): self.mom0.Update(time, row.close) # Automatic Wwarm up with history self.EnableAutomaticIndicatorWarmUp = True self.mom = self.MOMP(self.stock, RETURN_PERIOD, Resolution.Daily) self.Log(f"Starting values ref: {self.mom0.Current.Value} {self.mom0.Samples}") self.Log(f"Starting values : {self.mom.Current.Value} {self.mom.Samples}") self.mom_2, df = self.returns(self.stock, RETURN_PERIOD) self.mom_3, df2 = self.returns(self.stock, RETURN_PERIOD+1) def returns(self, symbol, period): history = self.History(symbol, period, Resolution.Daily) volume = history.volume if len(volume) != period: self.Log(f'Len = {len(volume)}') prices = history.close return float(100*(prices.iloc[-1]/prices.iloc[0] - 1)), history def OnData(self, data): if self.stock not in data.Bars: return if not self.Portfolio.Invested: self.SetHoldings(self.stock, 1) self.mom_2, df = self.returns(self.stock, RETURN_PERIOD) self.mom_3, df2 = self.returns(self.stock, RETURN_PERIOD+1) self.Plot("Momentum Percent", "RET", self.mom_2) self.Plot("Momentum Percent", "RET+1", self.mom_3) self.Plot("Momentum Percent", "MOMP", self.mom.Current.Value) self.Plot("Momentum Percent", "MOMP Ref", self.mom0.Current.Value) self.Log(f"Ending values: {self.mom.Current.Value} {self.mom0.Current.Value} {self.mom_2} {self.mom_3}")