Stock price prediction is very important in financial decision-making, and it is also the most difficult part of economic forecasting. The factors affecting stock prices are complex and changeable, and stock price fluctuations have a certain degree of randomness. If we can accurately predict stock prices, regulatory authorities can conduct reasonable supervision of the stock market and provide investors with valuable investment decision-making information. As we know, the LSTM (Long Short-Term Memory) algorithm is mainly used in large-scale data mining competitions, but it has not yet been used to predict the stock market. Therefore, this article uses this algorithm to predict the closing price of stocks. As an emerging research field, LSTM is superior to traditional time-series models and machine learning models and is suitable for stock market analysis and forecasting. However, the general LSTM model has some shortcomings, so this paper designs a LightGBM-optimized LSTM to realize short-term stock price forecasting. In order to verify its effectiveness compared with other deep network models such as RNN (Recurrent Neural Network) and GRU (Gated Recurrent Unit), the LightGBM-LSTM, RNN, and GRU are respectively used to predict the Shanghai and Shenzhen 300 indexes. Experimental results show that the LightGBM-LSTM has the highest prediction accuracy and the best ability to track stock index price trends, and its effect is better than the GRU and RNN algorithms.