Performance of TAIEX during Chinese New Year

Return of TAIEX before & after Market Closure Period



Chinese New Year is the most important festival of Chinese society. Traditionally, it is the genuine year-end. Stock market participants would conclude market performance in past year and begin the project targeting upcoming year. Therefore, this article would take Chinese New Year as the subject, discussing the performance of TAIEX during this period. To boot, we would apply event study on individual stocks and take past-and-upcoming 5 day as the event period so as to calculate the anomaly return.

Note:Stocks that this article mentions are just for the discussion, please do not consider it to be any recommendations or suggestions for investment or products.

Editing Environment and Modules Required

MacOS & Jupyter Notebook

# Basic
import pandas as pd
import numpy as np# Statistics Calculation
from sklearn.linear_model import LinearRegression
from scipy import stats# TEJ API
from datetime import datetimeimport tejapi
tejapi.ApiConfig.api_key = 'Your Key'
tejapi.ApiConfig.ignoretz = True


Unadjusted Stock Price(daily):Listed securities with unadjusted price and index. Code is ‘TWN/APRCD’.

Security Attribute:Listed securities with industry domain. Code is ‘TWN/ANPRCSTD’.

Security Basic Information:Listed securities with basic information. Code is ‘TWN/AIND’.

Performance of TAIEX

Step 1. Data Selection

twn = tejapi.get('TWN/APRCD',
coid = 'Y9997',
mdate = {'gte': '2008-01-01', 'lte':'2021-03-30'},
opts = {'columns':['mdate', 'roia']},
paginate = True,
chinese_column_name = True)

We get Return Index(Y9997) and set the period from 2008/01/01 to 2021/03/31 so as to ensure that it covers all the Chinese New Year period in each year.

Step 2. Import Last Trading Date before Market Closure & Match It with Date of Market Data

# Last trading date in every year 
last_day = ['2008-02-01', '2009-01-21', '2010-02-10', '2011-01-28', '2012-01-18', '2013-02-06', '2014-01-27', '2015-02-13', '2016-02-03', '2017-01-24', '2018-02-12', '2019-01-30', '2020-01-20', '2021-02-05']# Ensure that last_day is "date" data type. We transfer it to datetime item.
last_day = [datetime.fromisoformat(i) for i in last_day]# Match last trading date with market data
date = []
for i in last_day:
date.append(int(twn[twn['年月日'] == i].index.values))

Step 3. Calculate Return of market closure date along with pre-and-post 15 and 5 day period.

market = pd.DataFrame(columns = ['前十五日累計報酬', '前五日累計報酬', '封關日報酬', '後五日累計報酬', '後十五日累計報酬' ])for i in date:

# Pre 15-day cumulative return
market.loc[i, '前十五日累計報酬'] = ((twn.loc[i, '收盤價(元)'] / twn.loc[i-15, '收盤價(元)']) - 1) * 100

# Pre 5-day cumulative return
market.loc[i, '前五日累計報酬'] = ((twn.loc[i, '收盤價(元)'] / twn.loc[i-5, '收盤價(元)']) - 1) * 100

# Market Closure date return
market.loc[i, '封關日報酬'] = ((twn.loc[i, '收盤價(元)'] / twn.loc[i-1, '收盤價(元)']) - 1) * 100

# Post 5-day cumulative return
market.loc[i, '後五日累計報酬'] = ((twn.loc[i+5, '收盤價(元)'] / twn.loc[i, '收盤價(元)']) - 1) * 100

# Post 15-day cumulative return
market.loc[i, '後十五日累計報酬'] = ((twn.loc[i+15, '收盤價(元)'] / twn.loc[i, '收盤價(元)']) - 1) * 100

Step 4. Calculate Average Margin of Up-and-Down & Up-and-Down Situation

for i in range(0,5):
data['平均漲幅'][i] = market.iloc[:, i].mean()

pos = list(filter(lambda x: (x > 0), market.iloc[:,i]))
data['上漲次數'][i] = len(pos)
data['上漲機率'][i] = len(pos) / len(last_day)
data['上漲平均漲幅'][i] = np.mean(pos)

neg = list(filter(lambda x: (x < 0), market.iloc[:,i]))
data['下跌次數'][i] = len(neg)
data['下跌機率'][i] = len(neg) / len(last_day)
data['下跌平均跌幅'][i] = np.mean(neg)

Based on above chart, we would find that there is a down trend during pre 15-day trading period. As for the period after Chinese New Year, it shows that TAIEX performs well, overall. These circumstances caused by that market participants tend to sell current position to avoid impact of incident during market closure. After the closure, they buy more position as starting new plans.

Event Study — Pre Closure

Note:If you are not familiar with event study. Please firstly read 【Quant(6)】 Event Study — The Announcement Impact of Seasoned Equity Offerings on Stock Returns.

Step 1. Get Code of Common Stocks

