Table of Contents
Warren E. Buffett adhered to rational investment principles throughout his lifetime. His Business Investment Rules stress investing with the mindset of acquiring a whole business rather than simply investing in stocks.
This article selects five critical stock selection criteria from Buffett’s Business Investment Rules. From utilizing TejToolAPI to fetch financial data and screen targets to using TQuant Lab to backtest investment risks and performance, we will explore Buffett’s investment style and appreciate the ability of Business Investment Rules to generate excess returns.
Because certain aspects of Buffett’s Business Investment Rules are non-quantifiable, we have chosen only the quantifiable stock selection criteria, all rooted in the underlying principle of a company’s ability to generate profits for its shareholders. The stock selection criteria are as follows:
This article is written using Windows 11 and Jupyter Lab as the editor.
By importing the basic packages and inputting the API key, we can access the TEJ financial database.
import os
import numpy as np
import pandas as pd
# tej_key
tej_key = 'your key'
api_base = 'https://api.tej.com.tw'
os.environ['TEJAPI_KEY'] = tej_key
os.environ['TEJAPI_BASE'] = api_base
Before we access the TEJ database, we use the get_universe()
function to get our stock pool. In this case, we have chosen ordinary shares listed by the end of 2015 while excluding highly leveraged financial industries.
from zipline.sources.TEJ_Api_Data import get_universe
pool = get_universe(start = '2015-12-31',
end = '2015-12-31',
mkt_bd_e = 'TSE', # listed stocks in TWSE
stktp_e = 'Common Stock',
main_ind_e = 'General Industry') # general industry can exclude financial industry
Then, we use TejToolAPI to collect the following financial items required in the Business Investment Rules.
Note: The cash flow from operating activities and the cash flow from investing activities can be used to calculate free cash flow.
import TejToolAPI
start_time = pd.Timestamp('2015-12-31')
end_time = pd.Timestamp('2022-12-30')
data = TejToolAPI.get_history_data(start = start_time,
end = end_time,
ticker = pool,
fin_type = 'A', # Cumulative data
columns = ['Industry_Eng', 'Return_Rate_on_Equity_A_percent', 'Gross_Margin_Rate_percent', 'Market_Cap_Dollars', 'Total_Retained_Earnings', 'Cash_Flow_from_Operating_Activities', 'Cash_Flow_from_Investing_Activities'])
After data analysis, we can obtain our final 17 targets that meet all the five stock-selecting criteria.
Build Profitable Investment Portfolios With Financial Data!
Next, we use TQuant Lab to execute a buy-and-hold strategy for the above targets for one year ( 2023 ) and observe the risk and return performance.
Data Period: January 1, 2023, to December 31, 2023
We import the price data of the 17 targets and the TAIEX-Total Return Index ( IR0001 ) to be the benchmark of our backtest.
start = '2023-01-01'
end = '2023-12-31'
os.environ['mdate'] = start + ' ' + end
os.environ['ticker'] = ' '.join(tickers) + ' ' + 'IR0001'
!zipline ingest -b tquant
On January 1, 2023, evenly allocate assets to purchase the targets and hold them until the end of the backtesting period.
We executed the configured Buy & Hold strategy with the trading period from 2023-01-01 to 2023-12-31 and with the initial capital of 10,000,000 NTD. The output, or results
, will represent the daily performance and detailed transaction records.
from zipline import run_algorithm
start_date = pd.Timestamp(start, tz = 'utc')
end_date = pd.Timestamp(end, tz = 'utc')
capital_base = 1e7
results = run_algorithm(
start = start_date,
end = end_date,
initialize = initialize,
handle_data = handle_data,
analyze = analyze,
bundle = 'tquant',
capital_base = capital_base,
)
results
From the chart above, we can see that in 2023, the overall market is bull, with a market return of around 30%. However, the targets selected by Buffett’s Business Investment Rules outperform the market by approximately 20 percentage points, achieving a cumulative return of 51.525%. Additionally, the portfolio’s Alpha value is 0.24, and the Beta value is 0.8, indicating that Buffett’s Business Investment Rules not only bear less systematic risk than the market but also generate excess returns.
Furthermore, we plotted the Sharpe ratio chart below to observe whether Buffett’s Business Investment Rules can achieve higher excess returns under the same level of risk exposure.
Observing the chart above, we can see that the Sharpe ratios of the portfolio based on Buffett’s Business Investment Rules mostly exceed the market, averaging around 2.4. Therefore, the Business Investment Rules indeed assist us in earning higher returns than the market under a certain level of risk.
In this implementation, we utilized the five primary stock selection criteria of Buffett’s Business Investment Rules, combined with TejToolAPI for fundamental stock selection. We then conducted a one-year backtesting performance analysis using TQuant Lab. From the analysis results, whether the return rate, Alpha, Beta, or Sharpe ratio, Buffett’s Business Investment Rules demonstrated excellent stability and the ability to earn excess returns. No wonder this set of principles has stood the test of time.
The author believes the remarkable aspect of Buffett’s Business Investment Rules is that many investors lose their rationality due to short-term market fluctuations, leading to premature exits and missing out on potential returns. In contrast, Buffett’s Business Investment Rules teach us that by carefully selecting outstanding stocks based on the profit characteristics of each company before investing and holding them for the long term, we can confidently achieve excess 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 backtesting to consider purchasing relevant solutions from TQuant Lab. With our high-quality databases, you can construct a trading strategy that suits your needs.
Subscribe to newsletter