In partnership with

When Is the Right Time to Retire?

Determining when to retire is one of life’s biggest decisions, and the right time depends on your personal vision for the future. Have you considered what your retirement will look like, how long your money needs to last and what your expenses will be? Answering these questions is the first step toward building a successful retirement plan.

Our guide, When to Retire: A Quick and Easy Planning Guide, walks you through these critical steps. Learn ways to define your goals and align your investment strategy to meet them. If you have $1,000,000 or more saved, download your free guide to start planning for the retirement you’ve worked for.

🔔 Flash Launch Alert: AlgoEdge Colab Vault – Your 2026 Trading Edge! 🔔

The $79 book gives you ideas on paper.
This gives you 20 ready-to-run money machines in Google Colab.

I've turned my 20 must-have, battle-tested Python strategies into fully executable Google Colab notebooks – ready to run in your browser with one click.

One-click notebooks • Real-time data • Bias-free backtests • Interactive charts • OOS tests • CSV exports • Pro metrics

Test on any ticker instantly (SPY, BTC, PLTR, TSLA, etc.).

Launch Deal (ends Feb 28, 2026):
$129 one-time (save $40 – regular $169 after)

Lifetime access + free 2026 updates.

Inside the Vault (20 powerhouses):

  • Bias-Free Cubic Poly Trend

  • 3-State HMM Volatility Filter

  • MACD-RSI Momentum

  • Bollinger Squeeze Breakout

  • Supertrend ATR Rider

  • Ichimoku Cloud

  • VWAP Scalper

  • Donchian Breakout

  • Keltner Reversion

  • RSI Divergence

  • MA Ribbon Filter

  • Kalman Adaptive Trend

  • ARIMA-GARCH Vol Forecast

  • LSTM Predictor

  • Random Forest Regime Classifier

  • Pairs Cointegration

  • Monte Carlo Simulator

  • FinBERT Sentiment

  • Straddle IV Crush

  • Fibonacci Retracement

👇 Grab It Before Price Jumps 👇
Buy Now – $129

P.S. Run code today → test live tomorrow → outperform the book readers.

Reply “VAULT” for direct link or questions.

Premium Members – Your Full Notebook Is Ready

The complete Google Colab notebook from today’s article (with live data, full Hidden Markov Model, interactive charts, statistics, and one-click CSV export) is waiting for you.

Preview of what you’ll get:

Inside:

  • Use 12-month momentum to determine market regime

  • Go long when momentum is positive

  • Stay in cash when momentum is negative

  • Apply volatility targeting to stabilize risk

  • Use weekly data to reduce noise and turnover

Free readers – you already got the full breakdown and visuals in the article. Paid members – you get the actual tool.

Not upgraded yet? Fix that in 10 seconds here👇

Google Collab Notebook With Full Code Is Available In the End Of The Article Behind The Paywall 👇 (For Paid Subs Only)

Buy and sell signals on weekly S&P 500 price data

Instead of predicting the market, I tested whether reacting to long term trends is enough to control risk.

The goal was to test a 12-month time-series momentum strategy on the US equity market and evaluate whether it can meaningfully reduce risk compared to buy and hold, without relying on prediction, frequent trading, or complex models.

Using weekly data, a long-term momentum filter, and volatility targeting, the strategy aims to stay invested during sustained uptrends and step aside during prolonged market weakness.

The focus is not on maximizing returns, but on improving risk-adjusted performance and reducing drawdowns.

The results are measured directly against buy and hold.

What investment is rudimentary for billionaires but ‘revolutionary’ for 70,571+ investors entering 2026?

Imagine this. You open your phone to an alert. It says, “you spent $236,000,000 more this month than you did last month.”

If you were the top bidder at Sotheby’s fall auctions, it could be reality.

Sounds crazy, right? But when the ultra-wealthy spend staggering amounts on blue-chip art, it’s not just for decoration.

The scarcity of these treasured artworks has helped drive their prices, in exceptional cases, to thin-air heights, without moving in lockstep with other asset classes.

The contemporary and post war segments have even outpaced the S&P 500 overall since 1995.*

Now, over 70,000 people have invested $1.2 billion+ across 500 iconic artworks featuring Banksy, Basquiat, Picasso, and more.

How? You don’t need Medici money to invest in multimillion dollar artworks with Masterworks.

