BLOG

Behind the numbers.

Code examples, market analysis, and data quality deep-dives.

Is AI Capex Paying Back Fast Enough? Revenue Hurdle Forecasting in Python
Could Shorter AI Asset Lives Hit Earnings? Depreciation Stress Test in Python
How Much AI Capex Risk Can a Portfolio Remove? Constrained Optimization in Python
Is the AI Capex Trade Crowded? Rolling Volatility and Sector Rotation in Python
Did the AI Boom Come From Existing S&P 500 Members? Point-in-Time Momentum Test in Python
Is AI Revenue Circular? Customer-Vendor Capex Loop Analysis in Python
Is the AI Trade Connected to Private Credit? Rolling Correlation Network in Python
Is Apollo More Balance-Sheet Sensitive Than Peers? Leverage Screen in Python
Are AI Earnings Supported by Cash Flow? Accrual and Capex Screen in Python
Can Defensive Stocks Hedge AI Drawdowns? Basket Regime Test in Python
How Fast Does the Market Price In Fed Decisions? FOMC Event Study in Python
How Much Are Options Sellers Overpaid? The Variance Risk Premium in Python
Which Companies Have the Worst Earnings Quality? Sloan Accrual Screen with Geographic Revenue Data in Python
Does the Oil-to-Gold Ratio Signal Recessions? XLE/GLD Backtest in Python
Is AI Spending Crowding Out Free Cash Flow? Capex Sustainability Across the Mag 7 in Python
Does a Long Energy / Short Bonds Portfolio Capture Inflation Surprises? Factor Construction in Python
Can a Hidden Markov Model Detect Oil Market Regimes? HMM Analysis in Python
Do Grain Prices Predict Food Inflation? Granger Causality Test in Python
Does the Corporate Credit Spread Predict Stock Market Crashes? BAA-AAA Spread Analysis in Python
Do Oil Stocks Hedge Inflation? Rolling Beta Analysis in Python
Which Stocks Are Most Rate-Sensitive? Equity Duration via Bond Beta in Python
Which Companies Have the Highest Accrual Ratios? Earnings Quality Screening in Python
Is Alpha Persistent or Decaying? Rolling Sharpe Ratio Analysis in Python
Are Markets Trending or Mean-Reverting? Hurst Exponent Analysis in Python
Is Consumer Discretionary vs Staples a Leading Indicator? XLY/XLP Ratio Analysis in Python
Does Heavy Capex Predict Future Stock Returns? Capital Expenditure Analysis in Python
How to Estimate Cost of Equity Using CAPM in Python
Is Volatility Predictable? Testing for Volatility Clustering in Python
Which Industrials Are Overleveraged? Net Debt to EBITDA Screening in Python
GM Before and After Bankruptcy: Why Entity Resolution Matters for Financial Data
What Is Adjusted Beta? Merrill Lynch Beta Shrinkage in Python
How Good Is a Stock Pick? Information Ratio and Tracking Error in Python
Do Stock Returns Follow a Normal Distribution? Testing for Fat Tails in Python
Which Large Caps Have the Highest Free Cash Flow Yield? FCF Screening in Python
Which Sectors Won Over 5 Years? Sector Rotation Analysis in Python
How to Forecast Stock Volatility with GARCH Models in Python
Are Stock Prices Mean-Reverting? Augmented Dickey-Fuller Test in Python
How to Calculate CAPM Alpha and Beta with Regression in Python
How to Compare Sector Sharpe Ratios and Sortino Ratios in Python
DELL: Why Stitching Historical Price Data Together Is Wrong
How to Analyze Drawdown and Recovery for Bank Stocks in Python
How to Screen SaaS Stocks by Revenue Growth and Cash Flow in Python
How to Screen REITs by Dividend Yield and Valuation in Python
How Correlated Are the Magnificent 7? Intra-Group Correlation in Python
AAPL vs XOM: Do Individual Stocks Have Seasonal Patterns?
How to Rank Large-Cap Stocks by Momentum in Python
How to Build a Multi-Endpoint Financial Dashboard in Python
How to Compare Volatility Across Energy Stocks in Python
How to Screen Healthcare Stocks by Valuation in Python
How to Build a Sector Correlation Matrix for Portfolio Diversification in Python
How to Find Oversold and Overbought Stocks Using Z-Scores in Python
How to Measure Earnings Quality: Cash Flow vs Net Income in Python
How to Build a Multi-Factor Stock Screen in Python (Value + Momentum + Quality)
How to Build a Simple DCF Model for Any Stock in Python
How to Screen Tech Stocks by Revenue Growth in Python
How to Screen Stocks by Balance Sheet Health in Python
Is "Sell in May" Real? SPY Monthly Seasonality Over 10 Years
How to Compare Sector Performance YTD Using Python
How to Track S&P 500 Additions and Removals Over Time in Python
How to Screen Dividend Stocks by Yield and Quality in Python
How to Calculate Max Drawdown and Recovery Time for Any Stock in Python
How to Compare Profitability Across Mega-Cap Tech Stocks in Python
Why Ticker Symbols Are Unreliable: The Recycling Problem Every Quant Should Know
How to Calculate and Compare Stock Volatility in Python
How to Screen Blue-Chip Stocks by P/E Ratio in Python
How to Track Companies Through Ticker Changes, Bankruptcies, and Renames in Python
S&P 500 Turnover: How Much the Index Has Changed Since 2010
How to Calculate Stock Beta and Correlation in Python
← All articles

