# README ## Overview This project presents an integrated deep learning framework for predicting stock closing prices. The framework combines the 2LE-ICEEMDAN denoising method, deep learning models (LSTM, GRU, LSTM-Batch) optimized with Bayesian optimization, and a developed PLR (Piecewise Linear Representation)-based trading strategy. ## Research Abstract This study presents a novel, integrated deep-learning framework named 2LE-BO-DeepTrade for stock closing price prediction. This framework combines 2LE-ICEEMDAN denoising, deep learning models tuned with Bayesian optimization, and a Piecewise Linear Representation (PLR)-based trading strategy. The framework utilizes the model that provides the highest accuracy among optimized Long Short-Term Memory (LSTM), Long Short Term Memory with Batch Normalization (LSTM-BN), and Gated Recurrent Unit (GRU) models on data preprocessed with the 2LE-ICEEMDAN denoising method. The model's performance is comprehensively evaluated using both statistical metrics and a PLR-based trading strategy specifically developed for this study. Experimental studies were conducted on AKBNK, MGROS, KCHOL, THYAO, and ULKER stocks, which are traded on Borsa Istanbul and represent different sectors. During the denoising phase, noise in the stock prices was successfully removed, and noiseless Intrinsic Mode Funsitons (IMFs) were obtained. The optimal model and hyperparameters for each IMF component were determined using Bayesian optimization, significantly improving prediction accuracy. With its optimized simple structure, the model within this framework exhibited superior prediction performance compared to the complex ICE2DE-MDL model in the literature. Furthermore, the developed PLR-based trading strategy offers investors a practical and profitable trading approach. This strategy generates "Buy" and "Sell" signals, enabling significantly higher returns compared to a passive investment strategy. For example, when the PLR-based trading strategy was applied to the ULKER stock, the profit was approximately 160 times higher than the passive strategy's. In conclusion, the proposed deep learning-based integrated stock prediction framework offers promising results for real-world applications in terms of both prediction accuracy and financial return potential. The findings demonstrate that combining advanced denoising techniques, optimized model architectures, and robust financial evaluation methods can significantly improve the accuracy of stock market predictions and the returns of trading strategies. ## Key Contributions 1. **Integrated Framework**: For the first time in the literature, an integrated approach is presented for stock price prediction that combines denoising, Bayesian-optimized hybrid deep learning modeling, and a PLR-based trading strategy in a single, end-to-end framework (2LE-BO-DeepTrade). This offers a more coherent, adaptable, and effective solution compared to traditional approaches, where data preprocessing, modeling, and trading strategy development stages are addressed independently. 2. **Enhanced Denoising**: The 2LE-ICEEMDAN method, proposed in \citep{akcsehir2024multi}, effectively reduces noise in stock price data, enabling deep learning models to be trained with cleaner and more meaningful data. 3. **Optimized Deep Learning Modeling**: A modeling approach consisting of LSTM, LSTM-BN, and GRU models, with hyperparameters optimally tuned using Bayesian optimization, was employed. This approach maximized prediction accuracy by selecting the most suitable model for each IMF. 4. **Proven Financial Returns**: The developed PLR-based trading strategy by directly converting the model's predictions into investment decisions, achieving a return approximately 60 times higher than the traditional Buy-and-Hold (passive) strategy. This clearly demonstrates that the model is not only statistically successful but also practically and financially valuable. ## Code Files - The files link containing all the code for this application has been shared at 'https://github.com/aksehird/2LE-BO-DeepTrade'. ## Usage Instructions 1. **Prerequisites**: - Python 3.10 or later 2. **Required Libraries**: - NumPy - Pandas - TensorFlow 2.x - Scikit-learn - yfinance - joblib - os - matplotlib 3. **Installation**: - Run the following command to install the required libraries: ```bash pip install numpy pandas tensorflow scikit-learn yfinance joblib os matplotlib ``` 4. **Running the Code**: -The provided link contains two code files: Denoising and hyperparameter optimization.py, and 2LE-BO-DeepTrade_Model_Training.py. To denoise the stock closing price data (AKBNK, KSCHOL, MGROS, ULKER, THYAO) and subsequently determine the best deep learning model (i.e., perform hyperparameter optimization) for each Intrinsic Mode Function (IMF) obtained, the code file named 'Denoising and hyperparameter optimization.py' should be executed first. Following this, the '2LE-BO-DeepTrade_Model_Training.py' code should be run to perform model training and analyze model performance both statistically and through profitability analysis using the developed PLR-based trading strategy. ## Experimental Results - **Prediction Accuracy**: The proposed 2LE-BO-DeepTrade framework achieved higher prediction accuracy compared to traditional methods such as ICE2DE-MDL. (See Table 8) - - **Financial Returns:**: The PLR-based trading strategy offers significantly higher return potential compared to passive investment strategies (See Table 9): 51 times more profit was obtained for AKBNK, 87 times for MGROS, 19 times for KCHOL, 15 times for THYAO, and 160 times for ULKER.