Overall Statistics |
Total Trades 249413 Average Win 0.00% Average Loss 0.00% Compounding Annual Return 14.932% Drawdown 33.300% Expectancy 0.855 Net Profit 287.414% Sharpe Ratio 0.951 Probabilistic Sharpe Ratio 36.017% 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.545 Tracking Error 0.015 Treynor Ratio 0.145 Total Fees $422694.79 Estimated Strategy Capacity $0 Lowest Capacity Asset BBK R735QTJ8XC9X |
# Creating our own Index Fund original class IndexInvesting(QCAlgorithm): def Initialize(self): self.SetStartDate(2012, 1, 1) # Set Start Date self.InitCash = 100000000 self.SetCash(self.InitCash) self.SetBenchmark("SPY") self.initBenchmarkPrice = None 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] def UpdateBenchmarkValue(self): if self.initBenchmarkPrice is None: self.initBenchmarkCash = self.InitCash self.initBenchmarkPrice = self.Benchmark.Evaluate(self.Time) self.benchmarkValue = self.initBenchmarkCash else: currentBenchmarkPrice = self.Benchmark.Evaluate(self.Time) self.benchmarkValue = (currentBenchmarkPrice / self.initBenchmarkPrice) * self.initBenchmarkCash def OnEndOfDay(self, symbol): self.UpdateBenchmarkValue() self.Plot('Strategy Equity', "SPY", self.benchmarkValue)