Overall Statistics |
Total Trades 5408 Average Win 0.09% Average Loss -0.09% Compounding Annual Return -57.222% Drawdown 50.800% Expectancy -0.298 Net Profit -50.771% Sharpe Ratio -5.483 Probabilistic Sharpe Ratio 0% Loss Rate 65% Win Rate 35% Profit-Loss Ratio 1.00 Alpha -0.453 Beta 0.052 Annual Standard Deviation 0.081 Annual Variance 0.007 Information Ratio -5.063 Tracking Error 0.128 Treynor Ratio -8.509 Total Fees $5408.00 Estimated Strategy Capacity $4800000.00 Lowest Capacity Asset TSLA UNU3P8Y3WFAD |
# EMAC, Take Profit and Stop Loss based on UnrealizedProfit class FatBrownBison(QCAlgorithm): def Initialize(self): self.cash = 100000 self.ticker = "TSLA" self.tp = 0.02 self.sl = -0.01 self.SetStartDate(2021, 1, 1) self.SetEndDate(2021, 11, 1) self.SetCash(self.cash) self.stock = self.AddEquity(self.ticker, Resolution.Minute).Symbol self.emaFast = self.EMA(self.stock, 12) self.emaFastPrev = IndicatorExtensions.Of(Delay(1), self.emaFast) self.emaSlow = self.EMA(self.stock, 26) self.emaSlowPrev = IndicatorExtensions.Of(Delay(1), self.emaSlow) self.SetWarmUp(150, Resolution.Minute) def OnData(self, data): if self.IsWarmingUp : return if not self.emaFastPrev.IsReady: return if not self.emaSlowPrev.IsReady: return currSlowEMA = self.emaSlow.Current.Value prevSlowEMA = self.emaSlowPrev.Current.Value currFastEMA = self.emaFast.Current.Value prevFastEMA = self.emaFastPrev.Current.Value pnl = self.Portfolio[self.stock].UnrealizedProfit if not self.Portfolio.Invested: if prevFastEMA < prevSlowEMA and currFastEMA > currSlowEMA: self.SetHoldings(self.stock, 1) elif prevFastEMA > prevSlowEMA and currFastEMA < currSlowEMA: self.SetHoldings(self.stock, -1) elif self.Securities[self.stock].Invested: if pnl >= self.tp: self.Liquidate(self.stock, "Took profit") elif pnl < self.sl: self.Liquidate(self.stock, "Stop Loss")