Overall Statistics |
Total Trades 6549 Average Win 0.03% Average Loss -0.03% Compounding Annual Return 1.152% Drawdown 29.900% Expectancy 0.696 Net Profit 16.194% Sharpe Ratio 0.145 Probabilistic Sharpe Ratio 0.032% Loss Rate 18% Win Rate 82% Profit-Loss Ratio 1.08 Alpha -0.03 Beta 0.45 Annual Standard Deviation 0.102 Annual Variance 0.01 Information Ratio -0.723 Tracking Error 0.118 Treynor Ratio 0.033 Total Fees $6551.83 |
# Dalio permanent portfolio with regular withdrawals class AllWeatherStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2008, 1, 1) self.SetEndDate(2021, 2, 4) self.InitCash = 100000 self.SetCash(self.InitCash) self.MKT = self.AddEquity("SPY", Resolution.Minute).Symbol self.mkt = [] self.etfs = [ (self.AddEquity('SPY', Resolution.Daily).Symbol,0.4), (self.AddEquity('TLT', Resolution.Daily).Symbol,0.3), (self.AddEquity('IEF', Resolution.Daily).Symbol,0.15), (self.AddEquity('GLD', Resolution.Daily).Symbol,0.075), (self.AddEquity('VPU', Resolution.Daily).Symbol,0.075) ] self.Schedule.On(self.DateRules.EveryDay(self.etfs[0][0]), self.TimeRules.AfterMarketOpen(self.etfs[0][0]), self.Rebalance) self.withdraw = 0.0003 self.leverage = 1.1 def Withdraw(self): withdrawal_amount = self.Portfolio.TotalPortfolioValue * self.withdraw current_cash = self.Portfolio.CashBook[self.AccountCurrency].Amount self.Portfolio.CashBook.Add(self.AccountCurrency, current_cash - withdrawal_amount, 1) self.Plot("Custom", "Withdrawal", withdrawal_amount) def Rebalance(self): self.SetHoldings([PortfolioTarget(etf, target * self.leverage * (1 - self.withdraw)) for etf, target in self.etfs]) self.Withdraw() def OnEndOfDay(self): self.Plot("Custom", "Cash", self.Portfolio.Cash) account_leverage = self.Portfolio.TotalHoldingsValue / self.Portfolio.TotalPortfolioValue self.Plot('Holdings', 'leverage', round(account_leverage, 2))