# A Persistent Entropy Automaton for the Dow Jones Stock Market

Marco Piangerelli, Luca Tesei, Emanuela Merelli

► To cite this version:

Marco Piangerelli, Luca Tesei, Emanuela Merelli. A Persistent Entropy Automaton for the Dow Jones Stock Market. 8th International Conference on Fundamentals of Software Engineering (FSEN), May 2019, Tehran, Iran. pp.37-42, 10.1007/978-3-030-31517-7_3. hal-03769121

HAL Id: hal-03769121

https://inria.hal.science/hal-03769121v1

Submitted on 5 Sep 2022

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
# A Persistent Entropy Automaton for the Dow Jones Stock Market

Marco Piangerelli[0000-0002-8545-3740], Luca Tesei[0000-0002-7536-8796], and Emanuela Merelli[0000-0002-1321-4134]

School of Science and Technology, University of Camerino, Via Madonna delle Carceri 9, 62032 Camerino (MC), Italy
{marco.piangerelli,luca.tesei,emanuela.merelli}@unicam.it

**Abstract.** Complex systems are ubiquitous. Their components, agents, live in an environment perceiving its changes and reacting with appropriate actions; they also interact with each other causing changes in the environment itself. Modelling an environment that shows this feedback loop with agents is still a big issue because the model must take into account the emerging behaviour of the whole system. In this paper, following the S[B] paradigm, we exploit topological data analysis and the information power of persistent entropy for deriving a persistent entropy automaton to model a global emerging behaviour of the Dow Jones stock market index. We devise early warning states of the automaton that signal a possible evolution of the system towards a financial crisis.

**Keywords:** Complex Systems · S[B] Paradigm · Emerging Behavior · Topological Data Analysis · Stock Market.

## 1 Introduction

A complex system is any system consisting of a great number of heterogeneous entities interacting with each other within an environment to shape an emerging behavior. Such emerging behaviour depends on a non-trivial space of correlations that derive from the interplay of agents *entangled in loops of non-linear interactions*. In the metaphor of the flock of starlings, any environmental change perceived by the starlings during their flight is visible in the formation of the flock shape due to their reaction. This implies that there is an underlying feedback loop between the agents and the global system.

Mastering the complexity of these systems has always been a challenge in almost every branch of science. In computer science, process-, actor- and agent-based models and languages have been developed for describing the behaviour of complex software systems [6, 1, 2, 11]. All these approaches require an *a priori* knowledge of the basic rules governing the dynamic of the system in order to define the behaviour of the components and of the environment. Unfortunately, for natural or social phenomena, it is quite impossible to have enough knowledge about the real interaction rules. However, global information about the system
is hidden inside phenomenological data produced by the individual components.
Thus, we need suitable methods to extract a specific model of interest.

Topological Data Analysis (TDA) is a relatively new field of study in which
topology driven methods are used to analyse big collections of data [5, 8, 4]. The
$S[B]$ paradigm is a general framework of modelling in which a complex system
is described as a pair of entangled systems: $S$, the global environment, and $B$,
a set of interactive agents [14, 13]. Persistent Entropy (PE) is a Shannon-like
entropic measure able to describe the global dynamics of a complex system [16].
PE has been used for studying complex phenomena in different fields [16, 15, 17].
As shown in [16], by analysing the trajectories of PE and its derived quantities,
an automaton, called Persistent Entropy Automaton (PEA), which models the
global dynamics of the system under study, can be manually devised.

The global financial system is one of the most important, human-made, com-
plex systems. This system is composed of multiple interacting autonomous com-
ponents or “selfish” agents, who - very often - act for their own benefit, and
of complex interactions among those components. Each component behaves ac-
cording to his/its own strategies, under the influence of the environment and
interacting with other heterogeneous components. Classical tools for analysing
and modelling such systems operate under a range of rather unrealistic assump-
tions. For example, interactions are normally abstracted with equations: this
implies that the system reaches the equilibrium through non-linear optimisation
methods rather than emerging from the agents interactions [12].

In this paper we use TDA to construct a data space from the components of
the Dow Jones stock market index. The considered data set is the time series of
the daily log-returns of Dow Jones' components from 1987 to 2017. From the data
space, we calculate the PE and we devise a PEA whose locations model global
states of the stock market. We show that early warnings about the emergence
of the already occurred financial crisis can be identified by the PEA.

## 2 Methods

TDA employs concepts and principles of the field of computational topology to
reveal higher dimensional patterns hidden in big data sets [5, 8]. Computational
topology studies invariants of shapes among which the so called Betti numbers,
or barcodes, that characterise the existence of *n*-dimensional holes in the topo-
logical data space. TDA builds a discrete topological space, a simplicial complex,
following a filtration procedure. In this work we use the Vietoris-Rips complex
filtration that works on point clouds [8]. At each step of the filtration the persis-
tent homology is computed yielding a collection of barcodes that indicate the life
span of the topological invariants. PE is then computed from the barcodes [15].

