Overall Statistics
Total Orders
2
Average Win
201.32%
Average Loss
0%
Compounding Annual Return
23.411%
Drawdown
34.800%
Expectancy
0
Start Equity
100000
End Equity
301318.13
Net Profit
201.318%
Sharpe Ratio
0.772
Sortino Ratio
0.837
Probabilistic Sharpe Ratio
30.515%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.038
Beta
1.11
Annual Standard Deviation
0.205
Annual Variance
0.042
Information Ratio
0.638
Tracking Error
0.078
Treynor Ratio
0.142
Total Fees
$6.70
Estimated Strategy Capacity
$430000000.00
Lowest Capacity Asset
QQQ RIWIV7K5Z9LX
Portfolio Turnover
0.10%
#region imports
from AlgorithmImports import *
#endregion
# For a better understanding of the results : https://www.quantconnect.com/docs/v2/our-platform/backtesting/results

class RetrospectiveYellowGreenAlligator(QCAlgorithm):

    def Initialize(self):
        # INITIALIZE
        self.SetStartDate(2019, 1, 1) 
        self.SetEndDate(2024, 3, 31)
        self.SetCash(100000) 
        self.spy = self.AddEquity("SPY", Resolution.Daily).Symbol
        self.qqq = self.AddEquity("QQQ", Resolution.Daily).Symbol
        
        # SET BENCHMARK AND PREPARE COMPARATIVE PLOT
        self.SetBenchmark("SPY")
        self.lastBenchmarkValue = None
        self.BenchmarkPerformance = self.Portfolio.TotalPortfolioValue
        
        # Set the date to sell all holdings (2 days before the end date)
        self.sell_date = self.EndDate - timedelta(days=5)
        
    def OnData(self, data):
        # Check if it's time to sell everything
        if self.Time.date() >= self.sell_date.date():
            self.Liquidate()
            return
        
        # INVESTMENT STRATEGY
        if not self.Portfolio.Invested:
            self.SetHoldings("QQQ", 1)
            
        # CREATE A COMPARATIVE PLOT OF STRATEGY VS. BENCHMARK
        benchmark = self.Securities["SPY"].Close    
        if self.lastBenchmarkValue is not None:
           self.BenchmarkPerformance = self.BenchmarkPerformance * (benchmark / self.lastBenchmarkValue)
        self.lastBenchmarkValue = benchmark
        
        self.Plot("Strategy vs Benchmark", "Portfolio Value", self.Portfolio.TotalPortfolioValue)
        self.Plot("Strategy vs Benchmark", "Benchmark", self.BenchmarkPerformance)