Overall Statistics
Total Trades
782
Average Win
0.19%
Average Loss
-0.08%
Compounding Annual Return
6.886%
Drawdown
16.400%
Expectancy
1.823
Net Profit
140.996%
Sharpe Ratio
0.864
Probabilistic Sharpe Ratio
29.495%
Loss Rate
17%
Win Rate
83%
Profit-Loss Ratio
2.40
Alpha
0.059
Beta
-0.021
Annual Standard Deviation
0.066
Annual Variance
0.004
Information Ratio
-0.082
Tracking Error
0.193
Treynor Ratio
-2.653
Total Fees
$1039.19
from datetime import datetime
from collections import *

### <summary>
### All Weather Strategy (Dalio)
### #https://www.iwillteachyoutoberich.com/blog/all-weather-portfolio/
### </summary>>
# https://www.quantconnect.com/forum/discussion/7411/ray-dalio-039-s-all-weather-strategy/p1

class AllWeatherStrategy(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2007, 1, 1)
        self.SetCash(1000000) 
        self.monthCounter = 0

        # # Country index ETFs according to https://seekingalpha.com/etfs-and-funds/etf-tables/countries
        # self.etfs_alt = [
        #     (self.AddEquity('QQQ', Resolution.Daily).Symbol,0.25),
        #     (self.AddEquity('XLU', Resolution.Daily).Symbol,0.25),
        #     (self.AddEquity('NVDA', Resolution.Daily).Symbol,0.25),
        #     (self.AddEquity('GLD', Resolution.Daily).Symbol,0.25),
        #     (self.AddEquity('MSFT', Resolution.Daily).Symbol,0.25),
        #     ]

        # 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.AfterMarketOpen(self.etfs[0][0]), self.Rebalance)
        self.leverage = 1.0
        
    def OnData(self, data):
       pass
     
    def Rebalance(self):
        self.SetHoldings([PortfolioTarget(etf,target*self.leverage) for etf,target in self.etfs])