Analyzing Financial Ratios Using the Finance Toolkit Ratios Module

A hands-on tour of the Finance Toolkit's Ratios Module in Python, using real output for Apple, Amazon, Meta, and Walmart to compare profitability, liquidity, efficiency, and valuation.

Christopher A. Rotunno 8 min read
Cover photo for Analyzing Financial Ratios Using the Finance Toolkit Ratios Module

Photo: Carol M. Highsmith / Public domain / Wikimedia Commons

Financial ratios are how you compare companies that are nothing alike in size. Apple and Walmart both report hundreds of billions in revenue, but they make money in completely different ways, and the raw numbers hide that. Ratios put them on the same scale.

The Finance Toolkit is an open-source Python package that calculates more than 50 of them from a company’s financial statements, using transparent formulas you can check yourself. This post walks through its Ratios Module, using four companies: Apple (AAPL), Amazon (AMZN), Meta (META), and Walmart (WMT).


What the Ratios Module Covers

The module groups its ratios into five categories. Each one answers a different question about a business:

  • Efficiency: how well the company turns its resources into revenue.
  • Liquidity: whether it can pay the bills coming due in the next year.
  • Profitability: how much of each dollar of revenue it keeps.
  • Solvency: whether it can carry its debt over the long run.
  • Valuation: what the market is paying for its earnings.

The full list is in the reference at the end of this post. Here are the patterns that stand out across the four companies:

  • Walmart turns its assets over fastest. It generated more than $2.50 of sales for every dollar of assets in 2023, about double Apple and Amazon.
  • Meta is the most liquid. It led on both the current ratio and the quick ratio every year, with a current ratio above 5 in 2020.
  • Apple’s return on equity is extreme. Above 170% in 2022 and 2023, largely because years of buybacks have shrunk its shareholder equity.
  • Amazon’s 2022 is an outlier everywhere. A net loss that year turned its ROA, ROE, and P/E negative.

Setting Up the Ratios Module

Install the package, then initialize the Toolkit with the tickers you want to compare. It pulls statements from Financial Modeling Prep, so you’ll need a free API key from them.

# Install the financetoolkit package using pip
pip install financetoolkit -U

# Import the Toolkit
from financetoolkit import Toolkit

# Set up API access to FMP
API_KEY = "FINANCIAL_MODELING_PREP_API_KEY"

# Initialize the Toolkit with company tickers
companies = Toolkit(
    ["AAPL", "AMZN", "META", "WMT"], api_key=API_KEY, start_date="2005-01-01"
)

Every ratio is then one method call away. The tables below show the Toolkit’s output for 2020 through 2024. Walmart’s fiscal year ends in January, so its numbers land a year later than the others, which is why only Walmart has a 2024 value.


Profitability

Return on Assets (ROA)

ROA measures how much profit a company earns from everything it owns.

ROA = Net Income / Average Total Assets
roa_ratios = companies.ratios.get_return_on_assets()
print(roa_ratios)
Company20202021202220232024
AAPL17.33%28.06%28.36%27.50%
AMZN7.81%9.00%-0.62%6.14%
META19.92%24.21%13.19%18.83%
WMT5.53%5.50%4.78%6.26%

Apple held steady around 28% from 2021 on. Amazon dipped below zero in 2022, and Walmart’s low ROA is the flip side of a business built on thin margins and huge volume.

Return on Equity (ROE)

ROE measures the profit generated on the money shareholders have invested.

ROE = Net Income / Average Shareholders' Equity
roe_ratios = companies.ratios.get_return_on_equity()
print(roe_ratios)
Company20202021202220232024
AAPL73.69%147.44%175.46%171.95%
AMZN27.44%28.81%-1.91%17.49%
META25.42%31.10%18.52%28.04%
WMT15.98%15.24%13.28%17.77%
Aerial view of Apple Park, Apple's ring-shaped headquarters in Cupertino
Apple Park in Cupertino. Apple's ROE runs above 100% because buybacks have shrunk the equity in the denominator, not because profits doubled. Photo: Daniel L. Lu / CC BY-SA 4.0 / Wikimedia Commons

An ROE above 100% is a reminder to read a ratio alongside its inputs. Apple has spent hundreds of billions buying back its own stock, which shrinks shareholders’ equity. A smaller denominator pushes ROE up even when net income is flat.


Liquidity

Current Ratio

The current ratio compares what a company can turn into cash within a year to what it owes within a year. Above 1 means current assets cover current liabilities.

Current Ratio = Current Assets / Current Liabilities
current_ratio = companies.ratios.get_current_ratio()
print(current_ratio)
Company20202021202220232024
AAPL1.361.070.880.99
AMZN1.051.140.941.05
META5.053.152.202.67
WMT0.790.970.930.820.83

