Published August 19, 2024 | Version v1
Software Open

Code and Data for "Causal Hierarchy in the Financial Market Network - Uncovered by the Helmholtz-Hodge-Kodaira Decomposition"

Description

This is the Python codebase used for our upcoming preprint "Causal Hierarchy in the Financial Market Network -- Uncovered by the Helmholtz-Hodge-Kodaira Decomposition". As we use the database of Ken French for our research, the data's version at the time of performing our research is also included in this repository. The codebase can be used for analysis of the Granger causality flux between different time series like the ones in the Ken French database. It calculates the hierarchy of the causality flux according to the Helholtz-Hodge-Kodaira decomposition by calculating the underlying potential values of each node. An example of how to use it is:

from hhkd_codebase import *
Start, End = "20191101","20201031"
DF_raw =    getperiod(data = getdata(49),
                         start = Start,
                         end = End )
DF = Denoise(DF, 0.9)  # retains 90% of the variance by dropping the less important PCAs
g = GrangerNetwork(DF_raw) 
gm = g.GrangerNetwork_Lag1() # estimate the Granger Matrix 
hhkd = HHKD_Bidirectional(gm.to_numpy(), constraint = "last") # initialise the HHKD
potentials = hhkd.HHKD_Potential(output=True) # cacluclate potentials

Alternatively, one can use a shortened version if one does not care about the estimated matrix, but only wishes to see the potentials:

from hhkd_codebase import *
Start, End = "20191101","20201031"
DF_raw =    getperiod(data = getdata(49),
                         start = Start,
                         end = End )
DF = Denoise(DF_raw, 0.9)  # retains 90% of the variance by dropping the less important PCAs
Ranking = Data2Cause(DF,Start,End)
print(Ranking.Potential)

 

Files

DATA_49_Industry_Portfolios_Daily.txt

Files (18.2 MB)

Name Size Download all
md5:ba3324818626cbc3c0dfce2ef5d081fa
18.2 MB Preview Download
md5:ce4dd7c328fe9673293e9cf7992b0df3
15.3 kB Download

Additional details

Funding

Japan Society for the Promotion of Science

Dates

Other
2024-08-19