Overall Statistics
Total Trades
19502
Average Win
0.02%
Average Loss
0.00%
Compounding Annual Return
27.022%
Drawdown
27.900%
Expectancy
2.970
Net Profit
250.761%
Sharpe Ratio
1.221
Probabilistic Sharpe Ratio
59.099%
Loss Rate
35%
Win Rate
65%
Profit-Loss Ratio
5.08
Alpha
0.286
Beta
-0.179
Annual Standard Deviation
0.198
Annual Variance
0.039
Information Ratio
-0.022
Tracking Error
0.304
Treynor Ratio
-1.35
Total Fees
$19755.05
Estimated Strategy Capacity
$0
Lowest Capacity Asset
LVNTA V8Z89IPL1MCL
# 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(2016, 6, 24)  
        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.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