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 Measure Earnings Quality: Cash Flow vs Net Income in Python

What’s the question?

How much of a company’s reported earnings are backed by actual cash? Net income — the bottom line of the income statement — is an accounting construct subject to management discretion. Revenue recognition timing, depreciation schedules, stock-based compensation treatment, and one-time items all influence the number. Operating cash flow (OCF), by contrast, measures cash actually collected and disbursed during the period. When cash flow significantly exceeds net income, earnings are considered high quality. When net income exceeds cash flow, the gap raises questions about the durability of reported profits.

The approach

We calculate two ratios for each company. The first is the OCF-to-net-income ratio: operating cash flow divided by net income. A ratio above 1.0 means the company generates more cash than it reports in earnings. Above 1.2 is conventionally considered high quality; below 0.8 is a potential concern. The second is the accrual ratio: (net income - operating cash flow) / revenue. A negative accrual ratio indicates the company collects cash faster than it recognizes revenue — characteristic of subscription and prepaid business models. A positive accrual ratio means revenue is being recognized before cash arrives.

We examine eight large-cap technology companies using the most recent annual filing data.

import xfinlink as xfl
import pandas as pd

xfl.set_api_key("your_key")  # free at https://xfinlink.com/signup

tickers = ["AAPL", "MSFT", "NVDA", "AMZN", "META", "GOOGL", "CRM", "ADBE"]
df = xfl.fundamentals(tickers, period_type="annual",
                       fields=["revenue", "net_income", "operating_cash_flow"], period="3y")

latest = df.sort_values("period_end").groupby("ticker").tail(1).copy()
latest["ocf_to_ni"] = latest["operating_cash_flow"] / latest["net_income"]
latest["accrual_ratio"] = (latest["net_income"] - latest["operating_cash_flow"]) / latest["revenue"]
latest = latest.sort_values("ocf_to_ni", ascending=False)

print("=== Earnings Quality: Cash Flow vs Net Income ===")
print("(OCF/NI > 1.0 = cash earnings exceed paper earnings = high quality)")
for _, r in latest.iterrows():
    ni = f"${r['net_income']/1e3:.0f}B"
    ocf = f"${r['operating_cash_flow']/1e3:.0f}B" if pd.notna(r["operating_cash_flow"]) else "N/A"
    ratio = f"{r['ocf_to_ni']:.2f}" if pd.notna(r["ocf_to_ni"]) else "N/A"
    quality = "HIGH" if pd.notna(r["ocf_to_ni"]) and r["ocf_to_ni"] > 1.2 else ""
    print(f"  {r['ticker']:5s}  NI={ni:>7s}  OCF={ocf:>7s}  OCF/NI={ratio:>5s}  {quality}")

Output:

=== Earnings Quality: Cash Flow vs Net Income ===
(OCF/NI > 1.0 = cash earnings exceed paper earnings = high quality)

  CRM    NI=    $6B  OCF=   $13B  OCF/NI= 2.11  accrual= -0.182  HIGH
  META   NI=   $60B  OCF=  $116B  OCF/NI= 1.92  accrual= -0.275  HIGH
  AMZN   NI=   $78B  OCF=  $140B  OCF/NI= 1.80  accrual= -0.086  HIGH
  ADBE   NI=    $7B  OCF=   $10B  OCF/NI= 1.41  accrual= -0.122  HIGH
  MSFT   NI=  $102B  OCF=  $136B  OCF/NI= 1.34  accrual= -0.122  HIGH
  GOOG   NI=  $132B  OCF=  $165B  OCF/NI= 1.25  accrual= -0.081  HIGH
  AAPL   NI=  $112B  OCF=  $111B  OCF/NI= 1.00  accrual=  0.001
  NVDA   NI=  $120B  OCF=  $103B  OCF/NI= 0.86  accrual=  0.080

What this tells us

CRM leads with an OCF-to-NI ratio of 2.11 — Salesforce generates more than twice as much cash as it reports in net income. The primary driver is stock-based compensation (SBC): SBC reduces net income as a real expense but is non-cash, so operating cash flow is unaffected. META at 1.92 exhibits the same pattern, producing $116B in operating cash against $60B in net income.

AAPL sits at exactly 1.00, meaning its cash earnings match its reported earnings almost perfectly. This is unusual among technology companies and reflects Apple’s hardware-heavy revenue model, which has fewer of the timing differences between cash collection and revenue recognition that inflate the ratio for subscription businesses.

NVDA at 0.86 is the only company below 1.0 in this group. The gap between net income ($120B) and operating cash flow ($103B) is not an isolated occurrence — NVDA’s OCF has trailed net income for three consecutive fiscal years (0.94 in FY2024, 0.88 in FY2025, 0.86 in FY2026), and the gap is widening. The likely cause is accounts receivable growth: hyperscaler customers place large GPU orders that are recognized as revenue before payment is received. The underlying credit risk is low given the customers involved, but the pattern means NVDA’s headline earnings overstate how much cash is currently available.

The accrual ratio adds context. META’s deeply negative accrual ratio (-0.275) indicates it collects cash well ahead of revenue recognition, the hallmark of an advertising platform where customers prepay for campaigns.

So what?

Earnings quality analysis is a standard step in fundamental due diligence. A high OCF-to-NI ratio does not automatically make a stock a good investment, and a ratio below 1.0 does not make it a bad one. What it does is reveal the cash content of reported earnings, which affects dividend sustainability, share buyback capacity, and the reliability of valuation multiples based on net income. When building financial models or comparing companies on a PE basis, adjusting for earnings quality ensures that comparisons are made on economically equivalent terms.

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