The 24 time series of the considered Dow Jones components were mapped
into a point cloud using a sliding window of 50 days and scrolling one point at a
time with superposition of 49 points. Each window then produced 50 points in
$\mathbb{R}^{24}$. This technique has been demonstrate suitable for studying the time-varying
properties of systems similar to the one we are studying [15, 9].
The mechanism driving critical transitions in complex systems is called tip-ping point, which is an abrupt qualitative change in the behaviour of a dynamical system when one or more control parameters change. In approaching a tipping point, a complex system shows a phenomenon called Critical Slowing Down (CSD), which can be considered an Early Warnings Signal (EWS) for the critical transition [18, 3]. Since PE describes a system globally, it contains a summary of the knowledge about the system. Moreover, it can be considered a time series itself and can be calculated for all the dimensions. Thus, we study the total PE time series (PE<sub>tot</sub>) - calculated as the sum of PEs for all the dimensions - with an analytical approach. The goal is to identify EWSs about a crisis by detecting the occurrence of tipping points. The obtained PE<sub>tot</sub> is shown in Figure 1.

To delimit the CSD areas we used an adaptation of the $W_2$ index, i.e. a combination of statistical indices (coefficient of variation, 1-lag autocorrelation, and kurtosis), described in [7]. $W_2$ is computed from PE<sub>tot</sub> with the R package "earlywarnings" using another sliding window of size 450. Thus, $W_2$ is another time series and it is plotted along with its running average and $2\sigma$ confidence bands in Figure 1. Potential areas of CSD are identified by finding points where $W_2 > \bar{W}_2 + 2\sigma$ [7]. These areas are shown in Figure 1 with black bands and represent the EWSs in our system.

Identified CSD areas can be used to define PEA states. A PEA monitors the PE and derived functions w. r. t. equilibrium conditions that define its states [16]. It remains in a state $s$ as long as the associated equilibrium condition $ec(s)$ is satisfied. When it is violated, the PEA exits $s$ and starts a non-instantaneous transition, which can be seen as an adaptation phase. This adaptation may end into an adjacent PEA state $s'$ as soon as $ec(s')$ is satisfied or may not terminate. This definition is based on the fact that PEA states are devised from the observed trajectories of PE and derived functions. Indeed, it may happen that the monitored functions exhibit evolutions that were not identified as equilibrium conditions. This is expected for natural complex systems for which "complete" models can not be established. The main difference between a PEA and a hybrid automaton, which is a top-down defined model not considering unknown evolutions [10], is essentially in this different perspective.

## 3 Persistent Entropy Automaton of Dow Jones

In the $S[B]$ paradigm the structural level $S$ is a model of the global dynamics of the system and the behavioural level $B$ is a model of the local interactions among the entities of the system [13]. In this study, the behavioural level $B$ is represented by real human agents that produced the data that we use. The structural level $S$ is defined as a PEA in the following.

We consider two financial crises, dot-Com and Lehman Brothers Crash, both represented with coloured bands in Figure 1. We devise the PEA by monitoring the functions PE<sub>tot</sub>(t), $W_2(t)$, their running average $\bar{PE}_{tot}(t)$, $\bar{W}_2(t)$ together with their derivatives indicated with a dot over the symbol. Each discrete instant $t$ corresponds to one day observation. The derived PEA is called PEAW<sub>2</sub>, is
<figure><img src="image_3.png" /><figcaption>**Fig. 1.** Plot of PE<sub>tot</sub> and its running average (above). Plot of W<sub>2</sub> and its running average with confidence bands (below). The grey and black vertical bands correspond to the relative states of the automaton in Figure 2. The thin coloured vertical bands correspond to financial crises.</figcaption></figure>

depicted in Figure 2 and its states are described in the following. A *stable* state is characterised by the equilibrium condition $|W_2 - \bar{W}_2| < 2\sigma$, that is $W_2$ does not exceed the confidence bands. The state called Stable is the initial one and holds this condition. As soon as the functions violate the stable condition, $PE_{W_2}$ exits state Stable and starts an adaptation. The only state in which the adaptation can end is the one called Grey, a state indicating that there was in the past at least one violation of the stable state condition. The equilibrium condition of Grey is $\bar{W}_2 \approx 0 \wedge \overline{PE}_{tot} < 0 \wedge W_2 < \bar{W}_2 - 2\sigma$, which means that the running average of $W_2$ has minimal oscillations, the running average of the total PE is decreasing and $W_2$ exits the confidence band $-2\sigma$. Visually, the periods in which $PE_{W_2}$ stays in this state are represented by the grey bands in Figure 1. State White corresponds visually to the period after a grey band, it has the stable equilibrium condition and records the fact that the system entered at least once state Grey. After White, another grey band can occur (in this case the PEA goes back to Grey) or a black band occurs. A black band corresponds to state Black. This is the early warning state because from Black the system can only evolve to state Tipping that represents a tipping point. In Tipping a crisis, represented by the dashed transition towards state Stable, can occur or the system can return to state Grey. The dashed transition can be interpreted as the occurrence of a phase transition of the system.
$PEA_{W_2}$ is then able to give a warning, in state Black, that a crisis may occur, without giving a prediction. However, if the current state is different from Black, the model says that a crisis cannot occur immediately: there must be at least one (or more) adaptations before the tipping point state is reached.

