Overall Statistics |
Total Trades 99 Average Win 1.69% Average Loss -0.66% Compounding Annual Return 11.048% Drawdown 15.300% Expectancy 1.819 Net Profit 69.549% Sharpe Ratio 0.869 Probabilistic Sharpe Ratio 33.268% Loss Rate 21% Win Rate 79% Profit-Loss Ratio 2.56 Alpha 0.016 Beta 0.522 Annual Standard Deviation 0.092 Annual Variance 0.008 Information Ratio -0.487 Tracking Error 0.085 Treynor Ratio 0.153 Total Fees $2258.20 Estimated Strategy Capacity $92000000.00 Lowest Capacity Asset IEF SGNKIKYGE9NP |
# Stocks-Bond Portfolio with Take Profit # ------------------------------------------------------ ASSETS = ["QQQ", 'XLP', 'IEF']; MA = 100; TP = 0.10; # ------------------------------------------------------ class StocksBondPortfolioTakeProfit(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 3, 26) self.SetCash(1000000) self.assets = [self.AddEquity(ticker, Resolution.Daily).Symbol for ticker in ASSETS] self.ma = self.SMA(self.assets[0], MA, Resolution.Daily) self.SetWarmUp(MA, Resolution.Daily) def OnData(self, data): if self.IsWarmingUp or not self.ma.IsReady: return pnl = 0 for sec in self.assets: pnl += self.Securities[sec].Holdings.UnrealizedProfitPercent ma = self.ma.Current.Value price = self.Securities[self.assets[0]].Price if not self.Portfolio[self.assets[0]].Invested: if price > ma: for sec in self.assets: self.SetHoldings(sec, 1/len(self.assets)) elif pnl >= TP: self.Liquidate()