| Overall Statistics |
|
Total Orders 1 Average Win 0% Average Loss 0% Compounding Annual Return 6.719% Drawdown 80.900% Expectancy 0 Start Equity 100000 End Equity 401029.56 Net Profit 301.030% Sharpe Ratio 0.233 Sortino Ratio 0.254 Probabilistic Sharpe Ratio 0.007% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.004 Beta 1.133 Annual Standard Deviation 0.216 Annual Variance 0.047 Information Ratio 0.079 Tracking Error 0.116 Treynor Ratio 0.044 Total Fees $6.23 Estimated Strategy Capacity $140000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX Portfolio Turnover 0.01% Drawdown Recovery 5443 |
#region imports
from AlgorithmImports import *
#endregion
# For a better understanding of the results : https://www.quantconnect.com/docs/v2/our-platform/backtesting/results
"""
TRADE LOGIC DESCRIPTION
This strategy trades QQQ using a simple buy-and-hold allocation rule. The model
enters a long QQQ position when the portfolio is not already invested and then
continues holding that position indefinitely. The purpose is to test whether full
exposure to QQQ can create value compared with a passive SPY benchmark. The
strategy does not use technical indicators, price momentum, volatility filters,
calendar timing rules, macro signals, or regime logic. It is purely exposure-based.
The strategy invests 100% of the portfolio in QQQ when active and does not keep
a planned cash reserve. SPY is not traded by the strategy; it is used only as the
benchmark for comparison. The benchmark is constructed by compounding the
starting portfolio value using SPY daily close-to-close returns. The model plots
the strategy equity curve and the benchmark equity curve on the same chart.
"""
class RetrospectiveYellowGreenAlligator(QCAlgorithm):
def Initialize(self):
# INITIALIZE
self.SetStartDate(2000, 1, 1)
self.SetEndDate(2021, 5, 5)
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
def OnData(self, data):
#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)