| Overall Statistics |
|
Total Trades 538 Average Win 0.16% Average Loss -0.14% Compounding Annual Return 5.011% Drawdown 26.400% Expectancy 0.943 Net Profit 63.062% Sharpe Ratio 0.442 Probabilistic Sharpe Ratio 2.609% Loss Rate 10% Win Rate 90% Profit-Loss Ratio 1.15 Alpha 0.054 Beta -0.067 Annual Standard Deviation 0.106 Annual Variance 0.011 Information Ratio -0.32 Tracking Error 0.198 Treynor Ratio -0.699 Total Fees $548.16 |
'''An implementation of Meb Faber's base model: Global Tactical Asset Allocation model (GTAA)(5)
Buy&Hold portfolio (monthly rebalance), as found in the paper:
"A Quantitative Approach to Tactical Asset Allocation" published May 2006.
'''
class GlobalTacticalAssetAllocationBase(QCAlgorithm):
def Initialize(self):
backtestDuration = 365*10
self.SetStartDate(datetime.now() - timedelta(backtestDuration))
self.SetEndDate(datetime.now())
self.SetCash(100000)
self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
self.UniverseSettings.Resolution = Resolution.Daily
symbols = [Symbol.Create(ticker, SecurityType.Equity, Market.USA)
for ticker in [ "SPY", # US Large Cap ETF
"VEA", # Developed Foreign Stocks (TradedSince: 2007/8)ETF
"IEF", # US 10Y Gov.Bonds ETF
"DBC", # GSCI Commodities ETF (TradedSince: 2006/3)
"VNQ" # US RealEstate ETF
]]
self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))
self.AddAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(days = backtestDuration), None, None))
self.Settings.RebalancePortfolioOnInsightChanges = False
self.Settings.RebalancePortfolioOnSecurityChanges = False
self.SetPortfolioConstruction( EqualWeightingPortfolioConstructionModel(self.DateRules.MonthStart()) )
self.SetExecution( ImmediateExecutionModel() )
self.AddRiskManagement( NullRiskManagementModel() )
# 1) Setting a Benchmark to plot with equity
self.benchmarkTicker = 'SPY'
self.SetBenchmark(self.benchmarkTicker)
self.initBenchmarkPrice = None
def UpdateBenchmarkValue(self):
''' Simulate buy and hold the Benchmark '''
if self.initBenchmarkPrice is None:
self.initBenchmarkCash = self.Portfolio.Cash
self.initBenchmarkPrice = self.Benchmark.Evaluate(self.Time)
self.benchmarkValue = self.initBenchmarkCash
else:
currentBenchmarkPrice = self.Benchmark.Evaluate(self.Time)
self.benchmarkValue = (currentBenchmarkPrice / self.initBenchmarkPrice) * self.initBenchmarkCash
def OnData(self, data):
# 2) simulate buy and hold the benchmark and plot its daily value as we are using daily data.
# Otherwise schedule when to call this function!
self.UpdateBenchmarkValue()
self.Plot('Strategy Equity', self.benchmarkTicker, self.benchmarkValue)