<figure><img src="image_4.png" /><figcaption>Fig. 2. $PEA_{W_2}$, describing the transitions among the global states of the system.</figcaption></figure>

# 4 Conclusions

In this work we have modelled the global dynamics of a complex system by manually devising a PEA. TDA has been used for analysing the phenomenological data of the system and PE has been calculated from a topological space derived from a data set. The application domain is the Dow Jones stock market. The derived automaton models the global behaviour of the market and is able to recognise a tipping point state in which a financial crisis may occur and previous states in which there is some degree of warning but there is not an immediate alarm because some other adaptations are required to reach the tipping point state. The transition that goes from the tipping point state to the stable state can be interpreted as a phase transition of the system.

Despite the encouraging result we are aware that the proposed analysis presents some limitations: one is about the peculiarity of the data set that does
not allow one to set up a statistical validation of the results because of the unicity of the phenomenon under study, for which other instances do not exist. Another regards the computation of the indices for deriving the W₂, for which it is necessary to try different lengths of the sliding windows.

## References

1. Arbab, F.: Reo: a channel-based coordination model for component composition. Mathematical Structures in Computer Science 14(3), 329-366 (2004)

2. Baier, C., Sirjani, M., Arbab, F., Rutten, J.: Modeling component connectors in Reo by constraint automata. Science of Comp. Programming 61(2), 75-113 (2006)

3. Battiston, S., Farmer, J.D., Flache, A., Garlaschelli, D., Haldane, A.G., Heesterbeek, H., Hommes, C., Jaeger, C., May, R., Scheffer, M.: Complexity theory and financial regulation. Science 351(6275), 818-819 (2016)

4. Binchi, J., Merelli, E., Rucco, M., Petri, G., Vaccarino, F.: jHoles: A Tool for Understanding Biological Complex Networks via Clique Weight Rank Persistent Homology. Electronic Notes in Theoretical Computer Science 306, 5-18 (2014)

5. Carlsson, G.: Topology and data. Bulletin of the AMS 46(2), 255-308 (2009)

6. De Nicola, R., Ferrari, G.L., Pugliese, R.: KLAIM: A Kernel Language for Agents Interaction and Mobility. IEEE Trans. on Software Engineering 24, 315-330 (1998)

7. Drake, J.M., Griffen, B.D.: Early warning signals of extinction in deteriorating environments. Nature 467(7314), 456 EP - (2010)

8. Edelsbrunner, H., Harer, J.: Computational topology: an introduction. AMS (2010)

9. Gidea, M., Katz, Y.: Topological data analysis of financial time series: Landscapes of crashes. PHYSICA A 491, 820-834 (2018)

10. Henzinger, T.: The theory of hybrid automata. In: Inan, M., Kurshan, R. (eds.) Verification of Digital and Hybrid Systems, NATO ASI Series (Series F: Computer and Systems Sciences), vol. 170, pp. 265-292. Springer, Berlin, Heidelberg (2000)

11. Jennings, N.R.: An agent-based approach for building complex software systems. Communications of the ACM 44(4), 35-41 (2001)

12. Landini, S., Gallegati, M., Rosser, J.B.: Consistency and incompleteness in general equilibrium theory. Journal of Evolutionary Economics (2018). https://doi.org/10.1007/s00191-018-0580-6

13. Merelli, E., Paoletti, N., Tesei, L.: Adaptability checking in complex systems. Science of Computer Programming 115-116, 23-46 (2016)

14. Merelli, E., Pettini, M., Rasetti, M.: Topology driven modeling: the IS metaphor. Natural Computing 14(3), 421-430 (2015)

15. Merelli, E., Piangerelli, M., Rucco, M., Toller, D.: A topological approach for multi-variate time series characterization: the epileptic brain. EAI Endorsed Transactions on Self-Adaptive Systems (2016). https://doi.org/10.4108/eai.3-12-2015.2262525

16. Merelli, E., Rucco, M., Sloot, P., Tesei, L.: Topological Characterization of Complex Systems: Using Persistent Entropy. Entropy 17(10), 6872-6892 (2015)

17. Piangerelli, M., Rucco, M., Tesei, L., Merelli, E.: Topological classifier for detecting the emergence of epileptic seizures. BMC Research Notes 11, 392 (2018)

18. Scheffer, M.: Complex systems: foreseeing tipping points. Nature 467, 411 EP (2010)