【Quant(14)】Which industries did three primary institutional investors invest in Taiwan?

How do the three primary institutional investors invest in Taiwan stocks?

Photo by Alexander Mils on Unsplash

Highlights

Preface

The three primary institutional investors are essential participants in the Taiwan stock market. Others investors use three direct institutional investors’ daily trading volume, cumulative trading volume, and the shareholding ratio of stocks to be a benchmark to invest. Therefore, we analyze the changes in the stock market value of the three primary institutional investors in the overall stock market and various industries. Then, we sort out the differences in industry preferences and investment strategies of the three direct institutional investors from 2015 to the present, hoping to inspire readers for transactions.

The remarks of the three primary institutional investors are as follows:

  1. Dealers mean Dealers’ proprietary accounts.
  2. Securities Investment Trust Companies mean domestic mutual funds managed by Securities Investment Trust Companies.
  3. Foreign Investors are defined by Regulations Governing Investment in Securities by Overseas Chinese and Foreign Nationals and Regulations Governing Securities Investment and Futures Trading in Taiwan by Mainland Area Investors.

The Editing Environment and Modules Required

Windows OS and Jupyter Notebook

# 功能模組
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Microsoft JhengHei'] # 解決 plot中文問題
plt.rcParams['axes.unicode_minus'] = False
#TEJ API
import tejapi
tejapi.ApiConfig.api_key = "your key"

Database Used

Data Processing

Step 1. Obtain data by TEJ API

We obtain the codes of listed companies that exclude the financial industry and depositary receipts from TEJ.

industry = tejapi.get("TWN/AIND",
paginate=True,
opts={'columns':['coid','mdate','mkt','tejinm4_c','tejinm3_c']},
chinese_column_name=True)
industry = industry[~industry['TSE新產業_名稱'].isin(['金融業','','存託憑證']) &
(industry['上市別'].isin(['TSE']))]
security_list = industry['公司簡稱'].tolist()

We obtain the market value of listed companies and the market value of the three primary institutional investors.

# TEJ為維持主機運行的穩定,總筆數單次最多為1,000,000筆。故我們可以將公司以50家分一組,以便迴圈分次撈取資料groups = []
while True:
if len(security_list) >= 50:
groups.append(security_list[:50])
security_list = security_list[50:]
elif 0 <= len(security_list) < 50:
groups.append(security_list)
break
market_value = pd.DataFrame()
for group in groups:
market_value = market_value.append(tejapi.get('TWN/APRCD',
coid = group,
mdate= {'gte': '2015-01-01','lte':'2021-01-19'},
opts={'columns':['coid','mdate','mv']},
chinese_column_name=True,paginate=True)).reset_index(drop=True)

data = pd.DataFrame()
for group in groups:
data = data.append(tejapi.get('TWN/ATINST1',
coid = group,
mdate= {'gte': '2015-01-01','lte':'2021-01-19'},
opts={'columns':['coid','mdate','qfiimv','fundmv','dlrmv']},
chinese_column_name=True,paginate=True)).reset_index(drop=True)

Step 2. Merging Data

We merge the corresponding industry name with the above company information.

data = pd.merge(data,industry, how='left', left_on='證券名稱', right_on='公司簡稱')
data = pd.merge(data,market_value, how='left', left_on=['證券名稱','年月日'], right_on=['證券代碼','年月日'])
data.head(10)

Step 3. Calculate the stock market value of the primary institutional investors.

We obtain the market value of TEJ’s three primary institutional investors. Then, we calculated the market value of the other, the other = all — (foreign investment + Investment Trust + Dealers) That is the sum of retail investors, directors, supervisors, corporate legal persons, the insurer, and private equity funds stock of market value.

# 計算籌碼持股市值
data['其他(百萬元)'] = data['市值(百萬元)'] - data['外資總投資市值(百萬)'] - data['投信持股數市值(百萬)'] \
- data['自營持股數市值(百萬)']
data = data[['證券代碼','TSE新產業_名稱', 'TEJ子產業_名稱', '年月日', '外資總投資市值(百萬)',
'投信持股數市值(百萬)', '自營持股數市值(百萬)','其他(百萬元)']]
# 改欄位名稱
data = data.rename(columns={'外資總投資市值(百萬)':'外資',
'投信持股數市值(百萬)':'投信',
'自營持股數市值(百萬)':'自營',
'其他(百萬元)':'其他'})

