{'fraction_non_alphanumeric': 0.03760638648809131, 'fraction_numerical': 0.016384068967033934, 'mean_word_length': 4.77348908075165, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Network geometry and market instability

The complexity of financial markets arise from the strategic interactions among agents trading stocks, which manifest in the form of vibrant correlation patterns among stock prices. Over the past few decades, complex financial markets have often been represented as networks whose interacting pairs of nodes are stocks, connected by edges that signify the correlation strengths. However, we often have interactions that occur in groups of three or more nodes, and these cannot be described simply by pairwise interactions but we also need to take the relations between these interactions into account. Only recently, researchers have started devoting attention to the higher-order architecture of complex financial systems, that can significantly enhance our ability to estimate systemic risk as well as measure the robustness of financial systems in terms of market efficiency. Geometry-inspired network measures, such as the Ollivier–Ricci curvature and Forman–Ricci curvature, can be used to capture the network fragility and continuously monitor financial dynamics. Here, we explore the utility of such discrete Ricci curvatures in characterizing the structure of financial systems, and further, evaluate them as generic indicators of the market instability. For this purpose, we examine the daily returns from a set of stocks comprising the USA S&P-500 and the Japanese Nikkei-225 over a 32-year period, and monitor the changes in the edge-centric network curvatures. We find that the different geometric measures capture well the system-level features of the market and hence we can distinguish between the normal or ‘business-as-usual’ periods and all the major market crashes. This can be very useful in strategic designing of financial systems and regulating the markets in order to tackle financial instabilities.


Introduction
For centuries, science had thrived on the method of reductionism-considering the units of a system in isolation, and then trying to understand and infer about the whole system. However, the simple method of reductionism has severe limitations [1], and fails to a large extent when it comes to the understanding and modelling the collective behaviour of the components of a 'complex system'. More and more systems are now being identified as complex systems, and hence scientists are now embracing the idea of complexity as one of the governing principles of the world we live in. Any deep understanding of a complex system has to be based on a system-level description, since a key ingredient of any complex system is the rich interplay of nonlinear interactions between the system components. The financial market is truly a spectacular example of such a complex system, where the agents interact strategically to determine the best prices of the assets. So new tools and interdisciplinary approaches are needed [2,3], and already there has been an influx of ideas from econophysics and complexity theory [4][5][6][7][8] to explain and understand economic and financial markets.
The traditional economic theories, based on axiomatic approaches and consequently less predictive power, could not foresee an event like the sub-prime crisis of 2007-2008 or the long-lasting effects of such a critical financial crash on the global economy. Researchers advocated that new concepts and techniques [9] like tipping points, feedback, contagion, network analysis along with the use of complexity models [10] could help in better understanding of highly interconnected economic and financial systems, as well as monitoring them. There have been numerous papers in the past that have addressed similar concerns and tried to adopt new approaches for studying financial systems. Since the correlations among stocks change with time, the underlying market dynamics generate very interesting correlation-based networks evolving over time. The study of empirical cross-correlations among stock prices goes back to more than two decades [11][12][13][14][15][16]. One of commonly adopted approaches for the modelling and analysis of complex financial systems has been correlation-based networks, and it has emerged as an important tool [11,12,[17][18][19][20][21][22].
A network or graph consists of nodes connected by edges. In real-world networks, nodes represent the components or entities, while edges represent the interactions or relationships between nodes. In the context of financial markets, the nodes represent the stocks and the edges characterize the correlation strengths (or their transformations into distance measures). The network formed by connecting stocks of highly correlated prices, price returns and trading volumes are all scale-free, with a relatively small number of stocks influencing the majority of the stocks in the market [23]. Hierarchical clustering has been used to cluster stocks into sectors and sub-sectors, and their network analysis provides additional information on the interrelationships among the stocks [24,25]. The cross-correlations among stock returns allow one to construct other correlation-based networks such as minimum spanning tree (MST) [11,12,18,26] or a threshold network [27]. Another approach to monitor the correlation-based networks over time, referred to as structural entropy, quantifies the structural changes of the network as a single parameter. It takes into account the number of communities as well as the size of the communities [28] to determine the structural entropy, which is then used to continuously monitor the market. The thermodynamical entropy [29] can also be used to describe the dynamics of stock market networks as it acts like an indicator for the financial system. Very recently, based on the distribution properties of the eigenvector centralities of correlation matrices, Chakraborti & Pharasi [30] have proposed a computationally cheap yet uniquely defined and nonarbitrary eigen-entropy measure, to show that the financial market undergoes 'phase separation' and there exists a new type of scaling behaviour (data collapse) in financial markets. Further, a recent review by Kukreti et al. [31] critically examines correlation-based networks and entropy approaches in evolving financial systems. To understand the topology of the correlation-based networks as well as to define the complexity, a volume-based dimension has also been proposed by Nie et al. [32]. There have also been some novel studies where the financial market has been considered as a quasistationary system, and then the ensuing dynamics have been studied [33][34][35][36][37].
Introduced long ago by Gauss & Riemann, curvature is a central concept in geometry that quantifies the extent to which a space is curved [38]. In geometry, the primary invariant is curvature in its many forms. While curvature has connections to several essential aspects of the underlying space, in a specific case, curvature has a connection to the Laplacian, and hence, to the 'heat kernel' on a network. Curvature also has connections to the Brownian motion and entropy growth on a network. Moreover, curvature is also related to algebraic topological aspects, such as the homology groups and Betti numbers, which are relevant, for instance, for persistent homology and topological data analysis [39]. Recently, there has been immense interest in geometrical characterization of complex networks [40][41][42][43][44]. Network geometry can reveal higher-order correlations between nodes beyond pairwise relationships captured by edges connecting two nodes in a graph [45][46][47]. From the point of view of structure and dynamics of complex networks, edges are more important than nodes, since the nodes by themselves cannot constitute a meaningful network. Hence, it may be more important to develop edge-centric measures rather than node-centric measures to characterize the structure of complex networks [43,48].
Surprisingly, geometrical concepts, especially, discrete notions of Ricci curvature, have only very recently been used as edge-centric network measures [42,43,[48][49][50][51]. Furthermore, curvature has deep connections to related evolution equations that can be used to predict the long-time evolution of networks. Although the importance of geometric measures like curvature have been understood for quite some time, yet there has been limited number of applications in the context of complex financial networks. In particular, Sandhu et al. [50] studied the evolution of Ollivier-Ricci curvature [52,53] in threshold networks for the USA S&P-500 market over a 15-year span (1998-2013) and showed that the Ollivier-Ricci curvature is correlated to the increase in market network fragility. Consequently, Sandhu et al. [50] suggested that the Ollivier-Ricci curvature can be employed as an indicator of market fragility and study the designing of (banking) systems and framing regulation policies to combat financial instabilities such as the sub-prime crisis of 2007-2008. In this paper, we expand the study of geometry-inspired network measures for characterizing the structure of the financial systems to four notions of discrete Ricci curvature, and evaluate the curvature measures as generic indicators of the market instability.
It is noteworthy that in the present paper, the term 'curvature' refers to four notions of discrete Ricci curvature investigated here, which are as such intrinsic curvatures, and not extrinsic curvatures as has been considered elsewhere in the context of complex networks (e.g. [54]). Recall that extrinsic geometry is given by embedding the networks in a suitable ambient space (which in practice is the hyperbolic plane or space), and thereafter, the geometric properties induced by the embedding space are studied (e.g. [55]). While this approach is intuitive and conducive to simple illustrations, such network embeddings are distorting, except for the special case of isometric embeddings. By contrast, the intrinsic approach to networks is independent of any specific embedding, and hence, of the necessary additional computations and any distortion. Moreover, such an intrinsic approach allows for the independent study of such powerful tools as the Ricci flow, without the vagaries associated with the embedding in an ambient space of certain dimension (e.g. [56]). Furthermore, the Ollivier-Ricci curvature has been employed to show that the 'backbone' of certain real-world networks is indeed tree-like, hence intrinsically hyperbolic [49]. Specific to financial networks, Sandhu et al. [50] have shown that Ollivier-Ricci curvature, which is of course an intrinsic curvature, presents a powerful tool in the detection of financial market crashes. In this work, we have considered three additional notions [43,55] of discrete Ricci curvature for the study of financial networks.
In the present paper, we examine the daily returns from a set of stocks comprising the USA S&P-500 and the Japanese Nikkei-225 over a 32-year period, and monitor the changes in the edge-centric geometric curvatures. A major goal of this research is to evaluate different notions of discrete Ricci curvature for their ability to unravel the structure of complex financial networks and serve as indicators of market instabilities. Our study confirms that during a normal period the market is very modular and heterogeneous, whereas during an instability (crisis) the market is more homogeneous, highly connected and less modular [18,21,22,57]. Further, we find that the discrete Ricci curvature measures, especially Forman-Ricci curvature [43,48], capture well the system-level features of the market and hence we can distinguish between the normal or 'business-as-usual' periods and all the major market crises (bubbles and crashes). Importantly, among four Ricci-type curvature measures, the Forman-Ricci curvature of edges correlates highest with the traditional market indicators and acts as an excellent indicator for the system-level fear (volatility) and fragility (risk) for both the markets. We also find using these geometric measures that there are succinct and inherent differences in the two markets, USA S&P-500 and Japan Nikkei-225. These new insights will help us to understand royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 3 tipping points, systemic risk, and resilience in financial networks, and enable us to develop monitoring tools required for the highly interconnected financial systems and perhaps forecast future financial crises and market slowdowns.

Ricci-type curvatures for edge-centric analysis of networks
The classical notion of Ricci curvature applies to smooth manifolds, and its classical definition requires tensors and higher-order derivatives [38]. Thus, the classical definition of Ricci curvature is not immediately applicable in the discrete context of graphs or networks. Therefore, in order to develop any meaningful notion of Ricci curvature for networks, one has to inspect the essential geometric properties captured by this curvature notion, and find their proper analogues for discrete networks. To this end, it is essential to recall that Ricci curvature quantifies two essential geometric properties of the manifold, namely, volume growth and dispersion of geodesics. See electronic supplementary material, figure S1 for a schematic illustration of the Ricci curvature. Further, since classical Ricci curvature is associated with a vector (direction) in smooth manifolds [38], in the discrete case of networks, it is naturally assigned to edges [48]. Thus, notions of discrete Ricci curvatures are associated with edges rather than vertices or nodes in networks [48]. Note that no discretization of Ricci curvature for networks can capture the full spectrum of properties of the classical Ricci curvature defined on smooth manifolds, and thus, each discretization can shed a different light on the analysed networks [48]. In this work, we apply four notions of discrete Ricci curvature for networks to study the correlation-based networks of stock markets.

Ollivier-Ricci curvature
Ollivier's discretization [52,53] of the classical Ricci curvature has been extensively used to analyse graphs or networks [42,[48][49][50][51][58][59][60][61][62]. Ollivier's definition is based on the following observation. In spaces of positive curvature, balls are closer to each other on the average than their centres, while in spaces of negative curvature, balls are farther away on the average than their centres (electronic supplementary material, figure S2). Ollivier's definition extends this observation from balls (volumes) to measures ( probabilities). More precisely, the Ollivier-Ricci (OR) curvature of an edge e between nodes u and v is defined as where m u and m v represent measures concentrated at nodes u and v, respectively, W 1 denotes the Wasserstein distance [63] (also known as the earth mover's distance) between the discrete probability measures m u and m v , and the cost d(u, v) is the distance between nodes u and v, respectively. Moreover, the Wasserstein distance W 1 (m u , m v ), which gives the transportation distance between the two measures m u and m v , is given by with ∏ (m u , m v ) being the set of probability measures μ u,v that satisfy where V is the set of nodes in the graph. The above equation represents all the transportation possibilities of the mass m u to m v . W 1 (m u , m v ) is the minimal cost or distance to transport the mass of m u to that of m v . Note that the distance d(u 0 , v 0 ) in equation (2.2) is taken to be the path distance in the unweighted or weighted graph. Furthermore, the probability distribution m u for u ∈ V has to be specified, and this is chosen to be uniform over neighbouring nodes of u [59].
Simply stated, to determine the OR curvature of an edge e, in equation (2.1) one compares the average distance between the neighbours of the nodes u and v anchoring the edge e in an optimal arrangement with the distance between u and v itself. Importantly, the average distance between neighbours of u and v is evaluated as an optimal transport problem wherein the neighbours of u are coupled with those of v in such a manner that the average distance is as small as possible. In the setting of discrete graphs or networks, OR curvature by definition captures the volume growth aspect of the classical notion for royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 smooth manifolds (e.g. [48] for details). In this work, we have computed the average OR curvature of edges (ORE) in undirected and weighted networks using equation (2.1).

Forman-Ricci curvature
Forman's approach to the discretization of Ricci curvature [64] is more algebraic in nature and is based on the relation between the Riemannian Laplace operator and Ricci curvature. While devised originally for a much larger class of discrete geometric objects than graphs, an adaptation to network setting was recently introduced by some of us [43]. The Forman-Ricci (FR) curvature F(e) of an edge e in an undirected network with weights assigned to both edges and nodes is given by [43] where e denotes the edge under consideration between nodes v 1 and v 2 , w e denotes the weight of the edge e, w v1 and w v2 denote the weights associated with the nodes v 1 and v 2 , respectively, e v1 e and e v2 e denote the set of edges incident on nodes v 1 and v 2 , respectively, after excluding the edge e under consideration which connects the two nodes v 1 and v 2 . Furthermore, some of us have also extended the notion of FR curvature to directed networks [65]. In the case of discrete networks, FR curvature captures the geodesic dispersal property of the classical notion [48]. In electronic supplementary material, figure S3, we illustrate, using a simple example, the computation of FR curvature in an undirected graph. In this work, we have computed the average FR curvature of edges (FRE) in undirected and weighted networks using equation (2.4). From a geometric perspective, the FR curvature quantifies the information spread at the ends of edges in a network (figure 1; electronic supplementary material, figure S3). The higher the information spread at the ends of an edge, the more negative will be the value of its FR curvature. Specifically, an edge with high negative FR curvature is likely to have several neighbouring edges connected to both anchoring nodes, and moreover, such an edge can be seen as a funnel at both ends, connecting many other nodes. Intuitively, such an edge with high negative FR curvature can be expected to have high edge betweenness centrality, as many shortest paths between other nodes, including those quite far in the network, are also likely to pass through this edge. Previously, some of us have empirically shown a high statistical correlation between FR curvature and edge betweenness centrality in diverse networks [48,66].

Menger-Ricci curvature
The remaining two curvatures studied here are adaptations of curvatures for metric spaces to discrete graphs. Indeed, both unweighted and weighted graphs can be viewed as a metric space where the distance between any two nodes can be specified by the path length between them. Among notions of metric, and indeed, discrete curvature, Menger [67] has proposed the simplest and earliest definition whereby he defines the curvature of metric triangles T formed by three points in the space as the reciprocal 1/R(T ) of the radius R(T ) of the circumscribed circle of a triangle T. Recently, some of us [55,68] have adapted Menger's definition to networks. Let (M, d) be a metric space and T = T(a, b, c) be a triangle with sides a, b, c, then the Menger curvature of T is given by where p = (a + b + c)/2. In the particular case of a combinatorial triangle with each side of length 1, the above formula gives K M (T) ¼ ffiffi ffi 3 p =2. Furthermore, it is clear from the above formula that Menger curvature is always positive. Following the differential geometric approach, the Menger-Ricci (MR) curvature of an edge e in a network can be defined as [55,68] where T e ∼ e denote the triangles adjacent to the edge e. Intuitively, if an edge is part of several triangles in the network, such an edge will have high positive MR curvature (figure 1). In electronic supplementary material, figure S4, we illustrate, using a simple example, the computation of MR curvature in an undirected graph. In this work, we have computed the average MR curvature of edges (MRE) in undirected financial networks by ignoring the edge weights and using equation (2.6).
royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: used for the construction of the threshold network. (d) MST T τ (t) constructed using the distance matrix D τ (t). (e) Threshold network S τ (t) constructed by adding edges with C ij (t) ≥ 0.75 to the MST T τ (t). ( f) Evolution of the average of four discrete Ricci curvatures for edges, namely, Ollivier-Ricci (ORE), Forman-Ricci (FRE), Menger-Ricci (MRE) and Haantjes-Ricci (HRE), computed using the threshold networks S τ (t) constructed from correlation matrices over time epochs of τ = 22 days and overlapping shift of Δτ = 5 days. In this figure, C τ (t), D τ (t), T τ (t) and S τ (t) shown in (b)-(e) correspond to the correlation frame denoted by vertical dashed line in (a). (g) Evaluation of discrete Ricci curvatures on a toy example network which is undirected and unweighted. Here, the edge between v 27 and v 30 has a highly negative FR curvature as it depends on the degree of the two nodes or number of neighbouring edges. However, the edge between v 27 and v 30 has MR and HR curvature equal to zero as the edge under consideration is not part of any triangles or cycles, respectively. Moreover, the edge between v 1 and v 2 also has a highly negative FR curvature as the degree of both anchoring vertices is 4. By contrast, the edge between v 1 and v 2 has positive MR and HR curvature as the edge is part of a triangle which contributes to MR curvature and the edge is part of a triangle, a pentagon and a hexagon which contribute to HR curvature. For both the edges between v 27 and v 30 and between v 1 and v 2 , one can compute OR curvature; however, only triangles, quadrangles and pentagons make positive contribution to the OR curvature in unweighted and undirected networks. Specifically, the edge between v 1 and v 2 is part of a triangle, a pentagon and a hexagon; however, only the triangle and pentagon make positive contribution to OR curvature.

Haantjes-Ricci curvature
We have also applied another notion of metric curvature to networks which is based on the suggestion of Finsler and was developed by his student Haantjes [69]. Haantjes defined the curvature of a metric curve as the ratio between the length of an arc of the curve and that of the chord it subtends. More precisely, given a curve c in a metric space (M, d), and given three points p, q, r on c, p between q and r, the Haantjes curvature at the point p is defined as where l( b qr) denotes the length, in the intrinsic metric induced by d, of the arc b qr. In networks, b qr can be replaced by a path π = v 0 , v 1 , …, v n between two nodes v 0 and v n , and the subtending chord by the edge e = (v 0 , v n ) between the two nodes. Recently, some of us [55,68] have defined the Haantjes curvature of such a simple path π as , that is the shortest path distance between nodes v 0 and v n . In particular, for the combinatorial metric (or unweighted graphs), we obtain that , v n is as above. Note that considering simple paths in graphs concords with the classical definition of Haantjes curvature, since a metric arc is, by its very definition, a simple curve. Thereafter, the Haantjes-Ricci (HR) curvature of an edge e [55,68] can be defined as where π ∼ e denote the paths that connect the nodes anchoring the edge e. Note that while MR curvature considers only triangles or simple paths of length 2 between two nodes anchoring an edge in unweighted graphs, the HR curvature considers even longer paths between the same two nodes anchoring an edge (figure 1). Moreover, for triangles endowed with the combinatorial metric, the two notions by Menger and Haantjes coincide, up to a universal constant. In electronic supplementary material, figure S4, we illustrate, using a simple example, the computation of HR curvature in an undirected graph. In this work, we have computed the average HR curvature of edges (HRE) in undirected financial networks by ignoring the edge weights and using equation (2.9). Moreover, due to computational constraints, we only consider simple paths π of length less than or equal to 4 between the two vertices at the ends of any edge while computing its HR curvature using equation (2.9) in analysed networks. Note that both Menger and Haantjes curvature are positive in undirected networks, and they capture the (absolute value of ) geodesics dispersal rate of the classical Ricci curvature.

Data description
The data were collected from the public domain of Yahoo finance database [70] for two markets: USA S&P-500 index and Japanese Nikkei-225 index. The investigation in this work spans a 32-year period from 2 January 1985 to 30 December 2016. We analysed the daily closure price data of N = 194 stocks for T = 8068 days for USA S&P-500 and N = 165 stocks for T = 7998 days for Japanese Nikkei-225 markets. Electronic supplementary material, tables S1 and S2 give the lists of 194 and 165 stocks (along with their sectors) for the USA S&P-500 and Japanese Nikkei-225 markets, respectively, and these stocks are present in the two markets for the entire 32-year period considered here.

Cross-correlation and distance matrices
We present a study of time evolution of the cross-correlation structures of return time series for N stocks ( figure 1). The daily return time series is constructed as r k (t) = lnP k (t) − lnP k (t − 1), where P k (t) is the adjusted closing price of the kth stock at time t (trading day). Then, the cross-correlation matrix is royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 constructed using equal-time Pearson cross-correlation coefficients, where i, j = 1, …, N, t indicates the end date of the epoch of size τ days, and the means 〈 · · · 〉 as well as the standard deviations σ k are computed over that epoch. Instead of working with the correlation coefficient C ij (t), we use the 'ultrametric' distance measure: such that 0 ≤ D ij (t) ≤ 2, which can be used for the construction of networks [11,12,18,27].
Here, we computed daily return cross-correlation matrix C τ (t) over the short epoch of τ

Network construction
For a given time epoch of τ days ending on trading day t, the distance matrix D τ (t) constructed from the correlation matrix between the 194 stocks in USA S&P-500 index or the 165 stocks in Japan Nikkei-225 index can be viewed as an undirected complete graph G τ (t), where the weight of an edge between stocks i and j is given by the distance D ij (t). For the time epoch of τ days ending on trading day t, we start with this edge-weighted complete graph G τ (t) and create the MST T τ (t) using Prim's algorithm [71]. Thereafter, we add edges in G τ (t) with C ij (t) ≥ 0.75 to T τ (t) to obtain the graph S τ (t) (figure 1). We will use the graph S τ (t) to compute different discrete Ricci curvatures and other network measures. We remark that the procedure used here to construct the graph S τ (t) follows previous works [18,50] on analysis of correlation-based networks of stock markets.
Intuitively, the motivation behind the above method of graph construction can be understood as follows. Firstly, the MST method gives a connected (spanning) graph between all nodes (stocks) in the specific market. Secondly, the addition of edges between nodes (stocks) with correlation C ij (t) ≥ 0.75 ensures that the important edges are also captured in the graph S τ (t).

Common network measures
Given an undirected graph G(V, E) with the sets of vertices or nodes V and edges E, the number of edges is given by the cardinality of set E, that is m = |E|, and the number of nodes is given by the cardinality of set V, that is n = |V|. The edge density of such a graph is given by the ratio of the number of edges m divided by the number of possible edges, that is, 2m/n(n − 1). The average degree 〈k〉 of the graph gives the average number of edges per node, that is, 〈k〉 = m/n. In the case of an edge-weighted graph where a ij denotes the weight of the edge between nodes i and j, one can also compute its average weighted degree 〈k w 〉 which gives the average of the sum of the weights of the edges connected to nodes, that is, For any pair of nodes i and j in the graph, one can compute the shortest path length d ij between them. Thereafter, the average shortest path length 〈L〉 is given by the average of the shortest path lengths between all pairs of nodes in the graph, that is, The diameter is given by the maximum of the shortest paths between all pairs of nodes in the graph, i.e. max{d ij 8i, j [ V}. The communication efficiency [72] of a graph is an indicator of its global ability to exchange information across the network. The communication efficiency CE of a graph is given by royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 Modularity measures the extent of community structure in the network and community detection algorithms aim to partition the graph into communities such that the modularity Q attains the maximum value [73]. The modularity Q is given by the equation [73,74] where k i and k j give the sum of weights of edges attached to nodes i and j, respectively, c i and c j give the communities of i and j, respectively, and δ(c i , c j ) is equal to 1 if c i = c j else 0. Here, we use Louvain method [74] to compute the modularity of the edge-weighted networks. Network entropy is an average measure of graph heterogeneity as it quantifies the diversity of edge distribution using the remaining degree distribution q k [75]. q k denotes the probability of a node to have remaining (excess) degree k and is given by q k = (k + 1)p k+1 /〈k〉 where p k+1 denotes the probability of a node to have degree k + 1. The network entropy H(q) of a graph is then given by The above-mentioned network measures were computed in stock market networks using the Python package NetworkX [76].

GARCH( p, q) process
The generalized ARCH process GARCH( p, q) was introduced by Bollerslev [77]. The variable x t , a strong white noise process, can be written in terms of a time-dependent standard deviation σ t , such that x t ≡ η t σ t , where η t is a random Gaussian process with zero mean and unit variance. The simplest GARCH process is the GARCH(1,1) process, with Gaussian conditional probability distribution function where α 0 > 0 and α 1 ≥ 0; β 1 is an additional control parameter. One can rewrite equation (3.1) as a random multiplicative process For calculating this we have used an in-built function from Matlab garch (https://in.mathworks.com/ help/econ/garch.html).

Minimum risk portfolio
We calculated the minimum risk portfolio in the Markowitz framework, as a measure of risk-aversion of each investor with maximized expected returns and minimized variance. In this model, the variance of a portfolio shows the importance of effective diversification of investments to minimize the total risk of a portfolio. The Markowitz model minimizes w 0 Ωw − ϕR 0 w with respect to the normalized weight vector w, where Ω is the covariance matrix calculated from the stock log-returns, ϕ is the measure of risk appetite of investor and R 0 is the expected return of the assets. We set short-selling constraint, ϕ = 0 and w i ≥ 0 which entails a convex combination of stock return for finding the minimum risk portfolio. For calculating this we have used an in-built function from Matlab (https://in.mathworks.com/help/finance/portfolio. html).

Results and discussion
We analyse here the time series of the logarithmic returns of the stocks in the USA S&P-500 and Japanese Nikkei-225 markets over a period of 32 years (1985-2016) by constructing the corresponding Pearson cross-correlation matrices C τ (t). We then use cross-correlation matrices C τ (t) computed over time epochs of size τ = 22 days with either overlapping or non-overlapping epochs (i.e. shifts of Δτ = 5 or 22 days, respectively) and ending on trading days t to study the evolution of the correlation-based networks S τ (t) and corresponding network properties, especially edge-centric geometric measures. Figure 1 gives an overview of our evaluation of discrete Ricci curvatures in correlation-based royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 threshold networks constructed from log-returns of market stocks. Figure 1a shows the daily log-returns over the 32-year period (1985-2016). An arbitrarily chosen cross-correlation matrix C τ (t) over time epoch of τ = 22 days and Δτ = 5 days ending on 4 May 2011 and corresponding distance matrix D t (t) ¼ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi 2(1 À C t (t)) p are shown in figure 1b,c, respectively. The MST T τ (t) constructed from the distance matrix D τ (t) is shown in figure 1d. Thereafter, a threshold network S τ (t) is constructed using MST T τ (t) and edges with C ij (t) ≥ 0.75, as shown in figure 1e. The discrete Ricci curvatures are computed from the threshold networks. In figure 1f , we show the evolution of the discrete curvatures in threshold networks over the 32-year period. In figure 1g, we motivate the four discrete Ricci curvatures considered here using a simple example network.
A major goal of this research is to evaluate different notions of discrete Ricci curvature for their ability to unravel the structure of complex financial networks and serve as indicators of market instabilities. Previously, Sandhu et al. [50] have analysed the USA S&P-500 market over a period of 15 years (1998-2013) to show that the average Ollivier-Ricci (OR) curvature of edges (ORE) in threshold networks increases during periods of financial crisis. Here, we extend the analysis by Sandhu et al. [50] to (i) two different stock markets, namely, USA S&P-500 and Japanese Nikkei-225, (ii) a span of 32 years (1985-2016), (iii) four traditional market indicators (namely, index log-returns r, mean market correlation μ, volatility of the market index r estimated using GARCH(1,1) process, and risk σ P corresponding to the minimum risk Markowitz portfolio of all the stocks in the market), and (iv) four notions of discrete Ricci curvature for networks. Since discretizations of Ricci curvature are unable to capture the entire properties of the classical Ricci curvature defined on continuous spaces, the four discrete Ricci curvatures evaluated here can shed light on different properties of analysed networks [48]. In particular, some of us have introduced another discretization, Forman-Ricci (FR) curvature, to the domain of networks [43]. Note that OR curvature captures the volume growth property of classical Ricci curvature while FR curvature captures the geodesic dispersal property [48]. Nevertheless, our empirical analysis has shown that the two discrete notions, OR and FR curvature, are highly correlated in model and real-world networks [48]. Importantly, in large networks, computation of the OR curvature is intensive while that of the FR curvature is simple as the latter depends only on immediate neighbours of an edge [48]. Therefore, we started by investigating the ability of FR curvature to capture the structure of complex financial networks.  royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 minimum). Earlier Sandhu et al. [50] had focused on OR curvature as an indicator of crashes. Here, we additionally show that discrete Ricci curvatures, especially FR curvature, are sensitive and can detect both crash (market volatility high) and bubble (market volatility low). It is often difficult to gauge the state of the market by simply monitoring the market index or its logreturns. There exist no simple definitions of a market crash or a market bubble. The market becomes extremely correlated and volatile during a crash, but a bubble is even harder to detect as the volatility is relatively low and only certain sectors perform very well (stocks show high correlation) but the rest of the market behaves like normal or 'business-as-usual'. Traditionally, the volatility of the market captures the 'fear' and the evaluated risk captures the 'fragility' of the market. Some of us showed in our earlier papers that the mean market correlation and the spectral properties of the cross-correlation matrices can be used to study the market states [20] and identify the precursors of market instabilities [22]. A goal of this study is to show that the state of the market can be continuously monitored with certain network-based measures. Thus, we next performed a comparative investigation of several network measures, especially, the four discrete notions of Ricci curvature.    figure S7, we show the temporal evolution of the four discrete Ricci curvatures computed in threshold networks S τ (t) obtained using three different thresholds, C ij (t) ≥ 0.65 (cyan colour), C ij (t) ≥ 0.75 (dark blue colour) and C ij (t) ≥ 0.85 (sienna colour), for the two markets. It is seen that the absolute value of ORE, FRE, MRE and HRE decreases with the increase in the threshold C ij (t) used to construct S τ (t). Regardless of the three thresholds used to construct the threshold networks S τ (t), we show that the four discrete Ricci curvatures are fine indicators of market instabilities.
In previous work, Sandhu et al. [50] had contrasted the temporal evolution of ORE in threshold networks for USA S&P-500 market with NE, graph diameter and average shortest path length. Here, we have studied the temporal evolution of a larger set of network measures in threshold networks for USA S&P-500 and Japanese Nikkei-225 markets computed from the correlation matrices C τ (t) of epoch size τ = 22 days and overlapping shift of Δτ = 5 days, over a 32-year period (1985-2016). From figures 3 and 4, it is seen that NE and CE are also excellent indicators of market instabilities. In fact, we find that common network measures such as number of edges, edge density, average degree, average shortest path length, graph diameter, average clustering coefficient and modularity are also good indicators of market instabilities (electronic supplementary material, figure S8).
In electronic supplementary material, figures S9 and S10, we show the temporal evolution of the market indicators and several network measures (including edge-centric Ricci curvatures) computed from the correlation matrices C τ (t) of epoch size τ = 22 days and non-overlapping shift of Δτ = 22 days, over a 32-year period  in the two markets. It can be seen that our results are also not dependent on the choice of overlapping or non-overlapping shift used to construct the crosscorrelation matrices and threshold networks. royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 correlation among the four discrete Ricci curvatures with the four traditional market indicators in the two markets, and thus, FRE is an excellent indicator for market risk that captures local to global system-level fragility of the markets. Furthermore, both NE and CE also have high correlation with the four traditional market indicators. Therefore, these measures can be used to monitor the health of the financial system and forecast market crashes or downturns. Overall, we show that FRE is a simple yet powerful tool for capturing the correlation structure of a dynamically changing network.

Conclusion
In this paper, we have employed geometry-inspired network curvature measures to characterize the correlation structures of the financial systems and used them as generic indicators for detecting market instabilities (bubbles and crashes). We reiterate here that it is often difficult to gauge the state of the market by simply monitoring the market index or its log-returns. There exist no simple definitions of a market crash or a market bubble. The market becomes extremely correlated and volatile during a crash, but a bubble is even harder to detect as the volatility is relatively low and only certain sectors perform very well (stocks show high correlation) but the rest of the market behaves like normal or 'business-as-usual'. We have examined the daily returns from a set of stocks comprising the USA S&P-500 and the Japanese Nikkei-225 over a 32-year period, and monitored the changes in the edge-centric geometric curvatures. Our results are very robust as we have studied two very different markets, and for a very long period of 32 years with several interesting market events (bubbles and crashes; table 1). We showed that the results are not very sensitive to the choice of overlapping or non-overlapping epochs used to construct the cross-correlation matrices and threshold networks (figures 3-4; electronic supplementary material, figures S8-S10). Further, the choice of the thresholds for constructing networks also has little influence on their behaviour as indicators (electronic supplementary material, figures S5-S7). In addition, to test the robustness of our methodology in the current paper, we have added small amounts of Gaussian noise to the empirical correlation matrices for the USA S&P-500 market, and reproduced the evolution of the topological properties as well as the geometric curvature measures over the 32-year period. Specifically, we have found that the results are not sensitive to small amounts of noise or random reshuffling of data (electronic supplementary material, figure S12). We found that the four different notions of discrete Ricci curvature captured well the system-level features of the market and hence we were able to distinguish between the normal or 'business-as-usual' periods and all the major market crises (bubbles and crashes) using the network-centric indicators. Our studies confirmed that during a normal period the market is very modular and heterogeneous, whereas during an instability (crisis) the market is more homogeneous, highly connected and less modular.
Interestingly, our methodology picks up many peaks other than the major crashes and bubbles; these are neither spurious nor false positives. Unlike the major crashes and bubbles which are welldocumented in the financial literature (or listed in Internet sources, see table 1), many of these peaks correspond to interesting events that are not well understood or recorded in the literature. In fact the financial markets are often driven by endogenous and exogenous factors. Moreover, there are often multiple reasons leading to a market crash or a bubble burst. The study and characterization of such market events, including exogenous shocks, bubble bursts and anomalies, corresponding to such peaks has already been done in our earlier papers [20][21][22]30]. The findings of the present paper are in concordance with the earlier ones.
It is important to note that partial correlations can detect direct as opposed to plausibly indirect connections among components of the stock market. In the Econophysics literature (e.g. [30,[84][85][86][87]), researchers have used partial correlations for analysing the dynamics and constructing networks of stock markets. Partial correlations are particularly relevant when people study eigenvalue spectra (market, group and random modes), or network centrality measures, by first filtering out the spurious correlations. However, it has been observed [30,86] that partial correlations are less successful in picking the cluster or group dynamics, and the networks arising from partial correlations are also less stable. In this contribution, we are more interested in the market indicators and the use of discrete Ricci curvatures as generic indicators, for which we prefer to work with the more stable correlation matrices.
Also, we find from these geometric measures that there are succinct and inherent differences in the two markets, USA S&P-500 and Japan Nikkei-225. Importantly, among four Ricci-type curvature measures, the Forman-Ricci curvature of edges (FRE) correlates highest with the traditional market royalsocietypublishing.org/journal/rsos R. Soc. Open Sci. 8: 201734 indicators and acts as an excellent indicator for the system-level fear (volatility) and fragility (risk) for both the markets. These new insights may help us in future to better understand tipping points, systemic risk and resilience in financial networks, and enable us to develop monitoring tools required for the highly interconnected financial systems and perhaps forecast future financial crises and market slowdowns. These can be further generalized to study other economic systems, and may thus enable us to understand the highly complex and interconnected economic-financial systems.
Ethics. In this manuscript, there are no data or topics that need ethical approval. Data accessibility. All data used are openly available for download on the websites of the relevant sources mentioned in the text and stated in the references section. All relevant data and codes for this study have been uploaded and made publicly available via the GitHub repository: https://github.com/asamallab/StockMarkNetIndicator.