Overall Statistics
Total Trades
75
Average Win
3.34%
Average Loss
0%
Compounding Annual Return
8.830%
Drawdown
35.000%
Expectancy
0
Net Profit
290.480%
Sharpe Ratio
0.512
Sortino Ratio
0.566
Probabilistic Sharpe Ratio
4.168%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.035
Beta
0.233
Annual Standard Deviation
0.099
Annual Variance
0.01
Information Ratio
-0.107
Tracking Error
0.157
Treynor Ratio
0.218
Total Fees
$102.27
Estimated Strategy Capacity
$6500000.00
Lowest Capacity Asset
DBC TFVSB03UY0DH
Portfolio Turnover
0.06%
# region imports
from AlgorithmImports import *
# endregion

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(2008, 1, 1)  
        #self.SetEndDate(2020, 1, 31)  
        self.SetCash(100000) 
        self.monthCounter = 0
        # 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.5
        self.monthCounter = 1
    def OnData(self, data):
       pass
     
    def Rebalance(self):
        if self.monthCounter is 12:
            self.SetHoldings([PortfolioTarget(etf,target*self.leverage) for etf,target in self.etfs])
            self.monthCounter = 1
        else:
            self.monthCounter = self.monthCounter+1