Thousands of members have gotten annualized net returns like 14.6%, 17.6%, and 17.8% from 26 sales to date.

*Based on Masterworks data. Past performance is not indicative of future returns. Important Reg A disclosures: masterworks.com/cd

The Core Idea Behind the Strategy

Time-series momentum is based on a simple observation. Markets tend to continue moving in the same direction over longer horizons.

Instead of asking whether the market is cheap or expensive, this strategy asks whether the market has shown enough positive momentum over the past 12 months to justify being invested. If the answer is yes, the strategy takes exposure. If the answer is no, it stays out.

To avoid taking the same amount of risk in all market conditions, volatility targeting is added. Position size is adjusted so that overall risk remains relatively stable even when market volatility changes.

This combination creates a slow, rules-based system that trades infrequently and reacts only to sustained changes in market behavior.

Tools, Data, and Assumptions

The strategy is implemented in Python using historical data from Yahoo Finance accessed through the yfinance library. SPY(S&P 500 ETF) is used as a proxy for the US equity market. Prices are adjusted for dividends and splits.

Weekly data is used instead of daily data to reduce noise and align the system with a long-term investment horizon. All calculations are done using information that would have been available at the time to avoid lookahead bias.

Strategy Implementation in Python

Installing and Importing Dependencies

The environment is set up by installing yfinance and importing the required data analysis and visualization libraries.

%pip install yfinance --quiet
import yfinance as yf
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = (14, 6)
plt.rcParams["axes.grid"] = True

Downloading and Preparing Market Data

SPY data is downloaded starting from 2000. Prices are adjusted automatically, and the data is resampled to weekly frequency using Friday closes.

ticker = "SPY"  # S&P 500 ETF
start_date = "2000-01-01"

data = yf.download(ticker, start=start_date, auto_adjust=True)
weekly = data.resample("W-FRI").last()

weekly.head()

Establishing a Price Baseline

Before applying indicators, it is important to understand the underlying price behavior of the market.

plt.plot(weekly.index, weekly["Close"], label="Price")
plt.title(f"{ticker} Weekly Price")
plt.xlabel("Date")
plt.ylabel("Price")
plt.legend()
plt.savefig("spy_weekly_price.png")
plt.show()

Weekly SPY price from 2000

Calculating 12-Month Momentum

Momentum is defined as the percentage return over the previous 52 weeks. This serves as the trend filter for the strategy.

lookback = 52
weekly["Momentum"] = weekly["Close"].pct_change(lookback)

weekly[["Close", "Momentum"]].dropna().head()

Generating the Trading Signal

When momentum is positive, the strategy allows long exposure. When momentum is negative, it stays out of the market. The signal is shifted forward to avoid lookahead bias.

weekly["Signal"] = np.where(weekly["Momentum"] > 0, 1, 0)
weekly["Signal"] = weekly["Signal"].shift(1)  # avoid lookahead bias

Applying Volatility Targeting

Volatility targeting adjusts position size based on recent market volatility. The goal is to target a consistent level of annual risk rather than a fixed allocation.

target_vol = 0.10  # 10% annual volatility
weekly["Returns"] = weekly["Close"].pct_change()

rolling_vol = weekly["Returns"].rolling(52).std() * np.sqrt(52)
weekly["Position"] = (target_vol / rolling_vol) * weekly["Signal"]
weekly["Position"] = weekly["Position"].clip(0, 1)

weekly[["Signal", "Position"]].dropna().head()

Calculating Strategy and Benchmark Returns

Strategy returns are calculated using the dynamic position size. Buy and hold returns are calculated for comparison.

weekly["Strategy_Returns"] = weekly["Position"] * weekly["Returns"]
weekly["Cumulative_Strategy"] = (1 + weekly["Strategy_Returns"]).cumprod()
weekly["Cumulative_BuyHold"] = (1 + weekly["Returns"]).cumprod()

Removing Warm-Up Periods

Rows affected by indicator warm-up periods are removed before analysis and visualization.

weekly_clean = weekly.dropna().copy()

Comparing Long-Term Growth

This chart compares the cumulative performance of the momentum strategy with buy and hold.

plt.plot(
    weekly_clean.index,
    weekly_clean["Cumulative_Strategy"],
    label="Strategy"
)

