## 3 Research Methods
### Model Training  
Figure 4 illustrates the architecture of LSTM used in this study, implemented using Keras [29]. The model consists of two LSTM layers to capture temporal dependencies in the data, one dropout layer to prevent overfitting by randomly setting a fraction of input units to 0 at each update during training, and two dense layers in fully connected layers to output the final prediction results.  
The model's performance is evaluated using Mean Squared Error (MSE) as the loss function. After each training iteration (i.e., \(n=3849\)), the MSE is calculated and fed back to the NN to adjust the weights of each layer. A smaller MSE indicates higher prediction accuracy, while a larger MSE indicates lower accuracy. The formula for MSE is:  
\[\text{MSE}=\sum_{i=1}^{n}{(y-\hat{y})^{2}/n} \tag{11}\]  
where:  
* \(n\) is the sample size.
* \(y\) is the actual value.
* \(\hat{y}\) is the predicted value.  
Figure 4: LSTM architecture diagram [19].  
Figure 3: Data splitting diagram.  
The model's predicted stock prices may have small discrepancies from the actual daily stock prices, which can affect the trading points of subsequent trades and the highest and lowest prices during trading. To address this, a correction method [19] is used to adjust the predicted values. While this method reduces prediction error, it only corrects the next day's predictions and cannot improve future stock price trends.  
This study proposes STBC that uses the short-term prediction error of the current day's stock price to determine if the predicted value needs adjustment and then corrects future stock prices accordingly. Algorithm 1 presents the calibration procedure for calculating the error and determining whether to apply the correction.  
Where:  
- \(R_{t}\) is today's stock price.  
- \(P_{t}\) models today's predicted stock price.  
- \(\delta\) is the calibration threshold.  
- \(C_{last}\) is the previous calibration value.  
- \(C_{t}\) is today's calibration value.  
```
1:\(P_{t}=P_{t}+C_{last}\)
2:\(C_{t}=R_{t}-P_{t}\)
3:If\(|C_{t}|>(R_{t}\times\delta)\)then
4:\(C_{last}=C_{last}+C_{t}\)
5:endif
```  
**Algorithm 1** STBC Deviation Calibration Procedure.  
To reduce the prediction error of the model and determine the optimal correction threshold \(\delta\), this study employs GAs to evolve and find the best value. In GAs, the fitness function is used to calculate the fitness value, which evaluates an individual's adaptability to the environment. The higher the fitness value, the greater the individual's survival probability. In this study, the fitness value is calculated using the MSE obtained after applying STBC.  
Table 2 outlines the parameters and initial values for the GAs. The initial value for the correction threshold is set to 0.05, and the evolution is set to stop after 15 iterations. Given the relatively low complexity of the problem, the Steady State Selection [30] method is used to select individuals for reproduction, which is computationally efficient. After selection, single-point crossover is performed to evolve the next generation, with a mutation rate of 1% during the crossover process. By the end of the GA process, the optimal correction threshold \(\delta\) is identified, which minimizes the prediction error and improves the model's accuracy.