Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -3.313 Tracking Error 0.163 Treynor Ratio 0 Total Fees $0.00 |
class MeanReversionResearch(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 10, 1) self.SetEndDate(2020, 12, 5) self.SetCash(100_000) self.symbol1 = self.AddEquity('CVX', Resolution.Daily).Symbol self.symbol2 = self.AddEquity('XOM', Resolution.Daily).Symbol lookback = 20 self.sma = SimpleMovingAverage(lookback) self.std = StandardDeviation(lookback) def OnData(self, data): if data.ContainsKey(self.symbol1) and data.ContainsKey(self.symbol2): ratio = data[self.symbol1].Close / data[self.symbol2].Close self.sma.Update(self.Time, ratio) self.std.Update(self.Time, ratio) if self.sma.IsReady and self.std.IsReady: self.Plot("SMA", "Value", self.sma.Current.Value) self.Plot("STD", "Value", self.std.Current.Value) z_score = (ratio - self.sma.Current.Value) / self.std.Current.Value self.Plot("Z Score", "Value", z_score)