Data Visualization

Step 1. calculate the stock market value percentage of the primary institutional investors.

We can easily group the data through the groupby function to analyze the descriptive statistics under different groups. Then, we use the following code to group the dates and add up the stock market value ratios of the overall listed companies on each date.

The figure below shows that the proportion of foreign investors’ market value in Taiwan stocks has steadily increased since 2015. Even though foreign investors have traded over -447 billion since the beginning of 2021, the market capitalization of foreign investors is still nearly 40%. Investment Trusts and Dealers hold only a smaller percentage of the stock market value.

# 繪製籌碼持股市值百分比
figure_table1 = data.groupby(['年月日'])[['外資','投信','自營','其他']].sum()
figure_table1 = figure_table1.divide(figure_table1.sum(axis=1), axis=0)
fig, ax = plt.subplots(figsize = (14,8))
ax.set_title('籌碼持股市值百分比', fontsize=16, fontweight='bold')
ax.set_ylabel('Percentage', fontsize=12,rotation=0)
ax = ax.stackplot(figure_table1.index, figure_table1.T)
plt.legend(figure_table1.columns,loc=2, prop={'size': 12})
plt.show()
# 要反過來看圖例去對照圖形

Step 2. the primary institutional investors hold market value percentages in different industries.

The figures below show foreign investment, investment trust, and dealers from left to right. We find that foreign investment and investment trust have similar industry holding market value trends. However, foreign investment is more concentrated in the semiconductor industry than investment trust. Compared to the formers, dealers have relatively volatile industry holdings and similar market capitalizations in different sectors. It reflects their more flexible and short-term investment strategies.

Step 3. Foreign investments hold market value percentage in the semiconductor industry supply chain.

From 2015 to the present, the shareholding ratio of foreign investments in the semiconductor industry has increased from 40% to 70%. Therefore, we would like to further analyze the shareholding value of foreign money in the semiconductor industry chain through the sub-industries classified by the TEJ database. Among the 23 semiconductor sub-industries, foundry accounted for 80%, while 2330 TSMC accounted for more than 95% of the foundry.

Conclusion

60% of the market value held by foreign investors and investment trust companies is in the semiconductor industry. Although dealers also have a relatively high share of market value in the semiconductor industry, the overall sector holding market value has fluctuated dramatically, reflecting the flexible investment strategy of self-operated companies — short line operation. In addition, we also further analyzed the market value ratio of foreign investors in the semiconductor industry chain. We found that the layout of foreign investment in the industry stock selection reflects the 80/20 rule. The proportion of foreign investors holdings in the market value is mainly contributed by 2330 TSMC.

Finally, suppose readers are interested in analyzing primary institutional investors and industry grouping. In that case, readers are welcome to go to TEJ E-Shop to purchase a package combination that meets their needs.

Source Code

Extended Reading

Related Link

You could give us encouragement by …
We will share financial database applications every week.
If you think today’s article is good, you can click on the
applause icononce.
If you think it is awesome, you can hold the
applause icon until 50 times.
If you have any feedback, please feel free to leave a comment below.

--

--

--

新手上路|Rookie / 資料科學|Data Analysis / 量化分析|Quant / 實戰手冊|Application

Recommended from Medium

Understanding Variational Autoencoders (VAEs)

Basic Statistics of Events

Is COD Deficit really a deficit?

Machine Learning 101: Overview from Upstream Tech

How to use RSI in Your Trading System

5 Tips For Better Feature Engineering

A Practical Guide to Linear Regression

Why Data Scientists Need Unit Tests

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
台灣經濟新報(TEJ)

台灣經濟新報(TEJ)

TEJ為台灣本土第一大財金資訊公司,成立於 1990 年,專門提供金融市場基本分析所需資訊,以及信用風險、法遵科技、資產評價、量化分析及ESG等解決方案及顧問服務。鑒於財務金融領域日趨多元與複雜,TEJ 結合實務與學術界的精英人才,致力於開發機器學習ML、人工智慧AI及自然語言處理NLP等新技術,持續提供創新服務

More from Medium

【Application(10)】Pairs Trading

Vectorized Backtest of SMA Cross Strategy.

Data Mining Team Proof of Value, January 2022

Technical analysis of asset prices with Python