【Application】F-score Strategy: Identifying Undervalued Quality Stocks

TEJ 台灣經濟新報
TEJ-API Financial Data Analysis
7 min readJun 26, 2024
F-score strategy
Photo by engin akyurt on Unsplash

Highlight

  • Article Difficulty:★★☆☆☆
  • Introduce the nine selection criteria of the F-score strategy.
  • Use Pipeline to filter stocks that meet the nine indicators of the F-score strategy and generate buy signals.
  • Backtest the quarterly rebalancing performance of the F-score strategy using TQuant Lab’s simplified backtesting engine, TargetPercentPipeAlgo.

Preface

In today’s stock market, investors face the challenge of choosing from many stocks, with many hoping to find undervalued stocks with solid fundamentals. However, market volatility and information asymmetry often make this goal difficult to achieve. In this context, the Piotroski F-score, also known as the Piotroski score or F-score, has become an important tool for investors.

Conceived by the esteemed former University of Chicago professor Joseph Piotroski, the F-score strategy is a comprehensive evaluation of nine financial report conditions. This strategy serves as a reliable guide for investors, providing a holistic view of a company’s financial health. It encompasses aspects of profitability, safety, and growth, offering a multidimensional analytical framework that enables investors to assess a company’s potential value more comprehensively. To delve into the performance of the F-score in the Taiwan stock market, this article utilizes TQuant Lab to construct the F-score strategy, thereby equipping investors with a deeper understanding of the investment benefits that the F-score can potentially unlock.

F-score Strategy

According to the paper by Professor Joseph Piotroski, to identify undervalued stocks with relatively stable profitability, safety, and growth, the F-score strategy is constructed through the following two steps to generate trading signals:

  1. Identify the top 20% of stocks in the market based on their Book-to-Market Ratio (BM Ratio).
    p.s. A higher BM Ratio indicates that the stock is more undervalued, as its trading price is lower than its asset value.
  2. Calculate the score based on the 9 fundamental criteria of the F-score. Each criterion met earns 1 point. We will buy stocks that score 8 or 9 and rebalance the portfolio quarterly.

The 9 fundamental criteria of the F-score strategy are as follows:

  • Profitability
  1. Return on Assets (ROA) > 0
  2. Current year ROA > previous year ROA
  3. Operating cash flow > 0
  4. Operating cash flow > net income after tax
  • Safety
  1. Long-term debt for the current year < previous year
  2. Current ratio for the current year > previous year
  3. No new shares issued in the previous year
  • Growth
  1. Gross margin for the current year > previous year
  2. Asset turnover ratio for the current year > previous year

Next, we will use TQuant Lab to generate the trading signals required for the F-score strategy.

Coding Environment and Module Requirements

This article is written using Windows 11 and Jupyter Lab as the editor.

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

Select Stock Pool and Trading Data Import

First, we obtain undervalued stocks through the following two steps:

  1. Use the get_universe function to obtain the stock symbols of all listed and OTC common stocks on May 6, 2019.
  2. Use the TEJ Tool API to get the Price-Book Ratio ( PB ratio ) of the above stocks to calculate the BM Ratio, thereby obtaining the top 20% of stocks by BM Ratio.
    p.s. PB Ratio and BM Ratio are reciprocals.

With the backtest period set from May 6, 2019, to December 31, 2023, we then import the price and volume data of the above 340 undervalued stocks and the TAIEX-Total Return Index (IR0001) as the performance benchmark.

Obtain Financial Data for the F-score Strategy

To calculate the financial criteria needed for the F-score, we use TEJ Tool API to fetch the following 9 financial data points:

  1. ROA: Return_on_Total_Assets_A_percent
  2. Operating cash flow: Cash_Flow_from_Operating_Activities
  3. Net income per share: Net_Income_Per_Share
  4. Outstanding shares (in thousands): Outstanding_Shares_1000_Shares
  5. Long-term debt: Total_Noncurrent_Liabilities
  6. Current ratio: Current_Ratio
  7. New shares issued (in thousands): Cash_Capital_Increase_Thousand_Shares
  8. Gross margin rate: Gross_Margin_Rate_percent
  9. Asset turnover: Total_Assets_Turnover

