Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 10.884% Drawdown 38.500% Expectancy 0 Net Profit 14.552% Sharpe Ratio 0.46 Probabilistic Sharpe Ratio 23.631% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.174 Beta -0.275 Annual Standard Deviation 0.304 Annual Variance 0.093 Information Ratio 0.035 Tracking Error 0.443 Treynor Ratio -0.51 Total Fees $46.48 |
class BenchmarkPlotTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 1) self.SetCash(1000000) # select a ticker as benchmark (will plot Buy&Hold of this benchmark) ticker = 'IBM' self.benchmarkTicker = 'SPY' self.symbol = self.AddEquity(ticker, Resolution.Daily).Symbol self.SetBenchmark(self.benchmarkTicker) self.initBenchmarkPrice = None def OnData(self, slice): # simulate buy and hold the benchmark and plot its daily value self.UpdateBenchmarkValue() self.Plot('Strategy Equity', self.benchmarkTicker, self.benchmarkValue) if not self.Portfolio.Invested: self.SetHoldings(self.symbol, 1) def UpdateBenchmarkValue(self): ''' Simulate buy and hold the Benchmark ''' if self.initBenchmarkPrice is None: self.initBenchmarkCash = self.Portfolio.Cash self.initBenchmarkPrice = self.Benchmark.Evaluate(self.Time) self.benchmarkValue = self.initBenchmarkCash else: currentBenchmarkPrice = self.Benchmark.Evaluate(self.Time) self.benchmarkValue = (currentBenchmarkPrice / self.initBenchmarkPrice) * self.initBenchmarkCash