Overall Statistics
Total Trades
190
Average Win
1.07%
Average Loss
-0.37%
Compounding Annual Return
12.597%
Drawdown
8.000%
Expectancy
1.638
Net Profit
77.624%
Sharpe Ratio
1.688
Probabilistic Sharpe Ratio
94.671%
Loss Rate
32%
Win Rate
68%
Profit-Loss Ratio
2.89
Alpha
0.07
Beta
0.121
Annual Standard Deviation
0.051
Annual Variance
0.003
Information Ratio
-0.341
Tracking Error
0.147
Treynor Ratio
0.718
Total Fees
$190.00
Estimated Strategy Capacity
$45000000.00
Lowest Capacity Asset
DBC TFVSB03UY0DH
from datetime import datetime
from collections import *

class AllWeatherStrategy(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2017, 1, 1)
        #self.SetEndDate(2009, 1, 1)
        self.SetCash(10000) 
        self.monthCounter = 0
        
        self.etfs = [
            (self.AddEquity('QQQ', Resolution.Daily).Symbol,0.35), #High Growth Stocks
            (self.AddEquity('TLT', Resolution.Daily).Symbol,0.4), # iShares 20+ Year Treasury ETF (TLT)
            (self.AddEquity('VEA', Resolution.Daily).Symbol,0.15),  #iShares 7 – 10 Year Treasury ETF (IEF)
            (self.AddEquity('BITO', 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
        
        self.vix_price = self.GetParameter("vix-price")
        self.vix_price = float(self.vix_price) if self.vix_price else 30
        self.vix = self.AddIndex("VIX", Resolution.Minute).Symbol

        
    def OnData(self, data):
        if self.Securities[self.vix].Price > self.vix_price:
            self.Liquidate()
            self.Log("ONDATA VIX CHECK FAILED LIQUIDATING")
        pass

    def Rebalance(self):
        if not self.Securities[self.vix].Price > self.vix_price:
            self.SetHoldings([PortfolioTarget(etf,target*self.leverage) for etf,target in self.etfs])
        else: pass