Overall Statistics |
Total Trades 221 Average Win 1.72% Average Loss -0.25% Compounding Annual Return 17.807% Drawdown 40.700% Expectancy 5.616 Net Profit 748.187% Sharpe Ratio 0.895 Probabilistic Sharpe Ratio 26.141% Loss Rate 16% Win Rate 84% Profit-Loss Ratio 6.85 Alpha 0.119 Beta 0.775 Annual Standard Deviation 0.238 Annual Variance 0.057 Information Ratio 0.502 Tracking Error 0.183 Treynor Ratio 0.275 Total Fees $578.37 |
# Equal-weighted portfolio of stocks with different participation dates # ----------------------------------------------- STOCKS = ['QQQ', 'XIV', 'ARKK']; TARGET_LEV = 1.0 # ----------------------------------------------- class Equal_weighted_portfolio(QCAlgorithm): def Initialize(self): self.SetStartDate(2008, 1, 1) self.SetEndDate(2021, 1, 13) self.InitCash = 100000 self.SetCash(self.InitCash) self.MKT = self.AddEquity("SPY", Resolution.Hour).Symbol self.mkt = [] self.assets = [self.AddEquity(ticker, Resolution.Minute).Symbol for ticker in STOCKS] self.wt = {} self.real_wt = {} self.Schedule.On(self.DateRules.MonthStart(), self.TimeRules.AfterMarketOpen(self.MKT, 60), self.trade) def trade(self): tradable = [] for sec in self.assets: if self.Securities[sec].IsTradable == True: tradable.append(sec) else: continue for sec in self.Portfolio.Keys: if sec not in tradable: self.wt[sec] = 0. for sec in tradable: self.wt[sec] = TARGET_LEV / len(tradable) for sec, weight in self.wt.items(): if weight == 0. and self.Portfolio[sec].IsLong: self.Liquidate(sec) for sec, weight in self.wt.items(): if weight != 0.: self.SetHoldings(sec, weight) def OnEndOfDay(self): mkt_price = self.Securities[self.MKT].Close self.mkt.append(mkt_price) mkt_perf = self.InitCash * self.mkt[-1] / self.mkt[0] self.Plot('Strategy Equity', self.MKT, mkt_perf) account_leverage = self.Portfolio.TotalHoldingsValue / self.Portfolio.TotalPortfolioValue self.Plot('Holdings', 'leverage', round(account_leverage, 2)) self.Plot('Holdings', 'Target Leverage', TARGET_LEV) for sec, weight in self.wt.items(): self.real_wt[sec] = round(self.ActiveSecurities[sec].Holdings.Quantity * self.Securities[sec].Price / self.Portfolio.TotalPortfolioValue,4) # self.Log(str(self.Time) +" "+ str(self.Securities[sec].Symbol) +" "+ str(self.real_wt[sec])) self.Plot('Holdings', self.Securities[sec].Symbol, round(self.real_wt[sec], 4))