Overall Statistics |
Total Trades 97 Average Win 3.19% Average Loss -1.47% Compounding Annual Return 1067.852% Drawdown 10.600% Expectancy 1.026 Net Profit 181.670% Sharpe Ratio 12.667 Probabilistic Sharpe Ratio 99.796% Loss Rate 36% Win Rate 64% Profit-Loss Ratio 2.17 Alpha 4.906 Beta 0.098 Annual Standard Deviation 0.389 Annual Variance 0.151 Information Ratio 11.629 Tracking Error 0.404 Treynor Ratio 50.37 Total Fees $0.00 Estimated Strategy Capacity $5400000.00 Lowest Capacity Asset ETHUSD XJ Portfolio Turnover 68.96% |
from AlgorithmImports import * class RetrospectiveYellowGreenAlligator(QCAlgorithm): def Initialize(self): # INITIALIZE self.SetStartDate(2023, 1, 18) self.SetEndDate(2023, 6, 19) self._cash = 100000 self.SetCash(self._cash) self.ticker = "ETHUSD" self.AddCrypto(self.ticker, Resolution.Daily, Market.GDAX).Symbol # 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, 10, 0.45, 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") 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 > 80: self.SetHoldings(self.ticker, -1) self.Debug("Short position triggered") elif price > self.Bolband.MiddleBand.Current.Value and price < self.Bolband.UpperBand.Current.Value: self.SetHoldings(self.ticker, 0.5) self.Debug("Mid long triggered") elif price < self.Bolband.MiddleBand.Current.Value and price > self.Bolband.LowerBand.Current.Value and sto_value < 20: self.SetHoldings(self.ticker, 1) self.Debug("Long position triggered") elif self.Portfolio[self.ticker].UnrealizedProfitPercent > 0.07: self.Liquidate(self.ticker) self.Debug("Take profit triggered") else: self.SetHoldings(self.ticker, 1) 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)