The relationship between the yield rate of U.S. bonds and Taiwan stocks

Analyze the relationship between U.S. Treasuries and different types of Taiwan stocks.

Photo by Alina on Unsplash


  • Difficulty:★☆☆☆☆
  • We use the regression model to find the relationship between the change in the yield of U.S. Treasuries and the Taiwan stock market, electronic stocks, financial stocks, and high dividend stocks.
  • Advice: In terms of models, this article will not delve into the architectural composition, only analyze the information that the model results let us understand, so readers need to have a basic concept of the statistical model; in addition, the fund target mentioned in this article is for illustrative purposes only and does not represent any financial product recommendation or recommendation.


Raw material prices soaring, inflation and interest rate increases are the main issues in the financial market this year. The news media often report that the recent decline in Taiwan’s stock market is related to international capital flows, so this article takes this as a starting point to analyze the relationship between Taiwan’s stock market and the U.S. bond yield through statistical methods.

The Editing Environment and Modules Required

This article uses MacOS and uses Jupyter Notebook as the editor.

# Basic
import numpy as np
import pandas as pd# TEJ API
import tejapi
tejapi.ApiConfig.api_key = 'Your Key'
tejapi.ApiConfig.ignoretz = True


General Economic Statement Table: The description table is used for the accounts of the overall economic table. The data code is (GLOBAL/ABMAR).

Overall Economic TableThe overall economic indicators issued by the government department. Including the IMF and OECD, as well as related professional publications. The data code is (GLOBAL/ANMAR).

Listed (Counter) Adjusted Share Price (Monthly) — Ex-Dividend Adjustment: Monthly Information on Listed Securities and Indices (TSE and OTC). The data code is (TWN/AAPRCM1).

U.S. Debt Yield Ratio

Step 1. Read the data name and code id

factor_macro = tejapi.get('GLOBAL/ABMAR',
opts={'columns': ['coid','mdate', 'ename', 'freq']},
paginate=True)select_1 = list(factor_macro['ename'][i] for i in range(0,6214) if 'Yeild' in factor_macro.iloc[i,2])

The above process begins by reading the names of all the general economic database data and setting conditions in Chinese. We use the name contains “殖利率”(yield) to Filter out the “美國十年期公債殖利率”(yield rate of the United States 10-year Treasury).

factor_macro[factor_macro['ename'] == '10 Years Government Bond Yields(Long Term) - U.S.A.']

By setting the condition of the full Chinese name, we can find the data’s coid(code id) — CA15.

Step 2. Read the U.S. Treasury yield data

yield_10yr = tejapi.get('GLOBAL/ANMAR',
mdate={'gte': '2020-01-01', 'lte':'2022-03-01'},
opts={'columns': ['mdate', 'val']},
coid = 'CA15',
yield_10yr = yield_10yr.rename(columns = {'數值':'yield_10yr'})

Taiwan stock data

Step 1. Read indexes, fund remuneration data

index_list = ['Y9997', '0053', '0055', '0056']index_data = tejapi.get('TWN/APRCM',
coid = index_list,
mdate= {'gte': '2020-01-01', 'lte': '2022-03-01'},
opts={'columns': ['coid', 'mdate', 'roi']},
paginate = True,
chinese_column_name = True)

This article selects the Y9997 remuneration index as a representative of the Taiwan stock market. 0053 is a fund for electronic stocks; 0055 is a financial stock fund. Furthermore, 0056 is a high-dividend stock fund.

Note: 0056 is not a pure conventional industry fund; its main constituent stocks also contain high yield targets in electronic shares.

Step 2. Data Arrangement.

index_data = index_data.set_index('年月')roi = {}for i in index_list:
r = index_data[index_data['證券代碼'] == i]
r = r['報酬率%_月']
roi.setdefault(i, r)roi = pd.concat(roi, axis = 1).reset_index()

Model adaptation process

Step 1. Data Consolidation

final = pd.merge(roi, yield_10yr, how = 'inner', on = ['年月'])
final = final.rename(columns = {'Y9997':'台灣大盤', '0053':'電子股', '0055':'金融股', '0056':'高股息'})

Step 2. Model Adaptation

import statsmodels.formula.api as smf
from statsmodels.stats.anova import anova_lmfor i in list(final.columns)[1:5]:
data = pd.DataFrame(final[[i, 'yield_10yr']])
mdl = smf.ols(i + ' ~ yield_10yr', data=data).fit()

First, the names of each type of index or fund in the final table are obtained through “list ( final.columns ) [ 1:5 ]” and then put into the for-loop. Take each U.S. 10-year Treasury yield for adapting, and the following will explain the model results one by one.

The model results illustrate.

First, we can see the interpretation variable column of the 10-year bond yield (the red box). In the coefficient column, you can know that the two data are negatively correlated; and by the P value of 0.169, you can confidently judge that its role in the Taiwan stock market is not significant; in addition, the R² (the blue box) of 0.074 also indicates that the interpretation ability is quite insufficient.

In the interpretation variable field (the red box), it can be understood that the two data are also negatively correlated, and the P value of 0.042 can be judged that the performance of the U.S. Treasury yield on Taiwan electronic stocks is significant. However, it does not reach the highest standard of 0.01, so considering the R² (the blue box) is 0.156. It is inferred that the explanatory variable has a slight explanatory strength.

In the interpretation variable field (the red box), it can be understood that the two data are positively correlated; and the P value of 0.357 can be confidently judged that its effect on the Taiwan stock market is insignificant. In addition, the R² (the blue box) of 0.034 also indicates that the interpretation ability is quite insufficient.

In the interpretation variable field (the red box), it can be understood that the two data are negatively correlated; and the P value of 0.622 can be confidently judged that its role in the Taiwan stock market is insignificant. In addition, the R² (the blue box) of 0.010 also indicates that the interpretation ability is quite insufficient.


Through the above model results, I believe that readers can know that in addition to electronic related stocks, the interpretation ability of U.S. treasury yields for Taiwan’s broader market, financial stocks, and high dividend targets has not reached a certain level. However, this does not mean that Taiwan stock investors can ignore the overall economic or monetary policy of the Federal Reserve. After all, as a world economic leader, its general economic situation and the central bank’s attitude will still affect the flow of international funds. Taiwan is absolutely no exception because the central axis of Taiwan’s industrial development is electronic technology stocks. The impact of U.S. bond yields on this ethnic group can also be observed from the statements, which reminds us that in the environment of inflation and interest rate increase issues this year. As Taiwan stock investors, we need to pay more attention to the industrial and economic trends in the United States. Therefore, we welcome readers to continue to pay attention to this platform, and there will be more articles on the impact of the overall economy on the stock market. In addition, readers are also welcome to choose the plan in the TEJ E Shop. I believe that readers can quickly grasp the market trend after having a complete database.

Source Code

Extended Reading

Related Link