Finance - Grapth Theory

12
Forecasting short term abrupt changes in the stock market with wavelet decomposition and graph theory Marco Antonio Leonel Caetano !"#$%& !()*+*,*- ./ %()+(- / $/ )0,+)1 2 #3- $1,4- 2 56 17+4 [email protected]  Takashi Yoneyama !89 2 !()*+*,*- 8/:(-4;<+:- .1 9/6-(=,*+:1 2 #3- >-)? .-) @1AB-) 2 5617+4 [email protected]  Abstract After the financial crisis of 2008 the researches about causes and consequences increased in all sector of world market. The intuition of systemic risk and connection among the stock markets led several analysts to observe the network theory as possible explanation of abrupt changes in financial markets. This work propose a new methodology to detect the abrupt changes in the stock market by combining a numerical indicator based on the wavelet decomposition technique with a measure of the interdependency of the markets using graph theory. The indicator based on wavelet decomposition to measure abrupt changes in stock market was presented by authors in others works and showed good coherence with actual data. The idea in this work is to observe the behavior of stock market with its links and correlations using network and graph theory. An association is made between level of connection in all nodes of network and the measure of stress in market using indicator of decomposition wavelet. Experimentations are made with a variety of financial time series using actual data of the Brazilian stock market (BOVESPA). A case study involving nin e shares of stock market is presented in the analyzing the imminence of a drawdown Keywords: Network, Graph Theory, Wavelet De composition, Stock Market, Modeling

Transcript of Finance - Grapth Theory

Page 1: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 1/12

Forecasting short term abrupt changes in the stockmarket with wavelet decomposition and graph theory

Marco Antonio Leonel Caetano!"#$%& !()*+*,*- ./ %()+(- / $/)0,+)1 2 #3- $1,4- 2 5617+4

[email protected]

