Market of Stocks during Crisis Looks Like a Flock of Birds

A crisis in financial markets can be considered as a collective behaviour phenomenon. The collective behaviour is a complex behaviour which exists among a group of animals. The Vicsek model has been adapted to represent this complexity. A unique phase space has been introduced to represent all possible results of the model. The return of the transaction volumes versus the return of the closed price of each share has been used within the defined phase space. The findings show that the direction of the resultant velocity vectors of all share in this phase space act in the same direction when the financial crisis happens. By monitoring the market’s collective behaviour, it will be possible to gain more knowledge about the condition of the market days in crisis. This research aims to investigate the collective behaviour of stocks using the Vicsek model to study the condition of the market during the days in crisis.


Introduction
The emergence of collective behaviour has been observed in many systems, such as schools of fish or flocks of birds. One of these systems' main properties is that the members move in the same direction without any leadership [1][2][3]. This behaviour exists to increase the chances of survival for the whole system. This behaviour can also be seen in financial stock markets. Independent firms are exposed to more business risk than similar firms that are in a joint group. Independent markets are more vulnerable and have fewer chances of survival in a financial crisis. Despite growing stronger being in a group for each member, it would itself be a major factor to spread a problem of each member within the whole group. One of the most important issues in businesses is the prediction of this significant shift during a financial crisis [4][5][6][7][8]. This has been considered in previous studies with a variety of approaches [9,10]. Computer-aided platforms have been used in the past to facilitate decision-making in financial markets. For example, high-frequency trading is carried out by powerful computers to analyse markets and buy or sell shares within seconds [11]. These platforms assume that the share price changes are fixed across various financial markets. This assumption is not valid if the market copes with financial crises. This is the main motivation of applying collective behaviour of birds and animals to the stock markets [12]. In order to consider the collective behaviour of stock markets, particle swarm optimisation (PSO) has been adapted in [13]. The algorithm was focused on choosing the parameters of trading strategy to predict price trends and to obtain the highest net return. Malekian et al. have shown that PSO and ant colony approaches are more effective than regression to predict financial crashes [14].
Thomas and Francisco [15] applied the collective behaviour of animals to the financial markets and used network theory to show the complexity of their acts. In science, significant efforts have been made to identify and understand the general principles governing collective behaviours [16][17][18]. These efforts have been unsuccessful due to the absence of equilibrium in such systems. The interactions between the particles of these systems are short-range. Therefore, the existing statistical physics techniques used for the long-range interaction of the particles are unable to express the system's dynamics. The Vicsek model (VM) has been applied to construct a framework for this study. The Vicsek model was first introduced [19] in 1995 to investigate the emergence of self-ordered motion in systems of particles with biologically motivated interaction. This model was further extended in 1999 [20] to demonstrate that a system of self-propelled particles (SPP) exhibits spontaneous symmetry breaking and self-organisation in one dimension. In 2000, Levin et al. proposed a model [21] in which he enhanced the scope of Vicsek by taking into account both attractive and repulsive forces. The Buhl model [22] (2006), which implies a modification of velocity weighting of the particles, approves rapid transition from the disordered movement of individual agents to highly aligned collective motion. In contrast to the formless and point-like particles described within the Vicsek model, Peruani attributed forms and packing coefficients to the agents [23]. There are many more models based upon Vicsek platforms such as Chate [24], Cocker-Smiley [25], Galam [26], and that of the work in [27]. The Vicsek model deals with a system of self-propelled particles. The basic idea in the Vicsek model is that at each time step, a given particle moves with a constant velocity. A new direction is obtained by the average direction of all the neighbourhood particles within a circle of the radius with including a random noise [28]. In other words, all the particles of the system tend to follow their neighbours' direction. However, the particles might change their directions while following their neighbours' trajectory, which is considered noise. Vicsek model has been proven to be effective for modelling collective behaviour with the ability to express such systems' dynamic states. Thus, the Vicsek model has been adopted to build the framework for this research. The dynamics of the stock market is a very complex problem. We used VM to take some snapshots at different times of a market to compare them. Thus, the Vicsek model has been adopted to build the framework for this research. Neither studying dynamics of the Vicsek model nor the stock market dynamics has not been considered.

