Overall Statistics
Total Trades
16
Average Win
0.03%
Average Loss
-0.06%
Compounding Annual Return
-12.353%
Drawdown
11.200%
Expectancy
-0.086
Net Profit
-8.370%
Sharpe Ratio
-1.217
Probabilistic Sharpe Ratio
2.211%
Loss Rate
38%
Win Rate
62%
Profit-Loss Ratio
0.46
Alpha
-0.103
Beta
-0.028
Annual Standard Deviation
0.082
Annual Variance
0.007
Information Ratio
0.106
Tracking Error
0.211
Treynor Ratio
3.58
Total Fees
$44.88
### <summary>
### All Weather Strategy (Dalio)
### https://www.iwillteachyoutoberich.com/blog/all-weather-portfolio/
### </summary>>


class AllWeatherStrategy(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2008, 1, 1)  
        self.SetEndDate(2008, 8, 31)  
        self.SetCash(500000) 
        self.monthCounter = 0
        
        self.etfs = [
            (self.AddEquity('SPY', Resolution.Daily).Symbol,0.5),   #S&P 500
            (self.AddEquity('TLT', Resolution.Daily).Symbol,0.5),   #iShares 20+ Year Treasury ETF (TLT) / EU alternative: IS04 https://www.ishares.com/de/privatanleger/de/produkte/272124/ishares-usd-treasury-bond-20-yr-ucits-etf
            ]
        self.Schedule.On(self.DateRules.MonthStart(self.etfs[0][0]), self.TimeRules.AfterMarketOpen(self.etfs[0][0]), self.Rebalance)
        self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(0, 0), self.Withdraw)
        self.leverage = 1
     
    def Withdraw(self):
        withdraw_amount = self.Portfolio.TotalPortfolioValue * 0.0002
        current_cash = self.Portfolio.CashBook[self.AccountCurrency].Amount
        self.Portfolio.CashBook.Add(self.AccountCurrency, current_cash - withdraw_amount, 1)
     
    def Rebalance(self):
        self.SetHoldings([PortfolioTarget(etf, target) for etf, target in self.etfs])
        self.Plot("Custom", "Cash", self.Portfolio.Cash)