Skip to content

Repository files navigation

connectedness

PyPI Python License: MIT

Diebold-Yilmaz connectedness and volatility spillover indices in Python.

connectedness turns a panel of asset prices into a fully reproducible spillover analysis: realized covariance and semicovariance matrices, optional PIT normality transform, MHAR-LASSO dynamics, generalized FEVD (Koop-Pesaran-Shin), and the static and rolling-window spillover indices of Diebold and Yilmaz.

Status

Alpha. The API may change before 1.0.0.

Installation

pip install connectedness            # core
pip install connectedness[plots]     # + matplotlib helpers
pip install connectedness[parallel]  # + joblib/tqdm for rolling windows
pip install connectedness[io]        # + pyarrow for parquet I/O

Quickstart

import pandas as pd
from connectedness import SpilloverPipeline

# wide DataFrame: DatetimeIndex (intraday) × markets
prices = pd.read_parquet("prices.parquet")

result = (
    SpilloverPipeline(prices)
    .compute_returns()
    .compute_realized_measures()
    .auto_pit()
    .fit_static()
    .fit_rolling(window=365)
    .run()
)

print(result.tsi)              # total spillover index (%)
print(result.directional_to)   # contributions TO others
print(result.directional_from) # contributions FROM others
print(result.rolling_tsi)      # rolling TSI time series

For the underlying primitives:

from connectedness import (
    simple_returns,
    realized_covariance,
    realized_semicov,
    pit_transform,
    static_spillover,
    rolling_spillover,
)

Methodology

See docs/methodology.md for the formal definitions of realized (semi)covariance, the MHAR-LASSO specification, the generalized variance decomposition, and the Diebold-Yilmaz total / directional / net spillover indices.

Related Packages and References

connectedness focuses on an end-to-end realized-measure pipeline: intraday returns to realized covariance and semicovariance, optional PIT normalization, MHAR-LASSO dynamics, generalized FEVD, and static or rolling Diebold-Yilmaz indices. For a lighter-weight package focused on generalized FEVD and connectedness tables from supplied VAR inputs, see diebold-yilmaz.

Selected references:

  • Diebold, F. X. and Yilmaz, K. (2012). Better to give than to receive: Predictive directional measurement of volatility spillovers. International Journal of Forecasting 28(1), 57-66.
  • Diebold, F. X. and Yilmaz, K. (2014). On the network topology of variance decompositions: Measuring the connectedness of financial firms. Journal of Econometrics 182(1), 119-134.
  • Diebold, F. X. and Yilmaz, K. (2023). On the past, present, and future of the Diebold-Yilmaz approach to dynamic network connectedness. Journal of Econometrics 234(S), 115-120.
  • Koop, G., Pesaran, M. H. and Potter, S. M. (1996). Impulse response analysis in nonlinear multivariate models. Journal of Econometrics 74(1), 119-147.
  • Pesaran, M. H. and Shin, Y. (1998). Generalized impulse response analysis in linear multivariate models. Economics Letters 58, 17-29.
  • Corsi, F. (2009). A simple approximate long-memory model of realized volatility. Journal of Financial Econometrics 7(2), 174-196.
  • Audrino, F. and Knaus, S. D. (2016). Lassoing the HAR model: A model selection perspective on realized volatility dynamics. Econometric Reviews 35(8-10), 1485-1521.
  • Bollerslev, T., Li, J., Patton, A. J. and Quaedvlieg, R. (2020). Realized semicovariances. Econometrica 88(4), 1515-1551.
  • Chanatasig-Niza, E., Ciarreta, A. and Zarraga, A. (2022). A volatility spillover analysis with realized semi(co)variances in Australian electricity markets. Energy Economics 111, 106076.
  • Apergis, N., Barunik, J. and Lau, M. C. K. (2017). Good volatility, bad volatility: What drives the asymmetric connectedness of Australian electricity markets? Energy Economics 66, 108-115.
  • Lyu, C., Do, H. X., Nepal, R. and Jamasb, T. (2024). Volatility spillovers and carbon price in the Nordic wholesale electricity markets. Energy Economics 134, 107559.

Citation

@software{connectedness,
  author  = {Rolotti, Francisco},
  title   = {connectedness: Diebold-Yilmaz spillover indices in Python},
  year    = {2026},
  url     = {https://github.com/franrolotti/connectedness}
}

See also CITATION.cff.

License

MIT. See LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages