Advances in Economics, Management and Political Sciences

- The Open Access Proceedings Series for Conferences


Proceedings of the 2nd International Conference on Financial Technology and Business Analysis

Series Vol. 56 , 01 December 2023


Open Access | Article

Stock Price Forecasts Based on KNN and LSTM

Zihao Chen * 1
1 College of the Liberal Arts, Pennsylvania State University, State College, US

* Author to whom correspondence should be addressed.

Advances in Economics, Management and Political Sciences, Vol. 56, 70-77
Published 01 December 2023. © 2023 The Author(s). Published by EWA Publishing
This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
Citation Zihao Chen. Stock Price Forecasts Based on KNN and LSTM. AEMPS (2023) Vol. 56: 70-77. DOI: 10.54254/2754-1169/56/20231064.

Abstract

Every stock trader wants to successfully predict the price or trend of a stock in order to make a profit because stock price forecasts provide investors, traders, and financial professionals with signals about potential price movements, which can help them make more informed decisions about buying, selling, or holding stocks. This article selects the four largest stocks in the U.S. stock market by market capitalization: Google, Apple, Microsoft, and Amazon, and predicts their closing prices from 2013 to 2023. First, K-Nearest Neighbors (KNN) model is established for the closing price sequence after the first-order difference. Then a two-layer LSTM model is constructed to visualize the prediction results of the two models, and RMSE is calculated respectively. Comparing the prediction results of the two models, LSTM has a better prediction effect on the data set used in this paper. This paper finds that the LSTM model can capture the crucial time dependencies and relationships in financial time series data, which are essential for stock price prediction. Therefore, the LSTM model can often be used when predicting stocks in the future.

Keywords

stock market, KNN, LSTM, time series

References

1. Rishi, T. (2022). Stock Market Analysis Using Linear Regression. In Proceedings of the Jepson Undergraduate Conference on International Economics, 4.

2. Loukas, S. (2020). Time-Series Forecasting: Predicting Stock Prices Using An LSTM Model. Retrieved from https://towardsdatascience. com/lstm-time-series-forecasting-predicting-stock-prices-using-an-lstm-model-6223e9644a2f.

3. Sadorsky, P. (2021). A random forests approach to predicting clean energy stock prices. Journal of Risk and Financial Management, 14(2), 48.

4. Li, R., Ma, M., and Tang, N. (2023). Stock Price Prediction Based on Decision Trees, CNN and LSTM. In Proceedings of the 4th International Conference on Economic Management and Model Engineering, ICEMME 2022, November 18-20, 2022, Nanjing, China.

5. Nti, I. K., Adekoya, A. F., and Weyori, B. A. (2020). Efficient Stock-Market Prediction using ensemble support Vector machine. Open Computer Science, 10(1), 153–163.

6. Sonkavde, G., Dharrao, D. S., Bongale, A. M., Deokate, S. T., Doreswamy, D., and Bhat, S. K. (2023). Forecasting Stock Market Prices Using Machine Learning and Deep Learning Models: A Systematic Review, Performance Analysis and Discussion of Implications. International Journal of Financial Studies, 11(3), 94.

7. Biswal, A. (2023). Power of Recurrent Neural Networks (RNN): revolutionizing AI. Retrieved from https://www.simplilearn.com/tutorials/deep-learning-tutorial/rnn

8. Gülen, K. (2023). Stock Prediction In Machine Learning Explained - Dataconomy. Retrieved from https://dataconomy.com/2023/01/11/stock-prediction-machine-learning/

9. Ogunbiyi, I. A. (2022). Top evaluation Metrics for regression problems in Machine Learning. Retrieved from https://www.freecodecamp.org/news/evaluation-metrics-for-regression-problems-machine-learning/

10. Shah, R. (2022). Performance comparison of regularized and unregularized regression models. Retrieved from https://www.analyticsvidhya.com/blog/2021/08/performance-comparision-of-regularized-and-unregularized-regression-models/

Data Availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Authors who publish this series agree to the following terms:

1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.

2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.

3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open Access Instruction).

Volume Title
Proceedings of the 2nd International Conference on Financial Technology and Business Analysis
ISBN (Print)
978-1-83558-159-9
ISBN (Online)
978-1-83558-160-5
Published Date
01 December 2023
Series
Advances in Economics, Management and Political Sciences
ISSN (Print)
2754-1169
ISSN (Online)
2754-1177
DOI
10.54254/2754-1169/56/20231064
Copyright
01 December 2023
Open Access
This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited

Copyright © 2023 EWA Publishing. Unless Otherwise Stated