{'fraction_non_alphanumeric': 0.04603456630592796, 'fraction_numerical': 0.02406719431432725, 'mean_word_length': 4.669871794871795, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Detection of Bubbles in Tehran Stock Exchange Using Log-Periodic Power-Low Singularity Model

One of the essential factors that lead to severe disruptions in financial markets is price bubbles and subsequent crashes. Numerous models for detecting bubbles have been developed, one of which (LPPLS) has lately attracted considerable interest. This study aims to utilize this model to detect price bubbles in Tehran Stock Exchange's index (TEDPIX). Confidence multi-scale indicators for this model are presented by fitting the LPPLS model to the data of the TSE index from 2009 through 2020. The bubble is detected when the number of fits that are in our filter conditions increases which means the growth of the indicator's value. By applying this method on TSE data two significant crashes in 2013 and 2020 are detected. The proposed technique can be useful for market participants to detect financial crashes and bubbles.


Introduction
The capital market is one of the most essential parts of the economy . In this market, the formation of price bubbles and the subsequent fall of prices is considered as one of the most critical disorders (Koohi, et al, 2020). This phenomenon has always been regarded as an important topic for scientific centers such as universities and activists of these markets as well as policymakers (Namaki, Nazari, & Gaeeini, 2020). The importance of this issue comes from its impacts on society. (Hajihasani, et al, 2021) Bubbles can be classified in various ways (Blanchard, 1979). According to rational expectations theory, bubbles can be divided into rational and irrational ones (Diba & Grossman, 1982): A Rational bubble means that the current price of an asset is higher than its intrinsic value, but rational investors prefer to hold their assets or buy them if they do not possess the asset (Blanchard, 1979). On the other hand, Some Investors do not pay attention to intrinsic value and assume the price of an asset could consistently continue its growth (Johansen, 2003). They trade in a herding behavior approach and make irrational bubbles (Campbell et al, 1987).
Robert P. Flood and Peter M. Garber observed hyperinflation in Germany during the First World War through an article on the subject: "Market Fundamentals versus Price-Level Bubbles: The First Tests.". They concluded that by analyzing fundamental variables, bubbles cannot be detected. (Flood and Garber, 1979).
Stephen Leroy and Richard D Porter argued that the variance bound method can't explain the variations of the price from its intrinsic value. (Leroy and Porter, 1981). Bubbles cause violation at the variance bound but any violation does not essentially mean the bubble's existence (Blanchard and Watson, 1982;Tyrol, 1985).
Van Norden and Vigfusson attempted to detect bubbles by unit root test utilizing bubble switching models. (Norden et al, 1998).
Sornette et al proposed a new method named log periodic power law singularity (LPPLS) that can detect bubbles. By using this method, scholars have detected some major financial bubbles that prove the robustness of this model (Sornette, Johansen, and Bouchaud, 2000). In this paper, we have applied this model to detect bubbles in the TSE market.
The paper is organized as follows. Section 2 explains the LPPLS model. Section 3 and 4 present the findings of the research and the conclusion.

Research Methodology
The log-periodic power-law singularity (LPPLS) model We apply the LPPLS model on Tehran Stock Exchange as the leading capital market of Iran. This model assumes that the desired asset does not distribute cash profits. Market participants fall into two broad categories (Johansen, Ledoit, & Sornette, 2000): The first type is rational traders who mainly have the equivalent preferences and make decisions based on rational expectations (Sornette & Johansen, 1997). The second type is irrational traders, who trade more on the herding behavior approach. These people's inclination to buy and form bubbles ultimately leads to a critical point that provides the basis for the price falling (Sornette, Johansen, & Bouchaud, 1996). When a significant number of traders get a specific direction, there would be a sharp rise or fall in the price (Demirer, et al, 2019).
We assume that each of the traders is labeled with an integer "i" (Sornette & Johansen, 1998). The variable N (i) indicates the number of people in direct contact with a trader "i" . We suppose traders have two buying or selling positions in the market that are expressed With S i = +1, indicating trader's buy position, and S i = -1 indicating sell position for trader "i" (Sornette, Woodard, & Zhou, 2009).
According to this issue, for determining the trader's positions (buy or sell), the following equation is given (Sornette & Johansen, 1997): Equation (1) is a sign function. The first variable shows the effect of the network on its components (Johansen, Ledoit, & Sornette, 2000). The second variable illustrates the specific behavior of traders (Sornette & Johansen, 1997). The larger variable "k" means more effects from the network on the traders and more order in the network. (Johansen, Ledoit, & Sornette, 2000). Also, S j specifies person j position related to person "i". The second part of the sign function has σ indicates the position of person "i" based on her specific decision-making approach and ε is a random variable (Zhi-Qiang, et al, 2010).
We are trying to model the agents' interactions in the network. For this purpose, two models are used in the LPPLS model literature (Sornette & Johansen, 1998): In the Ising model, the effect of the network on its agents is negligible if the value of "k" is less than k c (a specific value) and the market will be in disorder condition (Johansen, Ledoit, & Sornette, 2000).
Equation (2) presents the vulnerability of the network in the Ising model: In this equation, "A" is a constant and positive value. "χ" has a value between 0 and +1 and it is named as "Vulnerability". The problem with the Ising model is that it supposes that the connections between network agents are identical (Sornette, Johansen, & Bouchaud, 1996). This is not a reasonable fact about financial markets that they have been composed of macro (such as pension funds) and micro (individual traders) agents. They have applied another approach known as the "Hierarchical diamond lattice model", which Johanson, Leddoit & Sornette (JLS) developed to model people's communication in various networks (Johansen, Ledoit, & Sornette, 2000). The difference between this approach and the Ising model is that the variable " χ " in the vulnerability equation will be a complex number. The new form of the vulnerability equation is presented as (Johansen, 2003): In this equation, "A 0 ", "A 1 ", and "w" are real numbers, and Re denotes the real part of the complex number (Sornette & Johansen, 2001).
One of the most important concepts that have greatly influenced the formation of the model is the "hazard rate". This rate is the probability of the occurring of a crash before it happens (Sornette & Johansen, 1997). The hazard rate can reach a certain point where many traders want to leave the market simultaneously. JLS assumes that the vulnerability variable behaves like the Hazard rate function h(t) near this critical point (Johansen, Ledoit, & Sornette, 2000;Johansen, Ledoit, & Sornette, 2000).
The LPPLS model is based on risk-neutral and rational expectations. In this situation, the Martingale process will produce the following price dynamics : They have presented a variable called J that could possess two values of +1 and 0 . The value of +1 demonstrates crash, while the value of 0 denotes there is no crash .
According to JLS (Johansen, Ledoit, & Sornette, 2000), the law of motion takes the following form: = μ(t) dt + Where μ (t) is the drift and σ (t) is the diffusion component of a standard Wiener process. Also, dj is representative of the jump process and in the crash state dj = +1 otherwise is equal to zero. K is a constant parameter that represents the size of the crash.
Then we will have the equation (6) : Assuming the arbitrage opportunity does not exist, we will have: Now, if the above equations are combined it is concluded: Where "A" is positive and equivalent to the critical point's price. "B" is a constant value that is less than zero (Sornette & Johansen, 1998). The value of "m" should be positive; thus, at the critical point, the price does not tend to infinity and has a finite value (Sornette, Johansen, & Bouchaud, 1996).
Parameter "B" must be greater than zero to fulfill the criterion that the price moves hyper-exponentially (Sornette & Johansen, 2001). There are limitations for other parameters of the model that have been achieved experimentally (Shu & Zhu, 2020).

Estimation of the model's parameters:
The variables C 1 and C 2 are defined as follows: By replacement of the variables the following equation is obtained: ln [p(t)] = A + B (tct) m + C 1 (tc − t) m cos (ω ln (tc − t)) + C 2 (tc − t) m sin (ω ln (tc − t)) (10) The price series must first be fitted to the model. For this purpose, one must first utilize a proper fit criterion named as the sum of squared error function as follows : The parameters (φ, ω, m, t c , C 1 , C 2 , B, A) must be calculated by minimizing the cost function . First, the central equation is revised as follows: Ln (p(t)) = A + Bf(t) + Cg(t) The model will be linear if we know the values of the four non-linear parameters and the following relationship is derived by partial derivation of the cost function on the linear parameters (Sornette, Woodard, & Zhou, 2009): They acquired the value of nonlinear parameters by applying the Levenberg Marquardt algorithm or Nelder-Mead simplex method .

The confidence multi-scale indicators for the LPPLS model:
Data fitting is conducted in numerous time windows in the LPPLS model (Zhi, et al, 2018). The LPPLS confidence indicator is defined as the ratio of fits with parameters within an acceptable range (filter condition) to all fits (Zhi, et al, 2018). Three periods are applied in this study, including short-term, mid-term, and long-term, to calculate the confidence indicator. The filter condition is based on :

Data analysis
It is considered the entire companies listed on the Tehran Stock Exchange from 2009 to 2020 and the required data was extracted from the Website of Tehran Securities Exchange Technology Management Co.
In the following, Fig-1 illustrates the fitting of the LPPLS model on data. As it is shown in Fig.2, the short-term indicator has consistently informed the existence of bubbles in the index at various periods. The number of times that short-term indicator is extremely high, is at "December 2012", "December 2013", "January 2017", "October 2016", "August 2017", as well as "March 2017", which illustrates the presence of bubbles throughout these historical periods. Except for "August 2019", all of these predictions are accurate and it is obvious the crashes with different sizes.

2) Mid-term indicator:
As illustrated in Fig.3, the mid-term indicator has delivered several signals of the bubble that exists in the index throughout the two periods. The first period starts in 2013 when the index ultimately crashed in January of that year. The second period begins in the year 2019-2020 which the value of the indicator constantly displays high numbers, indicating that the total index is in a bubble regime until it eventually crashed in "August 2020".  Fig.4 illustrates the long-term indicator similar to the mid-term one, indicating the existence of a bubble in the total index's value. The first period is one year prior to the index's crash in "January 2013", and this indicator consistently indicates that the index is in a bubble regime. The second period is one year before the historical "August 2020" crash, when this indicator has frequently warned of the presence of a bubble.

Conclusion
In this paper,we have applied the LPPLS model for detecting bubbles in the TSE market from 2009 to 2020. Using this model, we have constructed a multi-scale confidence indicator in three timeframes: short-term, mid-term and long-term. By using these indicators, we have found two major bubbles in Dec 2013 (Dey, 1392) and Aug 2020 (Mordad, 1399). Short-term and Mid-term indicators have detected more minor bubbles during this period.