Buying and Holding Tech Stocks: $500k in 10 Years : Chris

Buying and Holding Tech Stocks: $500k in 10 Years
by: Chris
blow post content copied from  Be on the Right Side of Change
click here to view original post

Rate this post

💡 Disclaimer: Just a heads up: this isn’t financial advice! Always do your own research and talk to a professional before making any investment decisions.

Here are the top technology companies by market cap in 2014 (source):

Let’s assume a simple buy-and-hold strategy where you simply buy the top six tech stocks (by market cap) in the year 2014, assuming you don’t have any particular insight into the tech industry (e.g., seeing NVidia or Tesla early):

  • Apple
  • Google
  • Microsoft
  • IBM
  • Oracle
  • Meta
tech_stocks = ['AAPL', 'GOOGL', 'MSFT', 'IBM', 'ORCL', 'META']

In the US, the average income of a coder was roughly $76k per year in 2014 (source).

If you save only 10% of that, i.e., $7,200 per year or $600 monthly and you distribute that equally across the six chosen tech stocks, here’s the annual ownership of your stock portfolio:

📈 Table: The table displays the year-end values of equal monthly $100-investments in our six tech stocks from 2014 to 2024, alongside their Compound Annual Growth Rates (CAGR).

Each row corresponds to a different stock, with columns indicating the investment’s worth at the close of each year.

The CAGR column reflects the average annual growth rate of the investment over the ten-year period.

For instance, an investment in Apple (AAPL) grew from $1,734 in 2014 to $134,446 by 2024, with a CAGR of 27.38% and annual contributions of $1,200 into AAPL.

Your total portfolio value of this simple buy-and-hold portfolio would be north of $500,000 after 10 short years! In this scenario, a 50-year-old could retire today, having started with $0 in 2014!

Assuming the compound annual growth rate remains ~15%, you’re technically retired because you don’t need your $76k paycheck anymore, given your $75k+ return on investment from year 11 onward!


You can recreate this using the following Python script.

First install these libraries:

pip install yfinance pandas numpy matplotlib

Then copy and paste the following code into your Python script ( and run it:

import yfinance as yf
import pandas as pd
import numpy as np
import datetime
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

# Define the time period for the data
end_date =
start_date = end_date - datetime.timedelta(days=10*365)

# List of top tech stocks based on market capitalization from about 10 years ago
tech_stocks = ['AAPL', 'GOOGL', 'MSFT'] # , 'IBM', 'ORCL', 'META'] # , 'TCEHY', 'QCOM', 'INTC', 'CSCO']

# Function to perform dollar-cost averaging investment strategy
def dollar_cost_averaging(initial_investment, monthly_investment, data):
    investment_values = {}
    total_asset_values = pd.Series(dtype=float)

    for stock in tech_stocks:
        # Initial investment
        initial_stock_investment = initial_investment / len(tech_stocks)

        # Monthly investment dates
        investment_dates = pd.date_range(start=data[stock].index[0], end=data[stock].index[-1], freq='M')
        stock_investment = np.zeros(len(data[stock].index))

        # Apply initial investment
        stock_investment[0] += initial_stock_investment

        for date in investment_dates:
            # Find the closest trading date
            closest_date = data[stock].index[data[stock].index.get_loc(date, method='nearest')]
            investment = monthly_investment / len(tech_stocks)
            stock_investment[data[stock].index.get_loc(closest_date)] += investment

        # Calculate cumulative investment
        cumulative_investment = np.cumsum(stock_investment)
        # Adjusted close price for the stock
        adj_close = data[stock]['Adj Close']
        # Calculate asset value over time
        asset_value = cumulative_investment / adj_close.iloc[0] * adj_close

        investment_values[stock] = asset_value
        total_asset_values = total_asset_values.add(asset_value, fill_value=0)

    # Aggregate yearly values
    yearly_values = {}
    for stock, asset_value in investment_values.items():
        # Resample the asset value data to get the value at the end of each year
        yearly_values[stock] = asset_value.resample('Y').last()

    return yearly_values, total_asset_values

# Function to calculate CAGR
def calculate_cagr(start_value, end_value, num_years):
    return (end_value / start_value) ** (1 / num_years) - 1

# Main function to execute the strategy
def main(initial_investment, monthly_investment):
    # Download historical data for the stocks
    stock_data =, start=start_date, end=end_date, group_by='ticker')

    yearly_values, total_asset_values = dollar_cost_averaging(initial_investment, monthly_investment, stock_data)

    # Creating a DataFrame for yearly values
    yearly_table = pd.DataFrame(yearly_values).T
    yearly_table.columns = yearly_table.columns.year  # Use year as column names

    # Format the table for better readability
    formatted_table = yearly_table.round().astype(int).applymap("${:,}".format)

    # Calculate CAGR
    cagr_values = {}
    for stock in tech_stocks:
        start_value = stock_data[stock]['Adj Close'].iloc[0]
        end_value = stock_data[stock]['Adj Close'].iloc[-1]
        num_years = (stock_data[stock].index[-1] - stock_data[stock].index[0]).days / 365.25
        cagr_values[stock] = calculate_cagr(start_value, end_value, num_years)

    cagr_df = pd.DataFrame(cagr_values, index=['CAGR'])
    cagr_df = cagr_df.T
    cagr_df['CAGR'] = cagr_df['CAGR'].apply(lambda x: f'{x:.2%}')

    # Combine yearly values and CAGR in a single DataFrame for display
    combined_df = pd.concat([formatted_table, cagr_df], axis=1)

    print("Yearly Investment Values and CAGR for Each Stock:")

    # Plotting the total asset value over time
    ax = total_asset_values.plot(title='Total Asset Value Over Time')
    ax.yaxis.set_major_formatter(ticker.FuncFormatter(lambda x, p: f'${x/1000:,.0f}K'))
    plt.ylabel('Total Asset Value')

if __name__ == "__main__":
    initial_investment = 0  # Modify this value as needed
    monthly_investment = 600   # Modify this value as needed
    main(initial_investment, monthly_investment)

You can modify the initial and monthly investments in the variables at the bottom of this script. If you don’t know how to run a script, consider this Python guide:

👉 How to Run a Python Script

January 22, 2024 at 08:37PM
Click here for more details...

The original post is available in Be on the Right Side of Change by Chris
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.