The Validation of the Framework
To validate the proposed framework, the historical data of the Standard&Poor s 500 (S&P500) companies in the US stock market has been used. The S&P500 index, an index of the New York Stock Exchange, consists of the 500 largest companies in the US. It is a market value-weighted index (stock price times number of shares outstanding), with each stock's weight in the index proportionate to its market value. The S&P500 index is one of the most widely used benchmarks of US equity performance [29]. Our data covers 12 years (from January 2007 to February 2019) with a recording frequency of daily intervals. The data gathered from 465 stocks includes closing prices and transaction volumes.

Prototype Implementation
VM assumes that particles move in a two-dimensional plane with periodic boundary conditions. In this model, each particle's location is defined by X-Y coordinates, and a vector can obtain its velocity in the plane. The model assumes that the particles move with equal speed and the direction of the velocity vectors of particles changes as a function of time. The direction of each particle's motion depends on the average velocity, V n (t), of its neighbouring particles within a circle of radius r 0 . The model defines a circular neighbourhood area U n (r 0 , t) centered at the n-th particle position r n (t). The number of closed neighbours is shown as K n (t). According to the VM model, no interactions can occur for the n-th particle located outside the U n (r 0 , t). The average velocity of the neighbours of the particle n is calculated by: where ν j (t) denotes the velocity of j-th particle inside U n (r 0 , t). The Equation (1) is the sum of the velocities of each particle in the neighbourhood divided by the number of particles in that neighbourhood. Equation (2) shows the time evolution of the velocity angel of n-th particle, where ξ n (t) is a random variable uniformly distributed in the interval [−π,π], and η is the noise intensity, which is a positive parameter. Therefore, the velocity of n-th particle can be calculated by Equation (3) wherex andŷ denote X and Y direction respectively. Then, the position of n-th particle in the next time step is: At any time t, the magnitude of order in a system might be assessed through the order parameter Φ η (t) [30,31], which is expressed by: where the η indicates that the order parameter in the system depends on the noise intensity. Equation (5) is the magnitude of the sum of all the particle's velocity in the system divided by the total number of particles N by the value of the velocity ν 0 . This parameter must be in the interval [0, 1]; 0 if the velocity vectors are distributed randomly, and 1 if particles line up in the same direction.
To use the Vicsek model, a coordinate system is required to describe the movements of stocks in a market. Thus, X-Y values have been formulated as follows, where t takes just discrete values 1, ..., t − 1, t, t + 1, ..., P t is the closing price, and T t is the transaction volume at time t. The X-axis and the Y-axis of the coordinate system show the daily closed price difference and the difference in transaction volumes for two consecutive days. Based on VM, the density of particles has been considered as the main factor in collective behaviour. This research does not take into account how the market trend changes over a time period. Thus, the effect of the market trend on each stock has been neutralised using the following transformations, where µ x : moving average over 20 days, µ y : moving average over 20 days and σ x : moving standard deviation over 20 days and σ x : moving standard deviation over 20 days.
The new phase space can be generated from the above formula. The speed parameter for a daily stock can be calculated as follow, whereŝ x andŝ y are unit vectors along X-axis and Y-axis, respectively. Figure 1 represents the velocity vectors of all one-day stocks for three critical market days compared to the market's those of normal functioning of the market. Figure 1 compares the velocity vectors for normal days in the market (non-crisis) versus markets in crisis over three days for 465 stocks. It has been observed that during the non-crisis period, the stocks tend to move randomly. The direction of vectors has been highlighted with different colours in Figure 1. The direction of vectors in Figure 1 for markets in crisis shows the emergence of the collective behaviours. To differentiate the normal days from the days in crisis in the stock market, a value has been assigned to each day. The following steps are used to calculate this value.

1.
Drawing an imaginary circle and lay the start point of the velocity vectors of each share ν i (t) on the center of the circle.

2.
Dividing the circle into 12 equal slices and assigning a number to each of them, so each velocity vector is located in one slice.

