Overall Statistics |
Total Trades 386 Average Win 13.10% Average Loss -4.64% Compounding Annual Return 168.369% Drawdown 40.600% Expectancy 1.025 Net Profit 101204.025% Sharpe Ratio 2.319 Probabilistic Sharpe Ratio 95.410% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 2.82 Alpha 1.269 Beta 0.277 Annual Standard Deviation 0.56 Annual Variance 0.313 Information Ratio 2.096 Tracking Error 0.569 Treynor Ratio 4.678 Total Fees $0.00 Estimated Strategy Capacity $4200000.00 Lowest Capacity Asset ETHUSD XJ Portfolio Turnover 11.34% |
from AlgorithmImports import * class RetrospectiveYellowGreenAlligator(QCAlgorithm): def Initialize(self): # INITIALIZE self.SetStartDate(2016, 6, 18) self.SetEndDate(2023, 6, 19) self._cash = 100000 self.SetCash(self._cash) self.ticker = "ETHUSD" self.AddCrypto(self.ticker, Resolution.Daily) # SET BENCHMARK AND PREPARE COMPARATIVE PLOT self.reference_ticker = self.History(self.Symbol(self.ticker), 10, Resolution.Daily)['close'] self._initialValue_ticker = self.reference_ticker.iloc[0] # SET TECHNICAL INDICATORS self.Bolband = self.BB(self.ticker, 20, 0.3, MovingAverageType.Simple, Resolution.Daily) self.sto = self.STO(self.ticker, 8, 5, 5, Resolution.Daily) # Risk management self.AddRiskManagement(TrailingStopRiskManagementModel(0.06)) self.Debug("Stop loss hit") self.AddRiskManagement(MaximumDrawdownPercentPerSecurity(0.05)) self.Debug("Drawdown limit hit") def OnData(self, data): price = self.Securities[self.ticker].Close sto_value = self.sto.Current.Value if price > self.Bolband.UpperBand.Current.Value and sto_value > 50: self.SetHoldings(self.ticker, 1) self.Debug("Long position triggered") elif price > self.Bolband.MiddleBand.Current.Value and price < self.Bolband.UpperBand.Current.Value: self.Liquidate(self.ticker) self.Debug("Trade closed") self.Plot("Strategy Equity", str(self.ticker), self._cash * self.Securities[self.ticker].Close / self._initialValue_ticker) self.Plot("Strategy Equity", 'Portfolio Value', self.Portfolio.TotalPortfolioValue) self.Plot("Bollinger", 'BB Lower', self.Bolband.LowerBand.Current.Value) self.Plot("Bollinger", 'BB Upper', self.Bolband.UpperBand.Current.Value) self.Plot("Bollinger", 'BB Middle', self.Bolband.MiddleBand.Current.Value) self.Plot("Bollinger", str(self.ticker), self.Securities[self.ticker].Close) self.Plot("Stochastic", "faststoch", self.sto.FastStoch.Current.Value) self.Plot("Stochastic", "stochk", self.sto.StochK.Current.Value) self.Plot("Stochastic", "stochd", self.sto.StochD.Current.Value)