Overall Statistics |
Total Trades 247893 Average Win 0.00% Average Loss 0.00% Compounding Annual Return 15.501% Drawdown 33.300% Expectancy 0.853 Net Profit 303.369% Sharpe Ratio 0.983 Probabilistic Sharpe Ratio 39.486% Loss Rate 24% Win Rate 76% Profit-Loss Ratio 1.43 Alpha -0.006 Beta 0.984 Annual Standard Deviation 0.15 Annual Variance 0.022 Information Ratio -0.557 Tracking Error 0.015 Treynor Ratio 0.15 Total Fees $420691.53 Estimated Strategy Capacity $0 Lowest Capacity Asset BBK R735QTJ8XC9X |
class IndexInvesting(QCAlgorithm): def Initialize(self): self.SetStartDate(2012, 1, 1) # Set Start Date self.SetCash(100000000) # Set Strategy Cash self.SetBenchmark("SPY") self.UniverseSettings.Resolution = Resolution.Hour self.spy = self.AddEquity("SPY", Resolution.Hour).Symbol self.AddUniverse(self.Universe.ETF(self.spy, self.UniverseSettings, self.ETFConstituentsFilter)) self.weights = {} self.Schedule.On( self.DateRules.WeekStart(self.spy), self.TimeRules.AfterMarketOpen(self.spy, 1), self.Rebalance) def ETFConstituentsFilter(self, constituents): self.weights = {c.Symbol: c.Weight for c in constituents} return list(self.weights.keys()) def Rebalance(self): for symbol, weight in self.weights.items(): if symbol in self.ActiveSecurities: self.SetHoldings(symbol, weight) # Market cap weighted # self.SetHoldings(symbol, 1 / len(self.weights)) # Equally weighted 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]