plt.plot(
    weekly_clean.index,
    weekly_clean["Cumulative_BuyHold"],
    label="Buy & Hold",
    alpha=0.7
)

plt.title("Cumulative Returns Comparison")
plt.ylabel("Growth of $1")
plt.legend()
plt.savefig("cumulative_returns_comparison.png")
plt.show()

Cumulative returns of the momentum strategy versus buy and hold

Visualizing Entry and Exit Points

This visualization shows how the strategy enters and exits the market based on long-term momentum changes.

buy_signals = weekly_clean[
    (weekly_clean["Signal"] == 1) &
    (weekly_clean["Signal"].shift(1) == 0)
]

sell_signals = weekly_clean[
    (weekly_clean["Signal"] == 0) &
    (weekly_clean["Signal"].shift(1) == 1)
]

plt.plot(
    weekly_clean.index,
    weekly_clean["Close"],
    label="Price",
    alpha=0.8
)

plt.scatter(
    buy_signals.index,
    buy_signals["Close"],
    marker="^",
    color="green",
    label="Buy",
    zorder=3
)

plt.scatter(
    sell_signals.index,
    sell_signals["Close"],
    marker="v",
    color="red",
    label="Sell",
    zorder=3
)

plt.title("Buy and Sell Signals")
plt.legend()
plt.savefig("buy_sell_signals.png")
plt.show()

Buy and sell signals on weekly price data

Stay informed. And actually enjoy it.

Most investing news tells you what happened. Very little helps you understand why it matters.

Brew Markets focuses on the context behind the moves — what’s driving stocks and where the real signals are hiding. It’s written in plain English and respects your time.

The result? Market coverage that helps you spot what matters sooner and stay engaged, without feeling overwhelmed.

Because the best investing news doesn’t just inform you. It actually sticks.

Evaluating Drawdowns

Drawdowns show how much capital is lost from peak to trough. Reducing drawdowns is a primary objective of this strategy.

rolling_max = weekly_clean["Cumulative_Strategy"].cummax()
drawdown = weekly_clean["Cumulative_Strategy"] / rolling_max - 1

plt.fill_between(drawdown.index, drawdown, 0)
plt.title("Strategy Drawdowns")
plt.ylabel("Drawdown")
plt.savefig("strategy_drawdowns.png")
plt.show()

Drawdowns of the momentum strategy over time

Final Performance Comparison

The table below summarizes the performance of buy and hold versus the 12-month time-series momentum strategy.

def performance_metrics(returns):
    ann_return = (1 + returns.mean()) ** 52 - 1
    ann_vol = returns.std() * np.sqrt(52)
    sharpe = ann_return / ann_vol

    cumulative = (1 + returns).cumprod()
    rolling_max = cumulative.cummax()
    max_dd = (cumulative / rolling_max - 1).min()

    return ann_return, ann_vol, sharpe, max_dd


metrics = pd.DataFrame(
    [
        performance_metrics(weekly_clean["Returns"]),
        performance_metrics(weekly_clean["Strategy_Returns"])
    ],
    columns=["Annual Return", "Annual Volatility", "Sharpe Ratio", "Max Drawdown"],
    index=["Buy & Hold", "Strategy"]
)

metrics
            Annual Return    Annual Volatility    Sharpe Ratio    Max Drawdown
Buy & Hold  0.103782         0.176047             0.589514        -0.546130
Strategy    0.064627         0.085261             0.757993        -0.135246

What the Results Show

The momentum strategy produces lower annual returns than buy and hold. However, it does so with significantly lower volatility and much smaller drawdowns.

The maximum drawdown is reduced from more than 50% to around 13%, and the risk-adjusted return improves meaningfully.

This outcome reflects the core trade-off of trend following. Some upside is sacrificed in strong bull markets in exchange for protection during prolonged market declines.

A More Practical Way to Stay Invested

This strategy is not designed to outperform the market in every environment. It is designed to make long-term participation more manageable.

By reducing drawdowns and smoothing returns, the strategy increases the likelihood that an investor can remain disciplined through different market regimes. For many, that may be more valuable than chasing the highest possible return.

The 12-month time-series momentum approach offers a structured way to respect market trends while keeping risk under control.

logo

Subscribe to our premium content to read the rest.

Become a paying subscriber to get access to this post and other subscriber-only content.

Upgrade

Keep Reading