Overall Statistics
Total Trades
10
Average Win
0.86%
Average Loss
0%
Compounding Annual Return
10.321%
Drawdown
13.900%
Expectancy
0
Net Profit
25.769%
Sharpe Ratio
1.339
Probabilistic Sharpe Ratio
66.589%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.084
Beta
0.028
Annual Standard Deviation
0.064
Annual Variance
0.004
Information Ratio
0.11
Tracking Error
0.223
Treynor Ratio
3.069
Total Fees
$12.51
from datetime import datetime
from collections import *

### <summary>
### All Weather Strategy (Dalio)
### #https://www.iwillteachyoutoberich.com/blog/all-weather-portfolio/
### </summary>>


class AllWeatherStrategy(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2018, 1, 1)  
        self.SetEndDate(2020, 5, 1)  
        self.SetCash(100000) 

        # Country index ETFs according to https://seekingalpha.com/etfs-and-funds/etf-tables/countries
        self.etfs = [
            (self.AddEquity('VTI', Resolution.Daily).Symbol, 0.3), #Vanguard Total Stock Market ETF
            (self.AddEquity('TLT', Resolution.Daily).Symbol, 0.4), # iShares 20+ Year Treasury ETF (TLT)
            (self.AddEquity('IEF', Resolution.Daily).Symbol, 0.15),  #iShares 7 – 10 Year Treasury ETF (IEF)
            (self.AddEquity('GLD', Resolution.Daily).Symbol, 0.075), #SPDR Gold Shares ETF (GLD),  #SPDR Gold Shares (GLD)  
            (self.AddEquity('DBC', Resolution.Daily).Symbol, 0.075) # PowerShares DB Commodity Index Tracking Fund (DBC)"
            ]
            
        self.Schedule.On(self.DateRules.MonthStart(self.etfs[0][0]), \
                        self.TimeRules.BeforeMarketClose(self.etfs[0][0]), self.Rebalance)
        
        self.leverage = 1.0
        self.monthCounter = 12
        
    def OnData(self, data):
       pass
     
    def Rebalance(self):
        if self.monthCounter == 12:
            self.SetHoldings([PortfolioTarget(etf,target*self.leverage) for etf,target in self.etfs])
            self.monthCounter = 1
        else:
            self.monthCounter += 1