Does Heavy Capex Predict Future Stock Returns? Capital Expenditure Analysis in Python

What’s the question?

Capital expenditure (capex) represents a company’s investment in future productive capacity — factories, data centers, equipment, technology. When a company dramatically increases capex, it is making a bet on future growth. The question is whether the stock market rewards or punishes this bet. Does heavy capex spending precede strong stock performance, or does it signal overinvestment and diminishing returns? Capex intensity — defined as capital expenditures divided by revenue — normalizes spending across companies of different sizes, allowing direct comparison between a $717B revenue giant like AMZN and a $68B industrial firm like CAT.

The approach

Select 8 large-cap stocks across sectors. Pull 5 years of annual fundamentals including revenue, capital_expenditures, and free_cash_flow. Compute capex intensity (capex divided by revenue) and year-over-year capex growth for each period. Then examine the multi-year trajectories for AMZN and META — the two most aggressive capex spenders in recent years — to understand how their investment strategies have diverged.

import xfinlink as xfl
import pandas as pd

xfl.api_key = "YOUR_API_KEY"  # free at https://xfinlink.com/signup

# -- Configuration ----------------------------------------------------------
tickers = ["AAPL", "MSFT", "AMZN", "META", "XOM", "CAT", "UNH", "HD"]

# -- Fetch 5Y annual fundamentals ------------------------------------------
df = xfl.fundamentals(
    tickers,
    period_type="annual",
    fields=["revenue", "capital_expenditures", "free_cash_flow"],
    period="5y",
)

# -- Compute capex intensity and YoY growth --------------------------------
df = df.sort_values(["ticker", "period_end"])
df["capex_abs"] = df["capital_expenditures"].abs()
df["intensity"] = df["capex_abs"] / df["revenue"]
df["capex_yoy"] = df.groupby("ticker")["capex_abs"].pct_change()

# -- Latest annual period per ticker ---------------------------------------
latest = df.sort_values("period_end").groupby("ticker").tail(1).copy()
latest = latest.sort_values("intensity", ascending=False)

print("=== Capex Intensity: Who Is Investing the Most? (Latest Annual) ===")
header = (
    f"{'Ticker':6s}  {'Period':>12s}  {'Revenue':>12s}  {'Capex':>12s}  "
    f"{'Intensity':>10s}  {'Capex YoY':>10s}"
)
print(header)
print("-" * 65)

for _, r in latest.iterrows():
    rev_str = f"${r['revenue'] / 1e3:>8.0f}B"
    capex_str = f"${r['capex_abs'] / 1e3:>8.0f}B"
    intensity_str = f"{r['intensity']:>9.1%}"
    yoy_str = f"{r['capex_yoy']:>+9.1%}" if pd.notna(r["capex_yoy"]) else "      N/A"
    print(
        f"{r['ticker']:6s}  {str(r['period_end'])[:10]:>12s}  {rev_str:>12s}  "
        f"{capex_str:>12s}  {intensity_str:>10s}  {yoy_str:>10s}"
    )