Takashi Yoneyama!89 2 !()*+*,*- 8/:(-4;<+:- .1 9/6-(=,*+:1 2 #3- >-)? .-) @1AB-) 2 5617+4

[email protected]

Abstract

After the financial crisis of 2008 the researches about causes and consequencesincreased in all sector of world market. The intuition of systemic risk and connectionamong the stock markets led several analysts to observe the network theory as possibleexplanation of abrupt changes in financial markets. This work propose a newmethodology to detect the abrupt changes in the stock market by combining a numericalindicator based on the wavelet decomposition technique with a measure of the

interdependency of the markets using graph theory. The indicator based on waveletdecomposition to measure abrupt changes in stock market was presented by authors inothers works and showed good coherence with actual data. The idea in this work is toobserve the behavior of stock market with its links and correlations using network andgraph theory. An association is made between level of connection in all nodes ofnetwork and the measure of stress in market using indicator of decomposition wavelet.Experimentations are made with a variety of financial time series using actual data ofthe Brazilian stock market (BOVESPA). A case study involving nine shares of stockmarket is presented in the analyzing the imminence of a drawdown

Keywords: Network, Graph Theory, Wavelet Decomposition, Stock Market, Modeling

Page 2: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 2/12

1. Introduction

The stock market of developing countries is typically dependent of large

financial centers around the world. In a more macroscopic view, one can say that theagents in the stock market today are closely connected and form a network. This worktry to exploit some known results on graph theory to model networks and use them toimprove a method proposed by the authors in a previous article, in order to providemore accurate short term forecasting of abrupt changes in the stock market. The graphstructure adopted here is assumes the vertices to represent financial Brazilian shares,while the links are associated with the correlations of their price history. The idea is tocombine the information provided by the graph structure with an index based on thewavelet decomposition technique, proposed by the authors in previous works.

The Graph Theory has been found to be very useful in a variety of fields ofknowledge, such as engineering, sociology, biology and ecology (May, 1974). Forinstance, Haldane (Haldane, 2009) notes that some simple ecosystems such savannasand rainforests could be quite robust to attacks, while complex systems such as tropicalforests could exhibit fragilities against plagues. In the field of financial, Haldane(Haldane, 2009) points out that complexity does not mean robustness and mentions the2008 crisis which was neither self-regulating nor self-repairing. In a later work Haldane(Haldane and May, 2011) showed that the network structure of a financial network has

profound implications on the dynamics of its systemic risk.

Onnela (Onnela et al., 2003 a; Onnela et al, 2004) proposed that it is possibleestimate the information content of market networks by means of graph theory. In orderto illustrate this fact Onnela (Onnela et al., 2003 b) describes the case of Black Mondayof 1987.

The graph theory has also been used to tackle the problem of price returns instock portfolios, such as in Estrada (Estrada et al.,2010). In some cases, a node in anetwork may compete with other nodes, leading to the instability of the the full system(Bornholdt and Schuster, 2003). In Junker (Junker, 2008), the issue of robustness of anetworked system against attacks is studied using graph theory.

A different way to observe the stock market is to analyze the time seriescorresponding to the price history. It is known that high frequency components areusually observed in the quotation data prior to the occurrence of abrupt changes in the

prices, reflecting the stress in the market (Sornette et al ., 1996, 1997, 1998, 2003;Johansen, 2001, 2003; Rappoport, 1993,1994). One approach to quantify the relevanceof these high frequency components is to build an index based on wavelet (Caetano andYoneyama, 2007; 2009).

In this work, the information derived from the application of the graph theory tofinancial networks is used to improve the detection accuracy of the wavelet based index

Page 3: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 3/12

proposed previously by the authors (Caetano and Yoneyama, 2007; 2009). The actualdata used in the case study are the price history practiced in the Brazilian stock market(BOVESPA).

2. Networks and Graph Theory

This section is devoted to the review of some known facts of Graph Theory. Agraph G(S,L) is defined by a set S of nodes, S = {n 1, ... , n N } and a set L of links. Eachlink is an ordered pair of nodes, i.e. (n i,n j ) represents a link between ni and n j (Bornholdtand Schuster, 2003). When no possibility of confusion exists, a graph is denoted simplyG. In order to represent a graph in a convenient way, the concept of adjacency matrix C is introduced. The entry cij of C is set to 1 if a link exists from ni to n j . Otherwise cij = 0 .

In the present work, the concept of correlation is used to represent links. Therefore cij =c ji and C is symmetric. Thus, the graph is of undirected type. Figure 1 shows anexample graph and its corresponding adjacency matrix. Solid lines indicate that the linkis present (c ij = 1), while light dashed lines represent absence of link.

Figure 1 - An undirected graph and its adjacency matrix

Now, it is known that if G is an undirected graph, then the eigenvalues of itsadjacency matrix C are real and the maximum eigenvalue max is non-negative.Moreover, the modules of all other eigenvalues do not exceed max. If H is a sub-graphof G, i.e., H(S',L') is such that S' S and L' L, then

max(C') max(C) (1)

Page 4: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 4/12

where C' is the adjacency matrix of H . The inequality is strict if G is connected. Figure2 shows the reduction of the maximum eigenvalue of the adjacency matricescorresponding to graphs obtained by deleting some links.

max = 3.4 max = 2.4 max = 2.0 max = 1.8

Figure 2 - Illustration of the value of the max as a measure of the multiplicity of links. One cannote that max decreases as links are eliminated, reducing the connectivity of the network.

Here, the nodes will represent Brazilian shares, such Petrobras (Petr4), Vale doRio Doce (Vale5) and others. A link between nodes i and j will be considered to exist(i.e., cij = 1 , in terms of the adjacency matrix) at a certain time k , if the indices i and j are strongly correlated. The correlation is computed using the data in the time window[k window _ size, k ]. The correlation is considered to be strong if its absolute value isgreater than a chosen threshold thr .

In this case, the idea is that some nodes may become disconnected orreconnected, during different phases of changes in the prices, as shown in the case study

presented with shares.

3. Indicator of Abrupt Changes based on Wavelet Decomposition

The study of abrupt changes in the stock market was the object of a previouswork (Caetano and Yoneyama, 2009), where the authors proposed a method to provide

short term forecast of an abrupt changes in the financial market. This method was basedon the Wavelet Transform to evaluate the high frequency content of financial data andwas inspired on the work by Sornette and his colleagues (Sornette et al, 1996, 1997,1998, 2003). The rationale behind the method is that when the financial market isstressed, high frequency components are observed in the data. However, Fourier Series(and even Windowed Fourier Series) is not a convenient tool to characterize theharmonic contents, as the data are not periodic functions. Therefore, instead of usingsines and cosines, the family of functions obtained by translation and scaling of acertain function (called mother wavelet) is used as a basis

Page 5: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 5/12

Rb, Ra,a

bt at ; R L.

2 / 1b,a2b,a ) (2)

where the constants a 0 and b are called scale and translation parameters,

respectively. Then, if f(t) is a square integrable function, it can be expanded in terms of a,b

dt t b,aW C 1

)t ( f b,a f (3)

where W f (a,b) are easily computable coefficients and C is a normalizing constant.Actually, in the practical implementation of the method, a discretized version of

the Wavelet Transform is used and an index that evaluates the number of coefficientsassociated with high frequency (small scale) is constructed. More specifically, the indexis defined by

N t n

t )(

)(

(4)

where N is the total number of significant coefficients in chosen the strip (time scale)and n(t) is the number of coefficients greater than the adopted threshold. Hereafter, ζwill be referred to as the wavelet index and its values lies in the interval [0,1]. Actual

observations of the stock market indicates that close to 1 indicates the possibility of acrash or drawdown, while close to 0, signals that the market is likely to maintain itscurrent trend. In the Table-1 is possible to see the historical results since 2004 to 2008for the wavelet index . The column "crash" shows the BOVESPA index quotation(Ibovespa points). The column "days" indicate duration (days) of drawdown of Ibovespaafter the alert signaled by the index . Finally the column "%" shows the percentage offall after the alert signal.

Date ζ Crash Days %

01/12/2004 1.0 24236-17604 84 -2703/04/2005 1.0 29197-23887 50 -1805/08/2006 1.0 41515-35791 11 -13.712/22/2006 0.2260 43355-42006 9 -3.107/12/2007 1.0 57613-48015 24 -1610/17/2007 1.0 63193-60894 2 -3.611/05/2007 1.0 62959-59069 13 -612/20/2007 0.9110 61716-53709 17 -1305/06/2008 1.0 70195-56869 60 -19

Table-1 Drawdowns and crashes (IBOVESPA-Brazilian Stock Index)

Page 6: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 6/12

In the Figure 3 one can observe the graphs with indications of and Ibovespaquotation in the time interval encompassing the 2008 financial crisis. In May-2008, fewmonths before the bankruptcy of Lehman-Brothers, the index approaches the value1.0 indicating the possibility of an abrupt change in Brazilian stock market.

Figure 3 Ibovespa prior to 2008 crash (left axis) and Wavelet Index (in the right axis). Thelower graph is the scale time representation of the coefficients obtained using waveletdecomposition (lighter grey corresponds to greater values of the coefficients).

The small inserted graph in Figure 3, shows the scale time representation ofthe coefficients of the wavelet decomposition (lighter grey corresponds to greater valuesof the coefficients). In the Figure 4 is possible to see the level curves of waveletdecomposition, where the open rectangle to the right indicates the moving region in the{scale,time} plane used to compute the index to the same period of Figure 3.

Page 7: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 7/12

Figure 4 The graph shows the level curves of the values of the wavelet coefficients. Thewavelet index is determined by counting the number of coefficients with values that are greaterthan a convenient threshold and that lie in the moving vertical strip (rectangle to the right).

4. Case study

The case study presented here considers data of prices from main nine shares ofBrazilian firms in 2010. More specifically, the shares are: PETROBRAS (Petr4),VALE (Vale5), USIMINAS (Usim5), GERDAU (GGBR4), ITAU (ItuB4), OGX(OgxP3), BRADESCO (Bbdc4), GOL (Goll4) and CIELO (Ciel4).

The top graph in Figure 5 shows the data window of interest in terms of fourshares (PETROBRAS, VALE, USIMINAS and ITAU). The bottom graph in Figure 5shows the wavelet index ζ , which can be associated with the recommendation to sellevaluated using stock market index Ibovespa. The wavelet index ζ computed using

actual data from Ibovespa. An analogous complementary index can also be defined tosignal recommendation to buy (details in Caetano and Yoneyama, 2009). This index is represented in the bottom graph of figure 5 with dashed lines but with small length.

Page 8: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 8/12

Figure 5 The upper graph shows four of the most important stocks included in Ibovespa(normalized stock market indices). The bottom graph shows the wavelet indices (solid line,related to "sell" recommendation) and (dashed line, related to "buy" recommendation).

The vertical solid line marks the date April 12 th 2010 when investors startedselling shares, reacting to the news of debt crises in Greece and Europe. Figure 6 shows

the network graphs corresponding to 4 different instants during the evolution of the prices to the time period represented in Figure 5 in 2010. The time window was set to30 and the threshold to 5.9 ( window_size = 30 and thr = 5.9 ). At time k = 30 , togetherthe indication of abrupt changes by the wavelet index , the network is seen to bestrongly connected. At time k = 60 , just before the beginning of the tendency to fall, thenetwork becomes weakly connected and even a disconnected node (ITAU, ItuB4) butwith index strongest in 0.86. However, at time k = 90 , when the tendency to fall ismaintained, the network becomes strongly interconnected, indicating that a criterion

based only on the graph theory may not suffice. On the other hand, the wavelet index

signals the occurrence of a possible change around k = 70 , which is consistent with theincrease in the slope of the curves starting at about k = 60 . At time k = 90, the networkrecovers the pattern of interconnection, similar to that observed before the crisis and signals possibility buy.

0 20 40 60 80 100 120 140 160 1800

50

100

150

Time [days]

Q u o t a t i o n

Petr4

Vale5Usim5Itub4

0 20 40 60 80 100 120 140 160 1800

0.5

1

Time[days]

W a v e l e t I n d e x

apr 12, 2010

Sell

Buy

Page 9: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 9/12

Time = 30, max = 5.9 Time = 60, max = 4.2

Time = 90, max = 7.4 Time = 150, max = 4.3

Figure 6 Graph representation of the network formed by the various financial indices atdifferent times in the interval used in the abscissa of Figure 5 (top and bottom).

Because it is not practical to draw graphs for large networks and evaluate it byvisual inspection, a simple numerical indicator can be proposed with basis on themaximum eigenvalue max of the adjacency matrix. Considering max_full the maximumeigenvalue of the fully interconnected network (i.e., cij = 1 for all i j ), the new index (k) at time k is defined by

Page 10: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 10/12

fullmax_

max )k ()k (

(1)

where max(k) is the maximum eigenvalue of the adjacency matrix of the network at

time k .Provided that (k), (k) and (k) are available simultaneously , one can produce

recommendations such as those summarized in Table 2. If one were to use only thewavelet index , he would wait until about time k = 70, when becomes greater than 0.7, in order to make a decision . In principle, because (k) is an increasing sequence inthe interval k [40, 70], it would be possible to extrapolate the value of (k) for k >40, using a trending tool together with the data for k [40, 70]. However, even in thiscase, one would not have information on the network as a whole and, moreover, a delayof 10 would be experienced. Now, if one also observes the information provided by the

index based on graph theory, (k), he can anticipate with greater certainty, a change inthe market and sell his stocks. This is also the case for (k) at [90, 100].

k max(k) (k) ζ(k) (k) Recommendation

30 5.9 0.79 0.73 0.0 Sell

60 4.2 0.56 0.86 0.0 Sell

90 7.4 1.00 0.62 0.16 Buy

150 4.3 0.58 0.87 0.0 Sell

Table 2: Recommendations based on both, index based on graph theory (k) and waveletindices ζ(k) and (k).

5. Conclusion

In a previous work, the authors had proposed a numerical indicator that couldsignal the imminence of changes in the stock market, using the wavelet decompositiontechnique. However, this indicator is computed using only the information content of asingle time series. In order to take into account a larger picture, involving several timeseries, the concept of network was introduced by means of tools borrowed from thegraph theory. The nodes of the network represent stock market indices and the links

between pairs of nodes are considered to exist if they are strongly correlated.Experimentations with a variety of financial time series indicated that the combinationof the numerical indicator based on wavelet theory (which detects the strong presence ofhigh frequency components in the time series) with a measure of the connectivity of the

network (related to the maximum eigenvalue of the adjacency matrix) produces sharper

Page 11: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 11/12

results. In order to illustrate the methodology a case study involving twelve stockmarket indices was presented.

ACKNOWLEDGEMENTS

The authors are grateful to CNPq – National Council for Research andDevelopment of Brazil for partially funding the project that lead to the presented results(grants 0686/05 and 301413/2010-0). The authors are also grateful to FAPESP -Fundação de Amparo à Pesquisa do Estado de São Paulo .

6. References

[1] Haldane, A. G. Rethinking the Financial Network . Bank of England. Speechdelivered at the Financial Student Association. Amsterdam. April 2009. Available in"##$%&&'''()*+,-./+01*+2(3-(4,&$4)153*#5-+6&3*1/+2*7&899:&*$751("#; . Accessed 2011.

[2] Haldane, A. G and May, R. Systemic risk in banking ecosystems. Nature . Vol. 469,Jan. 2011. 351-355

[3] (a) Onnela, J.P.; Chakraborti,A.; Kashi,K.; Kertész,J.; Kanto,A. Asset trees and assetgraphs in financial markets. Physica Scripta . Vol. T106, 2003. 48-54.

[4] (b) Onnela, J.P.; Chakraborti,A.; Kashi,K.; Kertész,J. Dynamic asset trees and BlackMonday. Physica A . Vol. 324. 2003. 247-252.

[5] Onnela, J.P.; Kashi,K.; Kertész,J. Clustering and information in correlation basedfinancial networks. Eur. Phys. J. B. Vol. 38. 2004. 253-362.

[6] Estrada, E.; Fox,M.; Higham, D. J.; Oppo, G.L. Network Science-Complexity in Nature and Technology . Springer. 2010.

[7] May, R. Stability and Complexity in Model Ecosystems . Princeton University Press.1974.

[8] Bornholdt, S.; Schuster, H. G. Handbook of Graphs and Networks - From genome tothe Internet . WILEY-VCH. Berlin. 2003.

[9]Junker, B.H. Analysis of Biological Networks. WILEY-INTERSCIENCE. NewJersey. 2008.

[10] Sornette, D. Why Stock Markets Crash . Princeton University Press, 2003.

Page 12: Finance - Grapth Theory

8/10/2019 Finance - Grapth Theory

http://slidepdf.com/reader/full/finance-grapth-theory 12/12

[11] Sornette, D.; Johansen, A. A hierarchical model of financial crash. Physica A , 261,

1998, pp. 581-598.

[12] Sornette, D.; Johansen, A. Large financial crashes. Physica A , 245, 1997, pp.411-

422.

[13] Sornette,D.; Johansen A.; Bouchaud, P. Stock market crashes, precursors and

replicas. J. Phys. I , France, No. 1, 1996, 167-175.

[14] Johansen, A. Characterization of large price variations in financial markets.Physica A , 324, 2003, pp.157-166.

[15] Johansen a, A. Sornette, D. Finite-time singularity in the dynamics of the world population, economic and financial indices. Physica A , 294, 2001, pp. 465-502.

[16] Johansen b, A. Sornette, D. Bubbles and anti-bubbles in Latin American, Asian, andWestern stock markets: An empirical study, International Journal of Theoretical and

Applied Finance, Vol. 4 , No.6, 2001, pp. 853-920.

[17] Rappoport, P; White, E.N. Was the Crash of 1929 Expected?, The American Economic Review. Vol. 84. No. 1. Mar.1994. pp 271-281.

[18] Rappoport, P; White, E.N. Was There a Bubble in the 1929 Stock Market? The Journal of Economic History . Vol. 53. No. 3. Sep. 1993. pp 549-574.

[19] Caetano, M.A.L, Yoneyama, T. Characterizing abrupt changes in the stock prices

using a wavelet decomposition method. Physica A . 383. 2007. 519-526.[20] Caetano, M.A.L, Yoneyama, T. A new indicator of imminent occurrence ofdrawdown in the stock market. Physica A . 388. 2009. 3563-3571.

[21] Junker, H.H.; Schreiber, F. Analysis of Biological Networks . John Wiley &Sons.2008.

[22] Daubechies, I. Ten Lectures on Wavelets . SIAM, Philadelphia, 1992.

[23] Meyer, Y. Wavelets - Algorithms and Applications . SIAM, Philadelphia, 1993.

[24] Vitali, S.; Glattfelder, J.B.; Battiton, S. The network of Global Corporate Control,PloS ONE , Vol. 6, No. 10, e25995, 2011.