BLOG

Behind the numbers.

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

Is MSTR a Leveraged Bitcoin Proxy? Rolling Beta Analysis in Python
Is Micron's Memory Cycle Recovering? Inventory and Margin Forecasting in Python
Which Sectors Work When Bonds Rally? Rate-Sensitive Rotation in Python
Do One-Month Price Extremes Reverse? Signal Evaluation in Python
Do Low-Volatility S&P 500 Stocks Reduce Drawdowns? Factor Test in Python
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

How to Screen Healthcare Stocks by Valuation in Python

What’s the question?

Which healthcare sub-segments are trading at a premium and which offer relative value? Healthcare is not a single industry — it spans pharmaceuticals, biotechnology, medical devices, managed care organizations (MCOs), and life science tools, each with different growth profiles, margin structures, and valuation conventions. A PE ratio that signals “cheap” in pharma may be normal in med-tech and expensive in managed care. Screening by multiple valuation metrics across the sector reveals where the market is allocating premium multiples and where it sees risk.

The approach

We retrieve the most recent annual metrics for 10 large-cap healthcare companies and compare them on four dimensions. Price-to-earnings ratio (PE) measures how much investors pay per dollar of earnings. Price-to-sales ratio (P/S) captures how the market values each dollar of revenue, which is particularly useful for comparing companies with different margin profiles. Dividend yield provides a measure of cash return to shareholders. Return on equity (ROE) measures profitability relative to book equity, though it can be distorted by buybacks and acquisition accounting that reduce or invert book equity.

The combination of these four metrics across companies with distinct business models highlights how valuation norms vary by sub-segment within healthcare.

import xfinlink as xfl
import pandas as pd
xfl.set_api_key("your_key")  # free at https://xfinlink.com/signup
tickers = ["UNH", "LLY", "JNJ", "ABBV", "MRK", "PFE", "TMO", "ABT", "AMGN", "BMY"]
metrics = xfl.metrics(tickers, period_type="annual",
    fields=["pe_ratio","ps_ratio","pb_ratio","earnings_yield","dividend_yield","roe"], period="3y")
latest = metrics.sort_values("period_end").groupby("ticker").tail(1).sort_values("pe_ratio")
print("=== Healthcare Sector Valuation Screen ===")
for _, r in latest.iterrows():
    pe = f"{r['pe_ratio']:.1f}" if pd.notna(r["pe_ratio"]) else "N/A"
    ps = f"{r['ps_ratio']:.1f}" if pd.notna(r["ps_ratio"]) else "N/A"
    dy = f"{r['dividend_yield']:.1%}" if pd.notna(r["dividend_yield"]) else "N/A"
    roe_s = f"{r['roe']:.1%}" if pd.notna(r["roe"]) else "N/A"
    print(f"  {r['ticker']:5s}  {r['entity_name'][:22]:22s}  PE={pe:>6s}  P/S={ps:>5s}  yield={dy:>5s}  ROE={roe_s:>7s}")

Output:

=== Healthcare Sector Valuation Screen ===
  MRK    MERCK & CO INC          PE=  15.3  P/S=  4.2  yield= 2.9%  ROE= 34.7%
  BMY    BRISTOL MYERS SQUIBB C  PE=  16.1  P/S=  2.4  yield= 4.5%  ROE= 38.2%
  PFE    PFIZER INC              PE=  19.0  P/S=  2.4  yield= 6.7%  ROE=  9.0%
  JNJ    JOHNSON & JOHNSON       PE=  20.1  P/S=  5.7  yield= 2.3%  ROE= 32.9%
  ABT    ABBOTT LABORATORIES     PE=  22.2  P/S=  3.2  yield= 2.9%  ROE= 12.5%
  AMGN   AMGEN INC               PE=  23.2  P/S=  4.8  yield= 2.9%  ROE= 89.1%
  TMO    THERMO FISHER SCIENTIF  PE=  25.5  P/S=  3.8  yield= 0.4%  ROE= 12.6%
  UNH    UNITEDHEALTH GROUP INC  PE=  29.1  P/S=  0.8  yield= 2.3%  ROE= 12.0%
  LLY    LILLY ELI & CO          PE=  42.1  P/S= 14.0  yield= 0.6%  ROE= 77.8%
  ABBV   ABBVIE INC              PE=  85.9  P/S=  5.9  yield= 3.3%  ROE=-129.2%

Note: ABBV has negative ROE (-129.2%) — likely negative equity from acquisitions

What this tells us

MRK and BMY are the cheapest names in the group at 15–16x PE, with strong ROE (35–38%) and meaningful dividend yields. These are the classic big pharma value profiles — mature franchises generating substantial cash flow with limited growth expectations priced in. PFE offers the highest yield in the group at 6.7%, but at the cost of low ROE (9.0%), reflecting its post-COVID revenue decline and the market’s skepticism about its pipeline replacement cycle.

LLY commands the highest premium at 42x PE and 14x P/S, justified by its GLP-1 obesity drug franchise, which the market views as a multi-decade growth opportunity. The nearly 3x premium over MRK on a PE basis quantifies exactly how much the market is paying for LLY’s growth pipeline versus MRK’s mature portfolio.

AMGN’s ROE of 89.1% is inflated by the same buyback-driven equity reduction seen in companies like AAPL — it reflects capital structure rather than exceptional operating performance.

UNH is notable for its P/S ratio of 0.8x, the lowest in the group by a wide margin. This is characteristic of managed care organizations: health insurers process enormous revenue (UNH’s annual revenue exceeds $448B) but retain thin margins after medical claims are paid. P/S is structurally misleading for MCOs and should not be compared directly to pharmaceutical P/S ratios.

ABBV’s extreme PE of 85.9x and negative ROE of -129.2% are both artifacts of the Allergan acquisition, which created negative book equity through acquisition accounting adjustments.

So what?

Healthcare valuation analysis requires sub-segment context. Comparing a pharma company’s PE to a managed care company’s PE without adjusting for structural differences in growth, margin, and capital intensity produces misleading conclusions. This screen provides the raw data for such comparisons while flagging the accounting artifacts (negative equity from acquisitions, buyback-inflated ROE) that distort standard metrics. Investors evaluating healthcare exposure should select the valuation metric most appropriate for each sub-segment rather than applying a single metric uniformly across the sector.

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