# -- AMZN trajectory -------------------------------------------------------
print("\n=== AMZN Capex Trajectory ===")
amzn = df[df["ticker"] == "AMZN"].dropna(subset=["capex_abs"])
for _, r in amzn.iterrows():
    yoy_str = f"YoY={r['capex_yoy']:+.1%}" if pd.notna(r["capex_yoy"]) else "YoY=N/A"
    print(
        f"  {str(r['period_end'])[:10]}  "
        f"capex=${r['capex_abs'] / 1e3:.0f}B  "
        f"intensity={r['intensity']:.1%}  "
        f"{yoy_str}"
    )

# -- META trajectory -------------------------------------------------------
print("\n=== META Capex Trajectory ===")
meta = df[df["ticker"] == "META"].dropna(subset=["capex_abs"])
for _, r in meta.iterrows():
    yoy_str = f"YoY={r['capex_yoy']:+.1%}" if pd.notna(r["capex_yoy"]) else "YoY=N/A"
    print(
        f"  {str(r['period_end'])[:10]}  "
        f"capex=${r['capex_abs'] / 1e3:.0f}B  "
        f"intensity={r['intensity']:.1%}  "
        f"{yoy_str}"
    )

Output:

=== Capex Intensity: Who Is Investing the Most? (Latest Annual) ===
Ticker        Period     Revenue       Capex   Intensity   Capex YoY
-----------------------------------------------------------------
META      2025-12-31  $     201B  $      70B       34.7%     +87.1%
MSFT      2025-06-30  $     282B  $      65B       22.9%     +45.1%
AMZN      2025-12-31  $     717B  $     132B       18.4%     +58.8%
XOM       2025-12-31  $     332B  $      28B        8.5%     +16.7%
CAT       2025-12-31  $      68B  $       3B        4.2%     +41.9%
AAPL      2025-09-27  $     416B  $      13B        3.1%     +34.6%
HD        2026-02-01  $     165B  $       4B        2.2%      +5.6%
UNH       2025-12-31  $     448B  $       4B        0.8%      +3.5%

=== AMZN Capex Trajectory ===
  2022-12-31  capex=$64B  intensity=12.4%  YoY=+4.2%
  2023-12-31  capex=$53B  intensity=9.2%  YoY=-17.2%
  2024-12-31  capex=$83B  intensity=13.0%  YoY=+57.4%
  2025-12-31  capex=$132B  intensity=18.4%  YoY=+58.8%

=== META Capex Trajectory ===
  2022-12-31  capex=$31B  intensity=27.0%  YoY=+68.2%
  2023-12-31  capex=$27B  intensity=20.0%  YoY=-14.0%
  2024-12-31  capex=$37B  intensity=22.6%  YoY=+37.8%
  2025-12-31  capex=$70B  intensity=34.7%  YoY=+87.1%

What this tells us

META is the heaviest investor relative to revenue at 34.7% capex intensity — nearly doubling capex from $37B to $70B in a single year (+87% YoY), driven by AI infrastructure buildout. MSFT and AMZN follow at 22.9% and 18.4% respectively. AMZN’s trajectory is equally striking: capex nearly tripled from $53B to $132B in two years, pushing intensity from 9.2% to 18.4%. META’s trajectory shows a clear inflection: after pulling back from peak metaverse spending (27% intensity in 2022) to $27B in 2023, capex re-accelerated sharply — $37B in 2024, then $70B in 2025 — as the company pivoted its capital strategy toward AI data centers. Both AMZN and META are now in aggressive capex expansion mode, with META’s acceleration even steeper. UNH at 0.8% intensity confirms that health insurance is essentially a capital-free business model.

So what?

Capex intensity is not inherently good or bad for shareholders — the question is whether the investment earns above its cost of capital. META and AMZN together spent $202B on capex in 2025 — an unprecedented combined bet on AI infrastructure. META’s 87% YoY capex surge and AMZN’s 59% growth are wagers that AI compute capacity will generate returns exceeding their roughly 12% cost of equity. If it does, these stocks are undervalued at current levels because the market is discounting future earnings that have not yet materialized. If it does not, the excess capex becomes a drag on free cash flow and the stocks reprice lower. Monitor the ratio of capex intensity to revenue growth: when capex grows faster than revenue for multiple consecutive years, the company is either building future capacity (bullish) or overinvesting (bearish). The distinction depends on whether new capacity translates to incremental revenue.

Built with xfinlink — free financial data API for Python. pip install xfinlink
← All articles