Net Profit Margin
Calculate the net profit margin, a profitability ratio that measures the percentage of profit a company earns per dollar of revenue.
The net profit margin ratio is calculated by dividing the net income by the total revenue. It indicates the portion of each dollar of revenue that represents profit after all expenses have been deducted. A higher net profit margin is generally considered favorable.
The formula is as follows:
\[\text{Net Profit Margin Ratio} = \text{Net Income} / \text{Revenue}\]Also known as: net margin, bottom line margin, net income margin.
Net Profit Margin in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_net_profit_margin as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["LLY", "NVO", "AZN"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.ratios.get_net_profit_margin()
Or, after setting up the Finance Toolkit MCP, ask:
How much of each dollar of revenue did Eli Lilly, Novo Nordisk and AstraZeneca keep as net income from 2021 to 2025?
Which returns:
| 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|
| AZN | 0.003 | 0.0741 | 0.13 | 0.1301 | 0.1746 |
| LLY | 0.1971 | 0.2188 | 0.1536 | 0.2351 | 0.3167 |
| NVO | 0.3392 | 0.3138 | 0.3603 | 0.3478 | 0.3314 |
Parameters
get_net_profit_margin accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the ratios. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
compound | bool | Whether the growth is the compound annual growth rate over the lag (e.g. lag=5 for the five-year CAGR) instead of the total change. Defaults to False. | False |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |
trailing | int | The number of periods to sum flows (income and cash flow statement items) over, with balance sheet items averaged over the same number of period ends. E.g. 4 with quarterly data gives the trailing twelve months (TTM) and 3 with annual data a three-year cumulative figure. Defaults to None, which uses single-period flows (per quarter and not annualized with quarterly data). | 4 |