Quick Ratio

The quick ratio, also called the acid-test ratio, is stricter. It drops inventory, which can take months to sell, and asks whether the most liquid assets alone cover short-term debts.

Quick Ratio = (Current Assets - Inventory) / Current Liabilities
quick_ratio = companies.ratios.get_quick_ratio()
print(quick_ratio)
Company20202021202220232024
AAPL1.220.910.710.84
AMZN0.860.910.720.84
META4.892.942.012.55
WMT0.200.260.260.180.20

Meta leads on both measures by a wide margin: it carries a lot of cash and almost no inventory. Walmart is the opposite. Its quick ratio sits near 0.2 because so much of its current assets is merchandise on shelves. For a retailer that sells inventory as fast as Walmart does, that isn’t a warning sign the way it would be for a slower business.


Efficiency

Asset Turnover Ratio

Asset turnover measures how many dollars of sales a company generates for each dollar of assets.

Asset Turnover Ratio = Net Sales / Average Total Assets
asset_turnover = companies.ratios.get_asset_turnover_ratio()
print(asset_turnover)
Company20202021202220232024
AAPL0.831.081.121.09
AMZN1.411.271.161.16
META0.590.730.660.65
WMT2.292.302.502.61
Exterior of a Walmart Supercenter in Perry, Florida
A Walmart Supercenter in Perry, Florida. High-volume retail is built to move inventory fast, which shows up as the highest asset turnover of the four. Photo: Winnebaggo / CC0 / Wikimedia Commons

Walmart’s turnover climbed every year, reaching 2.61 in 2024. Meta sits at the bottom for the opposite reason: its business runs on data centers and intangible assets that are expensive to build but don’t scale sales the way store shelves do.


Solvency

Debt-to-Equity Ratio

Debt-to-equity compares how much of a company is financed by borrowing versus by shareholders. Higher means more leverage, which amplifies both gains and losses.

Debt-to-Equity Ratio = Total Debt / Total Shareholders' Equity
debt_to_equity = companies.ratios.get_debt_to_equity_ratio()
print(debt_to_equity)

Like ROE, this ratio is sensitive to buybacks. When a company retires shares, equity shrinks and debt-to-equity rises, even if it hasn’t borrowed a dollar more.


Valuation

Price-to-Earnings (P/E) Ratio

P/E is what investors pay for each dollar of a company’s earnings. A high P/E usually means the market expects strong growth.

P/E Ratio = Market Price per Share / Earnings per Share
pe_ratio = companies.ratios.get_price_earnings_ratio()
print(pe_ratio)
Company20202021202220232024
AAPL39.6631.1521.0631.27
AMZN77.8751.47-314.3752.40
META26.9924.3513.9723.73
WMT26.2629.2828.3736.5442.71
An LED stock ticker showing prices for Intel and Facebook
A stock ticker, with Facebook (now Meta) in the middle. Meta's P/E fell to about 14 in 2022, the cheapest of the four, before the market re-rated it. Photo: Francisco Gonzalez / CC BY 2.0 / Wikimedia Commons

Amazon’s 2022 value of -314 isn’t a typo. When earnings are negative, P/E turns negative and stops being meaningful. That’s a good example of why a ratio needs context: on its own, it would look like a data error.


Ratio Reference

The Ratios Module includes far more than the ratios above. Here is the full set by category, with the formula behind each one.

Efficiency Ratios

RatioFormulaWhat it shows
Asset TurnoverNet Sales / Average Total AssetsSales generated per dollar of assets
Inventory TurnoverCost of Goods Sold / Average InventoryHow often inventory is sold and replaced
Days of Inventory Outstanding365 / Inventory TurnoverAverage days to sell inventory
Days of Sales Outstanding(Accounts Receivable / Total Credit Sales) × 365Average collection period
Operating CycleDIO + DSODays from buying inventory to collecting cash
Accounts Payable TurnoverTotal Purchases / Average Accounts PayableHow often suppliers are paid
Days of Accounts Payable Outstanding365 / Accounts Payable TurnoverAverage days to pay suppliers
Cash Conversion CycleDIO + DSO - DPODays to turn inputs into cash
Cash Conversion Efficiency(Operating Cash Flow / Net Sales) × 100How much income becomes cash
Receivables TurnoverNet Credit Sales / Average Accounts ReceivableHow well credit is collected
SG&A to Revenue(SG&A Expenses / Revenue) × 100Overhead as a share of revenue
Fixed Asset TurnoverNet Sales / Average Fixed AssetsSales per dollar of fixed assets
Operating Ratio(Operating Expenses / Net Sales) × 100Operating efficiency

