| Overall Statistics |
|
Total Trades 28 Average Win 20.43% Average Loss -4.62% Compounding Annual Return 6.098% Drawdown 36.700% Expectancy 0.807 Net Profit 98.321% Sharpe Ratio 0.392 Probabilistic Sharpe Ratio 1.657% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 4.42 Alpha 0.101 Beta -0.067 Annual Standard Deviation 0.225 Annual Variance 0.051 Information Ratio -0.309 Tracking Error 0.356 Treynor Ratio -1.325 Total Fees $1252.51 Estimated Strategy Capacity $560000.00 Lowest Capacity Asset XHB TFYQNA7D69UT |
class JumpingBrownCat(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)
def OnData(self, data):
if not self.indicator.is_ready():
return
if self.indicator.short_ema.Current.Value > self.indicator.long_ema.Current.Value:
# long
if self.Portfolio[self.trade.symbol].IsShort or not self.Portfolio.Invested:
self.SetHoldings(self.trade.symbol, 1)
elif self.indicator.short_ema.Current.Value < self.indicator.long_ema.Current.Value:
# short
if self.Portfolio[self.trade.symbol].IsLong or not self.Portfolio.Invested:
self.SetHoldings(self.trade.symbol, -1)
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