Operating Margin
Calculate the operating margin, a profitability ratio that measures the percentage of revenue that remains after deducting operating expenses.
The operating margin ratio is calculated by subtracting the operating expenses from the total revenue and then dividing the result by the total revenue. It indicates how efficiently a company is managing its operating expenses in relation to its revenue.
The formula is as follows:
\[\text{Operating Margin Ratio} = \text{Operating Income} / \text{Revenue}\]Also known as: EBIT margin, operating income margin.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Operating Margin for you. Just ask in plain English.
Calculate the Operating Margin in Python
The Operating Margin is available in the Ratios module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_operating_margin as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")
operating_margin_ratios = toolkit.ratios.get_operating_margin()
Which returns:
| 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|
| AAPL | 0.2978 | 0.3029 | 0.2982 | 0.3151 | 0.3197 |
| TSLA | 0.1212 | 0.1676 | 0.0919 | 0.0724 | 0.0459 |
Parameters
get_operating_margin accepts the following parameters:
- rounding (int, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the ratios. Defaults to False.
- lag (int | str, optional): The lag to use for the growth calculation. Defaults to 1.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
- trailing (int): Defines whether to select a trailing period. E.g. when selecting 4 with quarterly data, the TTM is calculated.
Related Profitability Ratios
The Ratios module page introduces the module, and the sidebar lists all of its functions.