Table of Contents
TEJToolAPI
into Pipeline
and use it in a strategy framework.In the dynamic landscape of today’s stock market, the activities of major investors often trigger significant price fluctuations. Among the various factors influencing these changes, the transfer of shares by directors and supervisors stands out. These insiders, armed with a profound understanding of the company’s operations, can wield substantial influence over its stock price. Consequently, when news of their share transfers surfaces, investors are quick to follow suit, aiming to capitalize on the resulting market swings.
As per the Taiwan Stock Exchange, the first quarter of 2024 witnessed a surge in market enthusiasm, with 4,879,506 individual investors engaging in transactions valued at less than NT$100 million, which is the highest in seven years. This trend, coupled with the stock market’s continuous ascent to new highs, underscores the importance of timing in market entry and the need to avoid purchasing at peak prices. To illustrate this, we will integrate the concept of insider share transfers with TQuant Lab, a powerful tool for backtesting strategies. This will allow us to thoroughly examine the performance of the Insider Transfer Strategy, shedding light on its potential benefits.
In this article, MSCI constituent stocks are used as the stock pool, and we select from the following insider transfer methods: general trading, block trading, and general trading combined with block trading. The insider transfer strategy is built and backtested using the following rules:
This article is written using Windows 11 and Jupyter Lab as the editor.
We first obtain MSCI constituent stocks by get_universe
function and TEJToolAPI.
With the backtest period set from May 2, 2019, to May 1, 2024, we then import the price and volume data of the 89 MSCI constituent stocks and the TAIEX-Total Return Index (IR0001) as the performance benchmark.
Here, we use the TEJToolAPI
to obtain the daily data of each stock’s transfer start date, transfer end date, and transfer method. Furthermore, we added a transfer column to indicate whether there was an insider transfer of general trading, block trading, or general trading combined with block trading on that day.
CustomDataset
allows us to import database content into Pipeline
, facilitating subsequent backtesting. In this implementation, we use it to import the daily transfer information recorded in the transfer column into Pipeline
. Part of the code is as follows:
from zipline.pipeline.data.dataset import Column, DataSet
from zipline.pipeline.domain import TW_EQUITIES
class CustomDataset(DataSet):
Transfer_Method_English = Column(object)
transfer = Column(bool)
domain = TW_EQUITIES
From the pipeline
and zipline
functions provided in TQuant Lab, we can:
pipeline
.pipeline
.Start Building Portfolios That Outperform the Market!
We use run_algorithm()
function to execute the configured Insider Transfer Strategy with the trading period from 2019-05-02 to 2024-05-01 and with the initial capital of 1,000,000 NTD. The output, or results, will represent the daily performance and detailed transaction records.
The table above shows that the insider transfer strategy achieved an annualized return of 19.348%. Additionally, the Sharpe and Sortino ratios are 1.22 and 1.75, respectively, as well as an alpha value of 0.06. This indicates that the insider transfer strategy can generate excess returns under the unit of risk taken and has a certain degree of capital protection capability during downside risks. Observing the chart, we can find that the strategy’s performance was slightly below the market index before April 2021. After that, it officially surpassed the market index performance. The reason is that initially, the strategy was still in the building phase, so its performance could have been better than the market. However, once the positions were established and combined with the RSI indicator for exits during overbought periods, it effectively avoided bear market risks and achieved performance that exceeded the market index.
The exposure chart of long and short positions helps us understand the use of capital in long and short positions. From the above chart, we can see that the insider transfer strategy was building positions in the early phase. By the end of 2021, it sold part of the holdings with the help of the RSI indicator, avoiding the bear market trend in 2022 to a certain extent.
This strategy is inspired by directors’ and supervisors’ stock transfers, aiming to explore whether buying stocks when these insiders report transfers can effectively time the market in a consistently rising market. By combining the timing of insider transfers with the RSI indicator, the strategy slightly outperformed the market in backtesting. However, it’s important to note that this example uses MSCI large-cap stocks, and results may differ with mid- or small-cap stocks. Additionally, investment amounts should be based on current stock trends and individual risk tolerance for more stable returns.
Please note that the strategy and target discussed in this article are for reference only and do not constitute any recommendation for specific commodities or investments. In the future, we will also introduce using the TEJ database to construct various indicators and backtest their performance. Therefore, we welcome readers interested in various trading strategies to consider purchasing relevant solutions from TQuant Lab. With our high-quality databases, you can construct a trading strategy that suits your needs.
“Taiwan stock market data, TEJ collect it all.”
The characteristics of the Taiwan stock market differ from those of other European and American markets, and the dynamics of retail investors are worth noting. Especially in the first quarter of 2024, with the Taiwan Stock Exchange reaching a new high of 20,000 points due to the rise in TSMC’s stock price, global institutional investors are paying more attention to the performance of the Taiwan stock market.
Taiwan Economical Journal (TEJ), a financial database established in Taiwan for over 30 years, serves local financial institutions and academic institutions, and has long-term cooperation with internationally renowned data providers, providing high-quality financial data for five financial markets in Asia.
With TEJ’s assistance, you can access relevant information about major stock markets in Asia, such as securities market, financials data, enterprise operations, board of directors, sustainability data, etc., providing investors with timely and high-quality content. Additionally, TEJ offers advisory services to help solve problems in theoretical practice and financial management!
Subscribe to newsletter