Implementation of the paper: "Information-driven modeling of energy markets: an unbalanced Wasserstein barycenter approach"
Authors: Carlo Mari, Emiliano Mari, Cristiano Baldassari (University of Tuscia; Sydus)
This repository implements the 5-step pipeline described in the paper to analyze natural gas and electricity prices:
Inject and compute normalized detrended log-returns
Transform time series into graphs
Represent graphs in 128 dimensions (Diff2Vec)
Compute optimal fusion: λ_gas = 0.65, λ_el = 0.35
Model joint distribution
pip install numpy pandas matplotlib scipy statsmodels POT networkx karateclub ts2vg scikit-learn jupyterjupyter notebookExecute in order:
01_preprocessing.ipynb- Load data, detrending with LOESS, detrended and and normalized log-returns02_visibility_graphs.ipynb- Build graphs03_embeddings.ipynb- Diff2Vec embeddings04_wasserstein.ipynb- Optimal barycenter05_gmm.ipynb- Final model
Data already included andav available freely on mercatoelettrico.org
Files in data/:
logret_gas.dat- Natural gas log-returns (2019-2023)logret_electricity.dat- Electricity log-returns (2019-2023)
1825 observations already preprocessed with LOESS. Ready to use!
The method automatically finds:
- Natural gas weight: 65% (dominant)
- Electricity weight: 35%
This reflects the European market structure!
- Cristiano Baldassari: cristiano.baldassari@unitus.it
MIT License - Feel free to use this code