China is a large agricultural country. Fluctuations in the prices of agricultural products can have a significant impact on the income of farmers. It is also a barometer of the agricultural market. Accurate and effective price forecasting of agricultural products plays an important role in strengthening agricultural informatization. Therefore, it is important to explore the characteristics and laws of agricultural price fluctuations to stabilize agricultural market prices and protect farmers’ incomes. This paper takes the price of pork among agricultural products as an example. This paper summarises several key factors that influence pork price fluctuations. Ultimately, this paper uses three pig prices, namely Outer Ternary, Inner Ter-nary and Black pig, and two feed ingredient prices, namely soybean meal, and maize, for a total of five indicators to forecast pork prices. This study uses the Sparrow Search Algorithm (SSA) to optimize the Long Short-Term Memory (LSTM) hyperparameters to enhance the forecasting capability of the LSTM. An early warning mechanism for pork prices was established to warn of pork price fluctuations. The experimental results verified the prediction accuracy of the proposed model and the effectiveness of the early warning mechanism.