Change Points
Find the change points of every asset’s series: the dates at which its mean, its volatility or both change.
The change points follow the PELT (Pruned Exact Linear Time) method of Killick, Fearnhead and Eckley (2012). It finds the exact segmentation that minimizes the Gaussian cost of every segment plus a penalty per change, with no upper limit on the number of changes, and prunes the candidate dates that can no longer be the last change, so it runs in about linear time.
Where get_structural_breaks (Bai and Perron) looks for shifts in the mean with a common variance and at most a few breaks, PELT with the default mean and variance cost also splits the series where the volatility changes, which for returns separates calm and turbulent periods; the variance cost keeps the mean fixed and only lets the volatility change, the mean cost only the mean. Every segment is dated after the fact with the whole series, as a description of the past rather than a signal on the day.
The formula is as follows, with \(y_{t}\) the column series (Return by default), n observations and a segment s of \(n_{s}\) observations:
- The segmentation minimizes \(\sum C (s)\) + β·(number of changes), every segment at least
minimum_segmentobservations (5 by default)
- Per segment: its Start, End, Observations, Mean and Standard Deviation (ddof=1)
Also known as: PELT, change point detection, changepoints, variance change points, volatility regimes, segmentation, multiple structural breaks.
Example · QQQ, TLT · 2016 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_change_points:
from financetoolkit import Toolkit
toolkit = Toolkit(
["QQQ", "TLT"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2016-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_change_points(period="monthly", cost="variance")
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
When did the volatility of the monthly returns of the Invesco QQQ and iShares 20+ Year Treasury Bond (TLT) ETFs shift from 2016 to 2025?
Which returns:
| Item | Start | End | Observations | Mean | Standard Deviation | Penalty |
|---|---|---|---|---|---|---|
| ('QQQ', 1) | 2016-02 | 2018-09 | 32 | 0.0196 | 0.0319 | 9.5582 |
| ('QQQ', 2) | 2018-10 | 2025-12 | 87 | 0.0161 | 0.0587 | 9.5582 |
| ('TLT', 1) | 2016-02 | 2025-12 | 119 | -0.0002 | 0.0393 | 9.5582 |
3 rows
Using Your Own Data
get_change_points runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_change_points()
Parameters
get_change_points accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
column | str | The historical data column to analyze. Defaults to “Return”; use “Adj Close” (or “Level” with standalone data) for the series itself, such as an inflation rate. | "Return" |
cost | str | What may change between segments. Options are: “mean_variance” (both), “variance” (the volatility around the mean of the series), “mean” (the mean). Defaults to “mean_variance”. | "mean_variance" |
penalty | float | None | The penalty \(\beta\) per change; a larger one finds fewer changes. Defaults to None, the BIC \((p + 1) \cdot \ln (n)\). | None, the BIC $$(p + 1) \cdot \ln (n)$$ |
minimum_segment | int | The fewest observations of a segment. A segment of two nearly equal values has a variance close to zero, which the Gaussian cost rewards without bound, so the variance costs need a few more. Defaults to 5. | 5 |
include_benchmark | bool | Whether to include “Benchmark” among the assets. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper Killick, R., Fearnhead, P. and Eckley, I.A. (2012). “Optimal Detection of Changepoints With a Linear Computational Cost.” Journal of the American Statistical Association, 107(500), 1590-1598.
- Paper Jackson, B. et al. (2005). “An Algorithm for Optimal Partitioning of Data on an Interval.” IEEE Signal Processing Letters, 12(2), 105-108.
- Library Referenced against ruptures’ Pelt
- Library Referenced against changepoint (R)’s penalty_decision
- Library Shares similar logic as RiskLabAI’s pelt_change_points