Overall Statistics |
Total Trades 27 Average Win 20.88% Average Loss -4.11% Compounding Annual Return 7.933% Drawdown 36.700% Expectancy 1.105 Net Profit 145.378% Sharpe Ratio 0.478 Probabilistic Sharpe Ratio 2.991% Loss Rate 65% Win Rate 35% Profit-Loss Ratio 5.08 Alpha 0.119 Beta -0.064 Annual Standard Deviation 0.223 Annual Variance 0.05 Information Ratio -0.242 Tracking Error 0.353 Treynor Ratio -1.674 Total Fees $1378.66 Estimated Strategy Capacity $620000.00 Lowest Capacity Asset XHB TFYQNA7D69UT |
class CalculatingYellowGreenElephant(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) self.SetCash(100000) self.SetWarmup(90) self.SetBenchmark("XHB") periods = (30, 90) self.trade = SymbolData(self, self.AddEquity("XHB").Symbol, periods) self.indicator = SymbolData(self, self.AddEquity("WOOD").Symbol, periods) self.prior = 0 def OnData(self, data): if not self.indicator.is_ready(): return if self.indicator.diff() < 0 and self.prior > 0: if self.Portfolio[self.trade.symbol].IsShort or not self.Portfolio.Invested: self.SetHoldings(self.trade.symbol, 1) elif self.indicator.diff() > 0 and self.prior < 0: if self.Portfolio[self.trade.symbol].IsLong or not self.Portfolio.Invested: self.SetHoldings(self.trade.symbol, -1) self.prior = self.indicator.diff() class SymbolData: def __init__(self, algorithm, symbol, periods): self.symbol = symbol self.short_ema = algorithm.EMA(self.symbol, periods[0], Resolution.Daily) self.long_ema = algorithm.EMA(self.symbol, periods[1], Resolution.Daily) def is_ready(self): return self.short_ema.IsReady and self.long_ema.IsReady def diff(self): return self.long_ema.Current.Value - self.short_ema.Current.Value