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 dividing operating income (revenue minus the cost of goods sold and the operating expenses) by 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}\]Operating margin is the usual yardstick for the profitability of the core business, before financing and taxes. Companies with high fixed costs show operating leverage: their margin rises quickly when revenue grows and falls quickly when it shrinks. Restructuring charges and impairments are included, so a single weak year should be checked for one-off items before comparing with peers.
Also known as: EBIT margin, operating income margin.
Operating Margin in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_operating_margin as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["BKNG", "EXPE", "ABNB"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.ratios.get_operating_margin()
Or, after setting up the Finance Toolkit MCP, ask:
What were the operating margins of Booking Holdings, Expedia and Airbnb from 2021 to 2025?
Which returns:
| 2021 | 2022 | 2023 | 2024 | 2025 | |
|---|---|---|---|---|---|
| ABNB | 0.0716 | 0.2145 | 0.1531 | 0.23 | 0.212 |
| BKNG | 0.2278 | 0.2985 | 0.2731 | 0.3183 | 0.3448 |
| EXPE | 0.0216 | 0.093 | 0.0805 | 0.0963 | 0.127 |
Parameters
get_operating_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 |