Katz Fractal Dimension
The Katz Fractal Dimension (KFD), from Michael Katz’s 1988 analysis of waveforms, compares the total length of the path with how far it gets from its start: a straight path covers its whole length in distance, while a rough path travels far and stays close to where it began.
The formula for the Katz Fractal Dimension starts from the length L of the path of the N log prices x, the sum of its absolute steps:
\[L = \sum_{i=1}^{N - 1} \left\lvert x_{i+1} - x_{i}\right\rvert\]Its extent d is the largest distance of any log price from the first one, and n the number of steps:
\[d = \max\left(\left\lvert x_{i} - x_{1}\right\rvert\right)\] \[n = N - 1\]The dimension relates the extent to the length, both measured in steps of the average size L / n:
\[\text{FD} = \frac{\log\left(n\right)}{\log\left(n\right) + \log\left(\frac{d}{L}\right)}\]A straight path gives \(1 (d = L)\), and the dimension rises as the path folds back on itself. It is quick to calculate, but it depends on the number of observations as well as on the roughness, so compare it only between series of the same length.
The fractal dimension measures how rough a path is: how much of the plane it fills rather than how far it travels. A straight line has a dimension of 1 and a path so jagged that it fills the plane a dimension of 2; a price path lies in between. For a self-affine path the dimension is 2 - H, with H the Hurst exponent, so a random walk has a dimension of 1.5, a trending path a lower and a mean-reverting path a higher one. The measures come from the analysis of physiological signals (EEG and other waveforms) and work on the log prices of N periods. Price paths are close to random walks, so the dimensions are mostly of use to compare assets with each other or a rolling estimate over time.
Also known as: KFD, Katz dimension.
In the Finance Toolkit this is get_fractal_dimension with method="katz", the same function as Fractal Dimension.
Example · EURUSD, GCUSD, BTCUSD · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_fractal_dimension:
from financetoolkit import Toolkit
toolkit = Toolkit(
["EURUSD", "GCUSD", "BTCUSD"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.risk.get_fractal_dimension(method="katz")
| Parameter | Type | Description | Example |
|---|---|---|---|
method | str | The fractal dimension. Options are: “higuchi” (Higuchi Fractal Dimension), “katz” (Katz Fractal Dimension), “petrosian” (Petrosian Fractal Dimension). Defaults to “higuchi”. | "higuchi" |
period | str | None | The data frequency. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to None, which uses “daily”. | "weekly" |
rolling | int | None | The number of periods of a rolling window, at least kmax + 2 for “higuchi” (12 by default) and 3 for the others. Defaults to None, which calculates one value over the full history of every asset. | 4 |
kmax | int | The largest step k of the Higuchi dimension. Defaults to 10. | 10 |
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 |
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 |
Which returns:
| Item | 0 |
|---|---|
| EURUSD | 1.6932 |
| GCUSD | 1.5132 |
| BTCUSD | 1.7774 |
| Benchmark | 1.5799 |
4 rows
References
- Paper Katz, M.J. (1988). “Fractals and the analysis of waveforms.” Computers in Biology and Medicine, 18(3), 145-156.
- Library Referenced against antropy’s katz_fd (Katz Fractal Dimension)