3.
Mapping each share to one slice number. For example, the velocity vector of i-th share in the division l is shown as ν i l (t), where t denotes time. l can only accept integer values and it returns the number of the slice that velocity vector is located, and ∆θ is the degree of each slice which in this research assumed 30 degrees. l = θ i /∆θ . (9) l equals to the integer part of the right hand side of Equation (9). 4.
Coupling the joint shares. For example, if share i is in slice l and share j is in slice m, the return of the joint l-m or m-l will be considered. l-m and m-l are considered as one possible combination of joint shares. Therefore, the joint probability of both i and j to be placed in l and m divisions p( ν i l (t), ν j m (t)) equals 1.

6.
The distribution of these possible combinations of joint shares P t (l, m) can be obtained using Equation (10). The calculated P t (l, m) values for normal days vs. days in crises have been presented in Figure 2C.
Number of possible combinations of joint shares have been depicted in Figure 2B. The Y-axis values have been calculated using Equation (11).
In Equation (11), P t (l, m) only accepts non-negative values. When P t (l, m) equals to zero, Sign(P t (l, m)) returns zero. When P t (l, m) is greater than 0, Sign(P t (l, m)) returns 1. With this arrangement, the number of possible joint shares can be obtained. On a normal day in the market, 78 possible combinations of joint shares (l, m) can be found. This number can be significantly lower on a day in crisis. When the number is lower than 78, it also indicates that collective behaviour is emerging in the market. It means for some values of l and m, P t (l, m) equals zero. For each day, the number of l and m combination where P t (l, m) is greater than zero is counted. This number has been estimated for the trades happened all open days of 2018 and shown in the middle chart in Figure 2. We used the reference index of S&P500 to compare the calculated value from this research with the values listed in normal days in the market. This comparison has been depicted in Figure 2. Moreover, the distribution of possible combinations between joint shares in normal days has been compared with the same distribution during the market crisis ( Figure 2, the bottom chart).
Comparing the data from normal days against days in crisis in Figure 2 shows that the numbers of possible combinations for joint shares have decreased significantly during the days in crisis.
This research also illustrates how a time delay in the stock market can affect the emergence of collective behaviour. In Figure 3, the emergence of collective behaviour has been depicted for the duration of 8 days. The delay of one day has been assumed in calculations. To measure the alignment of the two velocity vectors, a value has been defined.

1.
The velocity vector of i-th share at time t is shown by ν i (t).

2.
The alignment of the velocity vectors of two separate shares can be calculated by Formula (12). The basis of this calculation is the cosine of the angle between the two velocity vectors. 3.
The stocks normally are correlated to each other. Thus, the change in one stock can affect the other stocks. This effect does not happen at once. Thus, we considered a delay for the calculations.
Equation (13) selects the maximum alignment factor between velocity vectors of two shares for two consecutive days. τ which is the added lag for alignment matrix calculations has been assumed 1 day.

4.
The alignment matrix has been constructed using calculatedã ij (t) in Equation (13). The alignment matrix has been generated using dendrogram to present the stocks which are grouped together.  The maximal alignment of pairs of stock vectors, when compared on the same day or with a one day lag.This plot has been generated using dendrogram and aligned shares have been grouped together. This graph shows that during the days in crisis one giant group of shares is shaped. This can be shown by a solid red color.

Conclusions
The results of empirical research show that the stock market during crisis days follows collective behaviour patterns. Days in crisis are affected by the price of shares and transaction volume fluctuations. Thus, it is crucial to define a phase space based on each share price and volume. The direction of the defined velocity vectors within the phase space can be used to identify the days in crisis. This phenomenon can be seen in the behaviour of biological systems, such as groups of animals. The Vicsek model has been used previously to investigate the collective behaviour in these systems. Suggested framework has shown the potential to represent this behaviour in the stock markets as well.
Raw data from S&P500 have been collected between 2007 and 2019. The collective behaviour has been discovered in some days in crisis. During these days, the direction of velocity vectors has been aligned as it was expected. An order parameter has been defined to compare the collective behaviour of the market during the crisis against normal days in the market. Using the data in S&P500, 24th of December 2018 has been identified as a crashed day. It is concluded that by analysing the market data before this date, it will be possible to identify the potential crisis in the days ahead.