Overall Statistics |
Total Trades 91 Average Win 1.99% Average Loss -1.47% Compounding Annual Return -1.024% Drawdown 16.100% Expectancy -0.011 Net Profit -2.458% Sharpe Ratio 0.017 Probabilistic Sharpe Ratio 3.293% Loss Rate 58% Win Rate 42% Profit-Loss Ratio 1.35 Alpha 0.021 Beta -0.179 Annual Standard Deviation 0.137 Annual Variance 0.019 Information Ratio -0.371 Tracking Error 0.28 Treynor Ratio -0.013 Total Fees $123.88 Estimated Strategy Capacity $1000000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class JumpingBlueGuanaco(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetEndDate(2022,6,1) self.SetCash(100000) # Set Strategy Cash self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol self.sma = self.SMA (self.spy,30,Resolution.Daily) self.SetWarmUp(timedelta(30)) def OnData(self, data): if not self.sma.IsReady: # check difference, warup or isready return hist = self.History(self.spy,timedelta(260),Resolution.Daily) high = max(hist["high"]) low = min(hist["low"]) price = self.Securities["SPY"].Price if price * 1.05 >= high and self.sma.Current.Value < price: #if not self.Portfolio[self.spy].IsLong: self.SetHoldings(self.spy,1) elif price * 0.95 <= low and self.sma.Current.Value > price: if not self.Portfolio[self.spy].IsShort: self.SetHoldings(self.spy,-1) else: self.Liquidate(self.spy) self.Plot("Benchmark","52w-high",high) self.Plot("Benchmark","high area",high*0.95) self.Plot("Benchmark","52w-low",low) self.Plot("Benchmark","low area",low*1.05) self.Plot("Benchmark","sma",self.sma.Current.Value)