Stock Selection Using Machine Learning Based on Financial Ratios
Abstract
:1. Introduction
- Aligning data time periods enhances return prediction accuracy and can be applied to other stock markets with fixed fiscal years.
- Four different types of nonlinear models were tested, each with its own strengths and limitations in handling temporal and spatial data dependencies.
- The top 10 and top 20 stock portfolios generated by our models outperformed the TW50 index with substantial excess returns.
- Our model-selected portfolios also demonstrated lower risk compared to random stock selection or the TW50 index.
2. Literature Review
3. Preliminaries
3.1. Random Forest (RF)
3.2. Feedforward Neural Network (FNN)
3.3. Gate Recurrent Unit (GRU)
3.4. Graph Attention Network (GAT)
3.5. Financial Graph Attention Network (FinGAT)
4. Methodology
4.1. Stock Pool of TW 97 Stocks
4.2. Financial Ratios of 18 Ratios as Attributes
- Liquidity ratios: Liquidity ratios measure a company’s ability to pay off its short-term debts.
- Leverage ratios: Leverage ratios measure the amount of debt a company has relative to its assets or equity. These ratios are often used by investors and creditors to assess the riskiness of a company’s operations and its ability to meet long-term debt obligations.
- Asset efficiency ratios: Asset efficiency ratios measure how effectively a company uses and manages its assets to generate revenue.
- Market value ratios: Market value ratios are used to evaluate a company’s stock price in relation to its earnings, sales, and book value.
- Profitability ratios: Profitability ratios measure a company’s ability to generate profits.
4.3. Moving Time Period
4.4. Evaluation Metrics
4.4.1. Excess Return
4.4.2. Top-k Precision
4.4.3. Portfolio Score
4.5. Model Architecture for Training/Validation/Test
4.5.1. Data Clean
4.5.2. Relative Return as Target y in Training
4.5.3. Training Procedure
4.5.4. Random Forest Hyperparameters
4.5.5. FNN Hyperparameters
4.5.6. GRU Architecture
4.5.7. FinGAT Hyperparameter
5. Results
5.1. High Portfolio Scores
5.2. High Excess Return in Top-10 and Top-20 in Test Data for Four Models for Investment Gain
5.3. Low-Risk Investment and High Return Rate
5.4. Top-k Precision
6. Conclusions
- Improved Stock Selection: The superior performance of our models, particularly in comparison to the TW50 benchmark, positions them as valuable tools for stock selection. This enhances the decision-making process for portfolio managers, providing more effective alternatives for discerning investors.
- Consideration of Fiscal Year Alignment: Managers should be aware of the limitations regarding aligned fiscal years. In markets with misaligned fiscal years, there may be potential performance loss due to quarterly financial report publishing misalignment. This suggests a need for adaptation or additional considerations when applying these models in diverse fiscal environments.
- Optimal Risk–Return Balance: The demonstrated balance between return and risk, as showcased in the risk vs. return plot, highlights the efficiency of our risk and return management approach. This implies that managers can achieve higher returns without significantly increasing portfolio risk, offering a valuable strategy for optimizing risk-adjusted returns.
- Methodological Prowess: The consistently superior performance of our methodology, as evidenced by portfolio scores outperforming the TW50 index, underscores its prowess. This emphasizes the reliability and effectiveness of our approach, reinforcing the commitment to sound risk and return management practices.
- Precision Improvement: Although precision in top 10 and top 20 outcomes may not be significant, the approach significantly outperforms random stock selection. This suggests that managers can enhance accountability by relying on our models, achieving more predictable outcomes in the range of 6.4% to 11.8% for top 10 portfolios and 6.2% to 9.3% for top 20 portfolios.
- Expanded Investment Options: The diversity of choices beyond TW50 index portfolios or haphazard stock selection offers investors a more tailored approach. Managers can guide investors to opt for top 10 portfolios for high excess returns with acceptable risk or top 20 portfolios for lower risk, maintaining commendable excess returns relative to the TW50 index.
7. Future Work
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Namdari, A.; Li, Z.S. Integrating fundamental and technical analysis of stock market through multi-layer perceptron. In Proceedings of the 2018 IEEE Technology and Engineering Management Conference (TEMSCON), Evanston, IL, USA, 28 June–1 July 2018; pp. 1–6. [Google Scholar]
- Huang, Y.; Capretz, L.F.; Ho, D. Machine learning for stock prediction based on fundamental analysis. In Proceedings of the 2021 IEEE Symposium Series on Computational Intelligence (SSCI), Orlando, FL, USA, 5–7 December 2021; pp. 1–10. [Google Scholar]
- Lu, Z.-Y. A Deep Reinforcement Learning-Enabled Portfolio Management System with Quarterly Stock Re-Selection Based on Financial Statements. Master’s Thesis, National Yang Ming Chiao Tung University, Taiwan, China, 2022. [Google Scholar]
- Arkan, T. The importance of financial ratios in predicting stock price trends: A case study in emerging markets. Finanse Rynki Finansowe Ubezpieczenia 2016, 79, 13–26. [Google Scholar] [CrossRef]
- Breiman, L. Random forests. Mach. Learn. 2001, 45, 5–32. [Google Scholar] [CrossRef]
- Cutler, A.; Cutler, D.R.; Stevens, J.R. Random forests. In Ensemble Machine Learning: Methods and Applications; Springer: New York, NY, USA, 2012; pp. 157–175. [Google Scholar]
- Svozil, D.; Kvasnicka, V.; Pospichal, J. Introduction to multi-layer feed-forward neural networks. Chemom. Intell. Lab. Syst. 1997, 39, 43–62. [Google Scholar] [CrossRef]
- Cho, K.; Van Merriënboer, B.; Gulcehre, C.; Bahdanau, D.; Bougares, F.; Schwenk, H.; Bengio, Y. Learning phrase representations using RNN encoder-decoder for statistical machine translation. arXiv 2014, arXiv:1406.1078. [Google Scholar]
- Hsu, Y.-L.; Tsai, Y.-C.; Li, C.-T. FinGAT: Financial Graph Attention Networks for Recommending Top-KK Profitable Stocks. IEEE Trans. Knowl. Data Eng. 2021, 35, 469–481. [Google Scholar] [CrossRef]
- Yu, H.; Chen, R.; Zhang, G. A SVM stock selection model within PCA. Procedia Comput. Sci. 2014, 31, 406–412. [Google Scholar] [CrossRef]
- Zhang, X.-d.; Li, A.; Pan, R. Stock trend prediction based on a new status box method and AdaBoost probabilistic support vector machine. Appl. Soft Comput. 2016, 49, 385–398. [Google Scholar] [CrossRef]
- Sabbar, K.; El Kharrim, M. Average variance portfolio optimization using machine learning-based stock price prediction case of renewable energy investments. In E3S Web of Conferences; EDP Sciences: Ulys, France, 2023; Volume 412, p. 01077. [Google Scholar]
- Dhingra, V.; Sharma, A.; Gupta, S.K. Sectoral portfolio optimization by judicious selection of financial ratios via PCA. Optim. Eng. 2023, 1–38. [Google Scholar] [CrossRef]
- Olorunnimbe, K.; Viktor, H. Deep learning in the stock market—A systematic survey of practice, backtesting, and applications. Artif. Intell. Rev. 2023, 56, 2057–2109. [Google Scholar] [CrossRef] [PubMed]
- Ibidapo, I.; Adebiyi, A.; Okesola, O. Soft computing techniques for stock market prediction: A literature survey. Covenant J. Inform. Commun. Technol. 2017, 5, 1–28. [Google Scholar]
- Dhokane, R.M.; Sharma, O.P. A Comprehensive Review of Machine Learning for Financial Market Prediction Methods. In Proceedings of the 2023 International Conference on Emerging Smart Computing and Informatics (ESCI), Pune, India, 1–3 March 2023; pp. 1–8. [Google Scholar]
- Graham, B.; Dodd, D.L.F.; Cottle, S.; Tatham, C. Security Analysis: Principles and Technique; McGraw-Hill: New York, NY, USA, 1962. [Google Scholar]
- Quah, T.-S.; Srinivasan, B.; Lee, M. Segmental Stock Market Prediction Using Neural Network. In Proceedings of the Applied Informatics-Proceedings, Innsbruck, Austria, 15–18 February 1999; pp. 23–24. [Google Scholar]
- Eakins, S.G.; Stansell, S.R. Can value-based stock selection criteria yield superior risk-adjusted returns: An application of neural networks. Int. Rev. Financ. Anal. 2003, 12, 83–97. [Google Scholar] [CrossRef]
- Quah, T.-S. DJIA stock selection assisted by neural network. Expert Syst. Appl. 2008, 35, 50–58. [Google Scholar] [CrossRef]
- Chen, W.; Jiang, M.; Zhang, W.-G.; Chen, Z. A novel graph convolutional feature based convolutional neural network for stock trend prediction. Inf. Sci. 2021, 556, 67–94. [Google Scholar] [CrossRef]
- Zhang, D.; Lou, S. The application research of neural network and BP algorithm in stock price pattern classification and prediction. Future Gener. Comput. Syst. 2021, 115, 872–879. [Google Scholar] [CrossRef]
- Hong, J.; Han, P.; Rasool, A.; Chen, H.; Hong, Z.; Tan, Z.; Lin, F.; Wei, S.X.; Jiang, Q. A Correlational Strategy for the Prediction of High-Dimensional Stock Data by Neural Networks and Technical Indicators. In International Conference on Big Data and Security; Springer: Singapore, 2022; pp. 405–419. [Google Scholar]
- Kimoto, T.; Asakawa, K.; Yoda, M.; Takeoka, M. Stock market prediction system with modular neural networks. In Proceedings of the 1990 IJCNN International Joint Conference on Neural Networks, San Diego, CA, USA, 17–21 June 1990; pp. 1–6. [Google Scholar]
- Quah, T.-S. Improving returns on stock investment through neural network selection. In Artificial Neural Networks in Finance and Manufacturing; IGI Global: Hershey, PA, USA, 2006; pp. 152–164. [Google Scholar]
- Chung, J.; Gulcehre, C.; Cho, K.; Bengio, Y. Empirical evaluation of gated recurrent neural networks on sequence modeling. arXiv 2014, arXiv:1412.3555. [Google Scholar]
- Matsunaga, D.; Suzumura, T.; Takahashi, T. Exploring graph neural networks for stock market predictions with rolling window analysis. arXiv 2019, arXiv:1909.10660. [Google Scholar]
- Tsai, Y.-C.; Chen, C.-Y.; Ma, S.-L.; Wang, P.-C.; Chen, Y.-J.; Chang, Y.-C.; Li, C.-T. FineNet: A joint convolutional and recurrent neural network model to forecast and recommend anomalous financial items. In Proceedings of the 13th ACM Conference on Recommender Systems, Copenhagen, Denmark, 16–20 September 2019; pp. 536–537. [Google Scholar]
- Wang, J.; Zhang, S.; Xiao, Y.; Song, R. A review on graph neural network methods in financial applications. arXiv 2021, arXiv:2111.15367. [Google Scholar] [CrossRef]
- Hossain, M.A.; Karim, R.; Thulasiram, R.; Bruce, N.D.; Wang, Y. Hybrid deep learning model for stock price prediction. In Proceedings of the 2018 IEEE Symposium Series on Computational Intelligence (SSCI), Bangalore, India, 18–21 November 2018; pp. 1837–1844. [Google Scholar]
- Veličković, P.; Cucurull, G.; Casanova, A.; Romero, A.; Lio, P.; Bengio, Y. Graph attention networks. arXiv 2017, arXiv:1710.10903. [Google Scholar]
- Scarselli, F.; Gori, M.; Tsoi, A.C.; Hagenbuchner, M.; Monfardini, G. The graph neural network model. IEEE Trans. Neural Netw. 2008, 20, 61–80. [Google Scholar] [CrossRef] [PubMed]
- Medsker, L.R.; Jain, L. Recurrent neural networks. Des. Appl. 2001, 5, 2. [Google Scholar]
- Taiwan Index Plus. Available online: https://taiwanindex.com.tw/en/indexes/TW50 (accessed on 1 July 2023).
- Ehrhardt, M.C. Financial Management: Theory and Practice; South-Western Cengage Learning: Mason, OH, USA, 2011. [Google Scholar]
Type | Ratio | Calculation |
---|---|---|
Liquidity Ratios | Current | |
Leverage Ratios | Debt to Equality | |
Debt to Capital | ||
Asset Efficiency Ratios | Asset Turnover | |
Inventory Turnover | ||
Receivable Turnover | ||
Days Sales in Receivable | ||
Market Value Ratios | Book Value per Share | |
Probability Ratios | Gross Margin | |
Operating Margin | ||
Pre-tax profit margin | ||
Net Profit Margin | ||
Return on Equality | ||
Return on Tangible Equality | ||
Return on assets | ||
Return on investment | ||
Operating Cash Flow Per Share | ||
Free Cash Flow per Share |
RF/FNN | Training Set (20 Quarters) | Validation Set (6 Quarters) | Test Set (1 Quarter) | Moving Time Period During Training and Validation |
---|---|---|---|---|
Moving time period 1 | 2013Q1–2017Q4 | 2018Q1–2019Q2 | 2019Q3 | Iterative training 1 Quarter as training input for each moving time period; |
Moving time period 2 | 2013Q2–2018Q1 | 2018Q2–2019Q3 | 2019Q4 | |
Moving time period 3 | 2013Q3–2018Q2 | 2018 Q3–2019 Q4 | 2020Q1 | |
…… | …… | …… | …… | |
Moving time period 11 | 2015Q3–2020Q2 | 2020Q3–2021Q4 | 2022Q1 |
GRU/FinGAT | Training Set (20 Quarters) | Validation Set (6 Quarters) | Test Set (4 Quarter) | Moving Time Period During Training and Validation |
---|---|---|---|---|
Moving time period 1 | 2013Q1–2017Q4 | 2018Q1–2019Q2 | 2019Q3–2020Q2 | Iterative training 4 Quarters as training input for each moving time period; |
Moving time period 2 | 2013Q2–2018Q1 | 2018Q2–2019Q3 | 2019Q4–2020Q3 | |
Moving time period 3 | 2013Q3–2018Q2 | 2018 Q3–2019 Q4 | 2020Q1–2020Q4 | |
…… | …… | …… | …… | |
Moving time period 11 | 2015Q3–2020Q2 | 2020Q3–2021Q4 | 2022Q1–2022Q4 |
Name of Hyperparamter | Optimized Result |
---|---|
Number of hidden layers | 2 |
Number of nodes in the first hidden layer | 30 |
Number of nodes in the second hidden layer | 15 |
Loss Function | MSE |
Activation Function | Sigmoid |
Learning Rate | 1 × 10−3 |
Optimizer | Adam |
Learning Rate Scheduler | ReduceLROnPlateau with factor = 0.1 |
Name of Hyperparamter | Optimized Result |
---|---|
Number of hidden layers | 1 |
Dimension of hidden state | 36 |
Time Step (Ratios of four quarters are inputted to GRU) | 4 |
Activation Function | Sigmoid |
Loss Function | MSE |
Number of training epochs | 100 |
Learning Rate | 1 × 10−3 |
Optimizer | Adam |
Learning Rate Scheduler | ReduceLROnPlateau with factor = 0.1 |
Name of Hyperparamter | Optimized Result |
---|---|
Number of layers in GRU | 1 |
Number of layers in GAT | 1 |
Dimension of Hidden State of GRU and GAT | 20 |
GRU time step (Ratios of four quarters are inputted to GRU) | 3 |
Activation Function | Sigmoid |
Loss Function | MSE |
Number of training epochs | 100 |
Learning Rate | 1 × 10−3 |
Optimizer | Adam |
Learning Rate Scheduler | ReduceLROnPlateau with factor = 0.1 |
Sector | Total Number of Shares in 97 Stocks of TW |
---|---|
Basic Material | 10 |
Communication Service | 3 |
Consumer Cyclical | 9 |
Consumer Defensive | 3 |
Energy | 1 |
Financial Services | 15 |
Healthcare | 0 |
Industrials | 11 |
Real Estate | 1 |
Technology | 44 |
Utility | 0 |
Total | 97 |
Random Forest | FNN | GRU | FinGAT | TW 97 | TW 50 | |||||
---|---|---|---|---|---|---|---|---|---|---|
Portfolios | Top 10 | Top 20 | Top 10 | Top 20 | Top 10 | Top 20 | Top 10 | Top 20 | ||
Portfolio Score | 0.54 | 0.53 | 0.62 (3) | 0.58 | 0.58 | 0.61 | 0.65 (2) | 0.68 (1) | 0.54 | 0.29 |
Excess return to the TW50 index | 109.2% (2) | 50.1% | 95.8% (3) | 60.1% | 65% | 79% | 114.5% (1) | 94.5% | 23.5% | Baseline 0% |
Average Return of Portfolio | 9.8% (1) | 6.5% | 8.8% (3) | 7.0% | 8.5% | 7.39% | 9.67% (2) | 8.61% | 4.8% | 3.5% |
Top-k Precision | 16.4% 1 | 26.8% 2 (3) | 19.1% 1 | 27.7% 2 (1) | 18.2% 1 | 29.5% 2 | 21.8% 1 | 27.3% 2 (2) | NA | NA |
STD of portfolio | 18.1% | 12.3% | 14.2% | 12.2% | 14.8% | 12.12% | 14.87% | 12.67% | 8.9% | 12.3% |
Top-20 | Research of US S&P [2] | Ours of TW Stock |
---|---|---|
Portfolio Score | Portfolio Score | |
RF | 0.414 | 0.58 |
FNN | 0.202 | 0.53 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Tsai, P.-F.; Gao, C.-H.; Yuan, S.-M. Stock Selection Using Machine Learning Based on Financial Ratios. Mathematics 2023, 11, 4758. https://doi.org/10.3390/math11234758
Tsai P-F, Gao C-H, Yuan S-M. Stock Selection Using Machine Learning Based on Financial Ratios. Mathematics. 2023; 11(23):4758. https://doi.org/10.3390/math11234758
Chicago/Turabian StyleTsai, Pei-Fen, Cheng-Han Gao, and Shyan-Ming Yuan. 2023. "Stock Selection Using Machine Learning Based on Financial Ratios" Mathematics 11, no. 23: 4758. https://doi.org/10.3390/math11234758
APA StyleTsai, P. -F., Gao, C. -H., & Yuan, S. -M. (2023). Stock Selection Using Machine Learning Based on Financial Ratios. Mathematics, 11(23), 4758. https://doi.org/10.3390/math11234758