True Range (TR)
Calculate the True Range (TR) for a given price series.
The True Range (TR) is a measure of market volatility that considers the differences between the high and low prices and the previous closing price. It provides insights into the price movement of an asset.
The formula is as follows:
\[\text{TR} = \max(\text{high} - \text{low},\; \operatorname{abs}(\text{high} - \text{previous\_close}),\; \operatorname{abs}(\text{low} - \text{previous\_close}))\]Also known as: TR, true range.
True Range (TR) in Python
get_true_range is part of the Technicals module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_true_range as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(tickers=["AAPL", "MSFT"])
toolkit.technicals.get_true_range()
Which returns:
| Date | AAPL | MSFT | Benchmark |
|---|---|---|---|
| 2026-06-18 | 4.95 | 8.09 | 7.27 |
| 2026-06-22 | 5.66 | 14.56 | 7.05 |
| 2026-06-23 | 7.46 | 9.88 | 12.09 |
| 2026-06-24 | 6.76 | 14.1 | 9.11 |
| 2026-06-25 | 19.33 | 16.26 | 9.77 |
| 2026-06-26 | 11.74 | 23.78 | 19.95 |
| 2026-06-29 | 8.52 | 20.6 | 12.57 |
| 2026-06-30 | 9.24 | 6.7 | 7.13 |
| 2026-07-01 | 7.39 | 15.81 | 7.06 |
| 2026-07-02 | 15.74 | 8.5 | 11.28 |
Parameters
get_true_range accepts the following parameters:
- period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
- close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- growth (bool, optional): Whether to calculate the growth of the True Range. Defaults to False.
- lag (int | list[int], optional): The lag to use for the growth calculation.
- 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. Defaults to 1.