Liquidity Ratios

RatioFormulaWhat it shows
Current RatioCurrent Assets / Current LiabilitiesAbility to pay short-term obligations
Quick Ratio(Current Assets - Inventory) / Current LiabilitiesAbility to pay without selling inventory
Cash RatioCash and Equivalents / Current LiabilitiesThe most conservative liquidity test
Working CapitalCurrent Assets - Current LiabilitiesFunds available for operations
Operating Cash Flow RatioOperating Cash Flow / Current LiabilitiesShort-term coverage from operations
Operating Cash Flow Sales RatioOperating Cash Flow / SalesCash generated per dollar of sales
Short-Term Coverage RatioOperating Cash Flow / Short-Term DebtAbility to service short-term debt

Profitability Ratios

RatioFormulaWhat it shows
Gross Margin((Revenue - COGS) / Revenue) × 100Profit after direct production costs
Operating Margin(Operating Income / Revenue) × 100Profit from core operations
Net Profit Margin(Net Income / Revenue) × 100Profit after all expenses
Interest Burden RatioEarnings Before Tax / EBITHow much interest eats into profit
Income Before Tax Profit Margin(Earnings Before Tax / Revenue) × 100Profitability before taxes
Effective Tax Rate(Income Tax Expense / Earnings Before Tax) × 100Actual tax burden
Return on AssetsNet Income / Average Total AssetsProfit from everything the company owns
Return on EquityNet Income / Average Shareholders’ EquityProfit on shareholder investment
Return on Invested CapitalNOPAT / Invested CapitalReturn on all capital invested
Income Quality RatioOperating Cash Flow / Net IncomeHow much reported profit is backed by cash
Return on Tangible AssetsNet Income / (Total Assets - Intangible Assets)Return on physical assets
Return on Capital EmployedEBIT / Capital EmployedProfit relative to capital employed
Net Income per EBTNet Income / Earnings Before TaxShare of pre-tax income kept
Free Cash Flow to Operating Cash FlowFree Cash Flow / Operating Cash FlowCash left after capital spending
Tax Burden RatioNet Income / EBTTax impact on profit
EBT to EBITEBT / EBITImpact of interest on earnings
EBIT to Revenue(EBIT / Revenue) × 100Operating profit margin

Solvency Ratios

RatioFormulaWhat it shows
Debt to AssetsTotal Debt / Total AssetsShare of assets financed by debt
Debt to EquityTotal Debt / Total Shareholders’ EquityBalance of debt and equity financing
Interest CoverageEBIT / Interest ExpenseAbility to pay interest
Equity MultiplierTotal Assets / Total Shareholders’ EquityLeverage on shareholder equity
Debt Service CoverageOperating Income / Total Debt ServiceAbility to service all debt
Free Cash Flow Yield(Free Cash Flow / Market Capitalization) × 100Cash flow relative to market value
Net Debt to EBITDANet Debt / EBITDADebt relative to earnings
Cash Flow CoverageOperating Cash Flow / Total DebtCash flow relative to debt
CAPEX CoverageOperating Cash Flow / Capital ExpendituresAbility to fund capital spending
CAPEX Dividend CoverageOperating Cash Flow / (CAPEX + Dividends)Ability to fund capital spending and dividends

Valuation Ratios

RatioFormulaWhat it shows
Earnings per Share(Net Income - Preferred Dividends) / Weighted Average SharesProfit per share
Revenue per ShareRevenue / Average Shares OutstandingRevenue per share
Price to EarningsMarket Price per Share / EPSPrice paid per dollar of earnings

Takeaways

  • One method call per ratio. Once the Toolkit is initialized, comparing companies on any of 50+ ratios takes a single line.
  • Ratios only make sense against peers and against time. Walmart’s quick ratio of 0.2 looks alarming alone and ordinary for a big-box retailer.
  • Read the inputs, not just the output. Apple’s ROE above 170% and Amazon’s P/E of -314 are both correct, and both would mislead anyone who didn’t check what drove them.

From here, try the Toolkit on companies you follow, and pair the numbers with what ratios can’t capture: competitive position, market trends, and where growth will come from. The Finance Toolkit documentation covers every ratio in detail.

Related Posts

Christopher A. Rotunno Analytics Engineer · Super Intelligence

Analytics engineer turning fragmented tidbits into confidence: messy data structured, patterns caught early, answers made plain with AI.

Copyright 2026 Christopher A. Rotunno. All Rights Reserved

Built with & Claude Code