Overall Statistics |
Total Trades 554 Average Win 3.13% Average Loss -0.51% Compounding Annual Return 58.563% Drawdown 30.500% Expectancy 0.722 Net Profit 154.941% Sharpe Ratio 1.19 Probabilistic Sharpe Ratio 47.542% Loss Rate 76% Win Rate 24% Profit-Loss Ratio 6.12 Alpha 0.416 Beta 0.369 Annual Standard Deviation 0.426 Annual Variance 0.181 Information Ratio 0.606 Tracking Error 0.432 Treynor Ratio 1.374 Total Fees $0.00 Estimated Strategy Capacity $500000.00 Lowest Capacity Asset EOSUSD XJ |
# Cryptos RSI and SMA with Stop Loss # ------------------------------------------------------------------------------------------ CRYPTOS = ['BTCUSD', 'ETHUSD', 'EOSUSD', 'LTCUSD']; MA = 50; RSI = 14; SL = 0.10; # ------------------------------------------------------------------------------------------ class CryptosRSIandSMA(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 4, 1) self.SetEndDate(2022, 4, 11) self.SetCash(100000) self.cryptos = [self.AddCrypto(ticker, Resolution.Minute).Symbol for ticker in CRYPTOS] self.sma = {}; self.rsi = {}; self.enter_price={} for sec in self.cryptos: self.sma[sec] = self.SMA(sec, MA, Resolution.Daily) self.rsi[sec] = self.RSI(sec, RSI, MovingAverageType.Simple, Resolution.Daily) self.enter_price[sec] = 0 self.SetWarmUp(max(MA, RSI), Resolution.Daily) def OnData(self, data): if self.IsWarmingUp: return for sec in self.cryptos: if not self.sma[sec].IsReady or not self.rsi[sec].IsReady: continue rsi = self.rsi[sec].Current.Value price = self.Securities[sec].Price sma = self.sma[sec].Current.Value quantity = self.CalculateOrderQuantity(sec, 0.19) pnl = self.Securities[sec].Holdings.UnrealizedProfitPercent if not self.Portfolio[sec].Invested: if rsi > 50 and price >= sma*1.005: self.MarketOrder(sec, quantity) self.enter_price[sec] = price elif self.Portfolio[sec].Invested: if self.enter_price[sec] > 0: if price < sma*0.995: self.Liquidate(sec, "price below sma") self.enter_price[sec] = 0 elif rsi < 50: self.Liquidate(sec, "rsi below 50") self.enter_price[sec] = 0 elif pnl < - SL: self.Liquidate(sec, "Stop Loss") self.enter_price[sec] = 0 def OnEndOfDay(self, symbol): if self.IsWarmingUp: return for sec in self.cryptos: if not self.sma[sec].IsReady or not self.rsi[sec].IsReady: continue self.Plot("RSI", sec, self.rsi[sec].Current.Value) self.Plot("RSI", 'threshold', 50)