Overall Statistics
Total Trades
67115
Average Win
0.01%
Average Loss
-0.01%
Compounding Annual Return
7.840%
Drawdown
31.200%
Expectancy
0.729
Net Profit
458.300%
Sharpe Ratio
0.488
Probabilistic Sharpe Ratio
0.139%
Loss Rate
23%
Win Rate
77%
Profit-Loss Ratio
1.23
Alpha
0.042
Beta
0.303
Annual Standard Deviation
0.127
Annual Variance
0.016
Information Ratio
-0.015
Tracking Error
0.192
Treynor Ratio
0.205
Total Fees
$70848.75
Estimated Strategy Capacity
$0
Lowest Capacity Asset
SXCI TJPMW3BHNMUD
#region imports
from AlgorithmImports import *
#endregion
# Creating our own Index Fund
# https://www.quantconnect.com/forum/discussion/12347/creating-our-own-index-fund

# ----------------------
ETF = "QQQ"; LEV = 1.00;
# ----------------------

class IndexInvesting(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2000, 1, 1)  
        self.SetCash(1000000)

        self.SetBenchmark(ETF)
        self.UniverseSettings.Resolution = Resolution.Daily
        self.etf = self.AddEquity(ETF, Resolution.Hour).Symbol
        self.AddUniverse(self.Universe.ETF(self.etf, self.UniverseSettings, self.ETFConstituentsFilter))
        self.weights = {}
        self.Schedule.On(self.DateRules.WeekStart(self.etf), self.TimeRules.AfterMarketOpen(self.etf, 31),
            self.Rebalance)
    
    def ETFConstituentsFilter(self, constituents):
        self.weights = {c.Symbol: c.Weight for c in constituents}
        return list(self.weights.keys())
    
    def OnSecuritiesChanged(self, changes):
        for security in changes.AddedSecurities:
            security.SetLeverage(10)

        for security in changes.RemovedSecurities:
            if security.Invested:
                self.Liquidate(security.Symbol, 'No longer in universe')
                if security.Symbol in self.weights.keys(): del self.weights[security.Symbol]
    
    def Rebalance(self):
        for symbol, weight in self.weights.items():
            if symbol in self.ActiveSecurities:
                if weight is not None:
                    # self.SetHoldings(symbol, weight)  # Market cap weighted
                    self.SetHoldings(symbol, LEV / len(self.weights))  # Equally weighted