| Overall Statistics |
|
Total Orders 225 Average Win 1.54% Average Loss -1.65% Compounding Annual Return 16.008% Drawdown 22.200% Expectancy 0.312 Start Equity 100000 End Equity 210161.94 Net Profit 110.162% Sharpe Ratio 0.552 Sortino Ratio 0.644 Probabilistic Sharpe Ratio 24.484% Loss Rate 32% Win Rate 68% Profit-Loss Ratio 0.93 Alpha 0.018 Beta 0.875 Annual Standard Deviation 0.154 Annual Variance 0.024 Information Ratio 0.09 Tracking Error 0.094 Treynor Ratio 0.097 Total Fees $601.50 Estimated Strategy Capacity $45000000.00 Lowest Capacity Asset VGT SVS2QA8SPHET Portfolio Turnover 2.63% Drawdown Recovery 570 |
#region imports
from AlgorithmImports import *
#endregion
# https://quantpedia.com/Screener/Details/3
# Use 10 sector ETFs. Pick 3 ETFs with strongest 3 month momentum into your portfolio
# and weigh them equally. Hold for 1 month and then rebalance.
class SectorMomentumAlgorithm(QCAlgorithm):
def initialize(self):
self.set_start_date(self.end_date - timedelta(5*365))
self.set_cash(100000)
self.settings.automatic_indicator_warm_up = True
tickers = ["VNQ", # Vanguard Real Estate Index Fund
"XLK", # Technology Select Sector SPDR Fund
"XLE", # Energy Select Sector SPDR Fund
"XLV", # Health Care Select Sector SPDR Fund
"XLF", # Financial Select Sector SPDR Fund
"KBE", # SPDR S&P Bank ETF
"VAW", # Vanguard Materials ETF
"XLY", # Consumer Discretionary Select Sector SPDR Fund
"XLP", # Consumer Staples Select Sector SPDR Fund
"VGT"] # Vanguard Information Technology ETF
for ticker in tickers:
equity = self.add_equity(ticker, Resolution.DAILY)
# Three-month momentum (3 x 22 days)
equity.momp = self.momp(equity.symbol, 3*22, Resolution.DAILY)
# schedule the function to fire at the month start
self.schedule.on(
self.date_rules.month_start("VNQ"),
self.time_rules.midnight,
self._rebalance)
def _rebalance(self):
# Pick 3 ETFs with strongest momentum and weight them equally.
to_long = [x.symbol for x in sorted(self.securities.values(), key=lambda s: s.momp)[-3:]]
targets = [PortfolioTarget(symbol, 1/3) for symbol in to_long]
self.set_holdings(targets, liquidate_existing_holdings=True)