Overall Statistics
Total Orders
2
Average Win
0%
Average Loss
0.00%
Compounding Annual Return
22.354%
Drawdown
35.100%
Expectancy
-1
Start Equity
100000
End Equity
287982.07
Net Profit
187.982%
Sharpe Ratio
0.734
Sortino Ratio
0.793
Probabilistic Sharpe Ratio
27.416%
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.031
Beta
1.114
Annual Standard Deviation
0.206
Annual Variance
0.043
Information Ratio
0.537
Tracking Error
0.08
Treynor Ratio
0.136
Total Fees
$4.29
Estimated Strategy Capacity
$220000000.00
Lowest Capacity Asset
QQQ RIWIV7K5Z9LX
Portfolio Turnover
0.05%
# region imports
from AlgorithmImports import *
# endregion

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
        
        # Initialize a counter for days
        self.dayCounter = 0

    def OnData(self, data):
        # Increment the day counter
        self.dayCounter += 1
        
        # INVESTMENT STRATEGY
        # Rebalance every 4 days
        if self.dayCounter % 4 == 0:
            if not self.Portfolio.Invested:
                self.SetHoldings("QQQ", 1)
            else:
                # This line is added to adjust holdings every 4 days,
                # even if the portfolio is already 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)