security = tejapi.get('TWN/ANPRCSTD',
mkt = 'TSE',
stypenm = '普通股',
opts = {'columns':['coid','mdate','stypenm','mkt']},
paginate = True,
chinese_column_name = True)tse_stocks = security['證券碼'].tolist()

Step 2. Event Studt Process(Programming is available at Source Code)

  1. Based on data within ‘Estimate Window’ , 251 trading day each year, we construct Fama/French 5 Factor Model.
  2. Apply above 5 Factor Model to forecast returns in ‘Event Window’ , which covers pre-and-post 5 trading day.(11 day in total, containing closure date)
  3. Get the anomaly return by that actual return minus forecast return. Calculate the cumulative anomaly return.

Step 3. Test Significance of Anomaly Return during Pre-Closure

We apply t-test and P-value to test the significance.

pre_close = pd.DataFrame()for stock in tse_stocks:

# Take the closure date as basis to calculate anomaly return
df = test[test['證券代碼'] == stock].reset_index(drop=True)
df = df[df['相對天數'] == 0]

# Delete stocks with too little sample amount
if len(df) < 4:
print(stock, 'has no enough data')

sample = df['累計異常報酬率'].values

# Test
t, p_value = stats.ttest_1samp(sample, 0)
if p_value <= 0.01:
significance = '***'
elif 0.01 < p_value <= 0.05:
significance = '**'
elif 0.05 < p_value <= 0.1:
significance = '*'
significance = ''

pre_close = pre_close.append(pd.DataFrame(np.array([stock,t,p_value, significance]).reshape((1,4)), columns = ['證券代碼','T檢定值', 'P-value','顯著水準'],)).reset_index(drop=True)

We use the most rigorous standard(P-value < 0.01) to select stocks with significant anomaly return.

result = pre_close[(pre_close['T檢定值'] > 0) & (pre_close['P-value'] < 0.01) ].reset_index(drop=True)

Step 4. Calculate ‘Daily’ Anomaly Return

Firstly, calculate the average anomaly return delaying n period in each year. For example, the average anomaly return of pre-5, pre-4 and pre-3 day separately . Subsequently, aggregate the average cumulative return from pre-5 day to closure date.

# Average Anomaly Return
for i in range(-5, 1):
result['第' + str(i) + '天平均異常報酬'] = test[test['證券代碼'].isin(positive_list) & (test['相對天數'] == i)].groupby('證券代碼')['異常報酬率'].mean().reset_index(drop=True)# Aggregate the period cumulative anomaly return
result['期間累計平均異常報酬率'] = test[test['證券代碼'].isin(positive_list) & (test['相對天數'] == 0)].groupby('證券代碼')['累計異常報酬率'].mean().reset_index(drop=True)

Step 5. Merge above Chart with Basic Information Table(TWN/AIND)

result['公司中文簡稱'] = ''
result['TEJ產業名'] = ''
result['TEJ子產業名'] = ''for i in range(len(positive_list)):
firm_info = tejapi.get('TWN/AIND',
coid = positive_list[i],
opts = {'columns':['coid', 'inamec', 'tejind2_c', 'tejind3_c']},
chinese_column_name = True,
paginate = True) result.loc[i, '公司中文簡稱'] = firm_info.loc[0, '公司中文簡稱']
result.loc[i, 'TEJ產業名'] = firm_info.loc[0, 'TEJ產業名']
result.loc[i, 'TEJ子產業名'] = firm_info.loc[0, 'TEJ子產業名']

According to the attribute of these 3 companies, we find that corporations with the most significant anomaly return pre closure are industrial-related or manufacturing stocks.

Event Study — Post Closure

The process of post closure is quite similar to that of pre closure. What we should change is the event period, in coding, from -5 to +5. Considering the length of this article, we just present the result.(Complete process is available at Source Code)

Above chart shows that industrial-related stocks maintain the status of owning the most significant anomaly return during post closure period.

Note:Stocks that this article mentions are just for the discussion, please do not consider it to be any recommendations or suggestions for investment or products.


Firstly, we analyze market participant’s attitude toward market closure by the performance of TAIEX return. With above content, you would notice that there is a lightly short period during pre closure and a majorly long one after the closure.

Secondly, we apply event study to find stocks with anomaly return. In this part, you would find that industrial-related companies have the most significant anomaly return. We consider that the situation is derived from both the increasing demand for fundamentally industrial processed product and decline of metal price during late February and early March, so market participants, then, expect the revenue would increase and cost of manufacturing goes down, therefore, long these stocks.

Last but not least, please note that “Stocks this article mentions are just for the discussion, please do not consider it to be any recommendations or suggestions for investment or products.” Hence, if you are interested in issues like Event Study, welcome to purchase the plans offered in TEJ E Shop and use the well-complete database to find the potential event.

Source Code

Extended Reading

Related Link