Import Financial Data into Pipeline

The CustomDataset class can import content from a database into Pipeline, facilitating subsequent backtesting. In this example, we use it to import the financial data we get from TEJ Tool API to calculate the F-score into Pipeline.

Create CustomFactor Functions

Before calculating the F-score, we use the CustomFactor function to define the following two factors:

  1. Calculate the YOY change of financial data.
  2. Convert the data passing the F-score criteria to 1 and those failing to 0, for calculating the F-score.

Create Pipeline Function

The Pipeline() function provides users with the ability to quickly process quantitative indicators and price-volume data of multiple stocks. In this case, we use it to handle:

  • Import stock price and financial data.
  • Calculate year-over-year ( YOY ) changes in financial data and annual average cash capital increase ( to determine if new shares were issued ).
  • Compute the F-score and generate trading signals in the “longs” column: True for F-score ≥ 8, False otherwise.
F-score strategy
Pipeline Results to be Used in Our Strategy

Backtest the F-score Strategy

Utilize TEJ’s simplified version of the Zipline backtesting engine, TargetPercentPipeAlgo, which allows all backtesting parameters to be set in a single line, requiring only the strategy pipeline input for execution.
p.s. For detailed usage instructions of TargetPercentPipeAlgo, please refer to TQuant Lab GitHub: Simple Algorithm-TargetPercentPipeAlgo

Parameters adjusted for this strategy:

  • Backtest period ( start_session, end_session ): May 30, 2020, to December 31, 2023.
  • Initial capital ( capital_base ): 10 million NTD.
  • Trading days ( rebalancing days ): 15th of March, June, September, and December.
  • Maximum leverage: 90%.
  • Strategy pipeline: Evaluates the “longs” column from the Pipeline to determine trading on rebalancing days.
  • Slippage model: VolumeShareSlippage.
  • Commission model: Custom_TW_Commission.

Performance Evaluation Using Pyfolio

F-score strategy
Backtesting Performance Compared to Benchmark

Based on the table above, the F-score strategy didn’t just perform well, it outperformed the market. It achieved an annualized return of 27.25%, with an annualized volatility of approximately 18.6%. Furthermore, the Sharpe ratio stands at 1.39, and the alpha value is 0.11, indicating that the F-score strategy generates respectable excess returns for investors under relatively controlled risk. Examining the beta value of 0.77, it suggests that the performance of the F-score strategy is moderately correlated with the market trend, indicating that the nine stock selection criteria of the F-score strategy indeed help mitigate some systematic risks for investors. In the performance comparison chart, it can be observed that the F-score strategy experienced a smaller decline compared to the market in 2022, and after recovering from the bear market, it outperformed the market, underscoring the strategy’s strong profitability.

F-score strategy
Annual Returns Chart

In the annual returns chart, aside from a significant downturn in 2022, the strategy achieved annualized returns exceeding 30% in the other three years.

F-score strategy
Long / Short Position Exposure Chart

From the long/short position exposure chart, we can see that setting the maximum leverage to 90% in TargetPercentPipeAlgo keeps the exposure stable around 0.9. This ensures that the F-score strategy retains some flexibility and is less affected by large fluctuations.

Conclusion

This strategy takes Joseph Piotroski’s ( 2002 ) paper as its foundation, aiming to explore whether the F-score strategy can provide stable profits for investors in the Taiwan stock market. In constructing the strategy, we identify undervalued stocks using the book-to-market ratio and use Pipeline to calculate the F-score and generate trading signals. Finally, we apply the simplified backtesting engine, TargetPercentPipeAlgo, to conduct strategy backtesting.

The quarterly rebalancing feature of the F-score strategy allows investors to promptly update their portfolios after each quarter’s new financial data release. Performance analysis using Pyfolio further confirms the F-score strategy’s superior profitability compared to the broader market. This demonstrates that even after over 20 years since its introduction, the strategy retains robust capabilities in evaluating company profitability, safety, and growth potential. Moreover, it shows applicability within the context of the Taiwan stock market.

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.

Source Code

Extended Reading

About

--

--

TEJ 台灣經濟新報
TEJ-API Financial Data Analysis

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