Using the number of margin trading and short selling and volume to establish the herding indicators then analyze by regression model.
Keyword：Herding Indicators、Margin Trading、Application
Table of Contents
The emergence of behavioral finance has challenged the traditional view in investment theory that individuals make rational investment decisions. The “herd behavior” represents the tendency of investors to follow the crowd in the market. Retail investors often see others moving in a certain direction and blindly follow. It’s generally believed that retail investors are often the group that loses money in the market.
Defining retail investors in the market is typically done using data on margin trading and day trading volume. Due to regulatory restrictions and practical limitations, institutional investors tend to use less leverage and day trading. This article employs data from these two trading methods to create a new indicator representing the herding behavior of retail investors. It employs a simple regression model to ascertain whether retail investors truly act as a “contrarian indicator.” This approach aims to verify the relationship between the herd behavior and the performance of the Taiwan stock market.
We utilize the TEJ API data to create the herding indicator.
Adjusted Stock Prices (Daily) – Ex-dividend and Ex-rights Adjusted (TWN/APRCD1)
Margin Trading and Short Selling (TWN/AGIN)
Statistics of Day Trading (TWN/ADT)
Trading Volume, Day Trading Volume, Margin Buying Volume, Margin Selling Volume, Short Selling Volume, Short Covering Volume, and Market Index
Retrieve data from January 1, 2015, to October 13, 2022.
Constructing the Indicator:
We proceed to create the indicators with the following formulas:
Retail Investor Buying Formula = (Margin Buying Volume + Short Covering Volume) / (Trading Volume – Day Trading Volume),
Retail Investor Selling Formula = (Margin Selling Volume + Short Selling Volume) / (Trading Volume – Day Trading Volume).
Utilizing the Python Plotly package, we can create interactive charts that display the relationship between the retail investor indicator and the market index. This allows us to have a clearer view of the correlation between the retail investor indicator and the market index.
We zoomed in on the chart to observe the most anxious period of the pandemic in 2020. On March 19, the Taiwan stock market hit a new low in recent years, closing at 8681 points. The retail investor sell indicator also reached a new high for the period. Afterward, the stock market began to stabilize and steadily climb upwards.
Furthermore, we fetched the market index returns and shifted the retail investor buy and sell indicators by one period. This was done to establish a regression model.
The results indicate that both the retail investor buy indicator and sell indicator are positively correlated with market returns, which contrasts with the previously held belief that retail investors are a contrarian indicator. Additionally, the correlation between the sell indicator and the market has strengthened.
Next, we proceeded to construct a simple regression to examine the relationship between the buy indicator and market returns. From the results, it’s evident that the coefficient of the buy indicator is positive and statistically significant, indicating that the buy indicator can indeed predict market returns.
Moving on to the sell indicator, similar to the buy indicator, we observed that the coefficient is positive and statistically significant. This suggests that the sell indicator also possesses the ability to predict market returns.
From the results, we can see that our initial expectation of retail investors’ herding behavior as a “contrarian indicator” in buy and sell strategies doesn’t hold true. Specifically, when the buy indicator rises, the next day’s market return decreases, and when the sell indicator rises, the next day’s market return increases. However, the empirical findings indicate that both the buy and sell indicators are positively correlated with the market’s returns, thus challenging the assumption of the herding effect among Taiwanese retail investors.
This study utilized a simple regression approach. For readers interested in a more comprehensive exploration, it’s recommended to include more control variables and employ multiple regression methods for more accurate results.
This study employed TEJ API data and utilized Python to construct various indicators and back-test their performance. For the complete code and details on the database project, please refer to the link below.
TEJ Quantitative datasets allow decision makers to get access to accurate data in real-time and improve strategy performance:
• Avoid look-ahead bias and reduce inaccurate assumptions
• Finding effective factors that facilitate quantitative modeling
Assess to databank