The buyandhold strategy is perhaps the most famous and timetested approach in equity investing. In its simplest form, an investor purchases a basket of stocks (or a single security) and keeps it for years, ignoring shortterm market noise. The allure lies in the belief that over long periods equities tend to rise, delivering solid real returns after inflation.
Realworld investing confronts us with constraints that are hard to replicate in a classroom: capital limits, tax consequences, transaction costs, and emotional pressure during market crashes. A simulation lets us isolate the pure effect of the strategy, observe outcomes under different market conditions, and test variations (e.g., adding a periodic rebalancing step).
import pandas as pdimport yfinance as yf# 1. Download datatickers = ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'SPY']data = yf.download(tickers, start='1995-01-01', end='2025-01-01')['Adj Close']# 2. Create equalweight portfolioweights = [1/len(tickers)] * len(tickers)# 3. Compute daily portfolio valuedaily_returns = data.pct_change().fillna(0)portfolio_daily = (daily_returns * weights).sum(axis=1) + 1portfolio_value = 100000 * portfolio_daily.cumprod()# 4. Metricscagr = (portfolio_value[-1] / portfolio_value[0]) ** (1/30) - 1max_drawdown = (portfolio_value / portfolio_value.cummax() - 1).min()volatility = portfolio_daily.std() * (252**0.5)print(f"CAGR: {cagr:.2%}")print(f"Max Drawdown: {max_drawdown:.2%}")print(f"Annual Volatility: {volatility:.2%}") When the above script is run with the specified tickers, typical outcomes look like:
| Metric | Result (30year horizon) |
|---|---|
| Compound Annual Growth Rate (CAGR) | 9.8% |
| Maximum Drawdown | -22.5% |
| Annual Volatility | 15.2% |
The CAGR of roughly 10% mirrors the historical performance of the S&P500, while the maximum drawdown shows the deepest singleperiod loss an investor would have experienced. The volatility number gives a sense of the yeartoyear swings the portfolio endured.
Buy and hold guarantees profit. The strategy improves the odds of positive returns over long horizons but does not protect against prolonged bear markets, structural declines, or the risk of a single company going bankrupt.
I can ignore taxes. In a taxable account, holding equities for more than a year qualifies for lower longterm capitalgains rates, which is a real advantage. Simulations that ignore taxes may overstate net performance for investors who cannot use a taxadvantaged wrapper.
After mastering the basic model, you can explore many whatif scenarios:
A wellconstructed buyandhold simulation demonstrates why the strategy has stood the test of time: modest, steady growth with acceptable risk when measured over decades. The simple mathematics behind the modelcompounding returns minus transaction costsare powerful enough that even novice investors can achieve results comparable to professional managers, provided they stay disciplined, diversified, and patient.
Use the code snippet above as a starting point, tinker with the parameters, and observe how each change influences the end result. The insight you gain from watching a portfolio march forward through bull markets, bear markets, and everything in between is invaluable for building confidence in a strategy that, at its core, is as straightforward as buy and hold.
For further reading, see the classic works of Warren Buffett, the academic paper Stocks for the Long Run by Jeremy Siegel, and the Investopedia guide to buyandhold investing.
