Overall Statistics |
Total Trades 126 Average Win 0.39% Average Loss -0.63% Compounding Annual Return 0.529% Drawdown 4.000% Expectancy 0.057 Net Profit 2.135% Sharpe Ratio 0.166 Probabilistic Sharpe Ratio 2.733% Loss Rate 35% Win Rate 65% Profit-Loss Ratio 0.62 Alpha -0.003 Beta 0.061 Annual Standard Deviation 0.024 Annual Variance 0.001 Information Ratio -1.112 Tracking Error 0.1 Treynor Ratio 0.064 Total Fees $126.00 Estimated Strategy Capacity $480000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
class CalibratedDynamicComputer(QCAlgorithm): def Initialize(self): self.SetStartDate(2016, 1, 30) self.SetEndDate(2020, 1, 30) self.SetCash(10000) #self.SetBrokerageModel(BrokerageName.OandaBrokerage) symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.engulfing = self.CandlestickPatterns.Engulfing(symbol, Resolution.Daily) self.engulfing_window = RollingWindow[float](10) self.SetBenchmark("SPY") def OnData(self, data): if not self.engulfing.IsReady: return engulfing = self.engulfing.Current.Value # 0 if not ready or not engulfing, 1 if bullish engulf, -1 if bearish engulf #self.Plot("IndicatorValue", "Engulfing", engulfing) self.engulfing_window.Add(engulfing) if self.engulfing_window.IsReady: # changed your code for ready instead of not ready #self.Plot("TrailingIndicatorValue", "TrailingHammer", self.engulfing_window[self.engulfing_window.Count-1]) # I did not know what you wanted to do with your window... self.Log(f"self.engulfing_window: {[x for x in self.engulfing_window]}") if engulfing: if not self.Portfolio["SPY"].Invested: self.Log("Buy") self.SetHoldings("SPY", 1) else: if self.Portfolio["SPY"].Invested: self.Log("Sell") self.Liquidate("SPY")