Overall Statistics |
Total Orders 4863 Average Win 0.16% Average Loss -0.45% Compounding Annual Return 3.525% Drawdown 32.700% Expectancy 0.056 Start Equity 100000 End Equity 180045.66 Net Profit 80.046% Sharpe Ratio 0.126 Sortino Ratio 0.123 Probabilistic Sharpe Ratio 0.023% Loss Rate 22% Win Rate 78% Profit-Loss Ratio 0.35 Alpha -0.005 Beta 0.283 Annual Standard Deviation 0.104 Annual Variance 0.011 Information Ratio -0.331 Tracking Error 0.15 Treynor Ratio 0.046 Total Fees $8482.12 Estimated Strategy Capacity $1800000.00 Lowest Capacity Asset GSG TKH7EPK7SRC5 Portfolio Turnover 6.81% |
#region imports from AlgorithmImports import * import numpy as np from datetime import datetime #endregion # https://quantpedia.com/Screener/Details/1 # Use 5 ETFs (SPY - US stocks, EFA - foreign stocks, BND - bonds, VNQ - REITs, # GSG - commodities), equal weight the portfolio. Hold asset class ETF only when # it is over its 10 month Simple Moving Average, otherwise stay in cash. class AssetClassTrendFollowingAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2007, 5, 1) self.set_cash(100000) self._data = {} period = 10*21 self.set_warm_up(period) symbols = ["SPY", "EFA", "BND", "VNQ", "GSG"] for symbol in symbols: self.add_equity(symbol, Resolution.DAILY) self._data[symbol] = self.sma(symbol, period, Resolution.DAILY) def on_data(self, data): if self.is_warming_up: return is_uptrend = [] for symbol, sma in self._data.items(): if self.securities[symbol].price > sma.current.value: is_uptrend.append(symbol) else: self.liquidate(symbol) for symbol in is_uptrend: self.set_holdings(symbol, 1/len(is_uptrend))