Multi-Agent LLM System for Stock-Movement Prediction
A stock-movement prediction system based on LLM agents and traditional machine learning models. The project combines historical stock prices, company news, fundamental data, and macroeconomic information to predict the direction of a stock's movement on the next trading day. The analysis process is streamed to the frontend in real time through WebSocket.
The project also implements LSTM and SVM as traditional machine learning baselines for comparison with the LLM-based prediction approach.
Technologies: Python · LLM · Flask · Vue · WebSocket · LSTM · SVM
- Multi-source stock analysis and movement prediction using LLM agents
- Combines data from the most recent 20 trading days, company news, fundamental data, and macroeconomic indicators
- Supports LSTM and SVM as traditional machine learning baselines
- Streams the model's analysis process to the frontend through WebSocket
- Visualizes prediction results and analysis details through a Vue frontend
- Provides APIs connecting the Flask backend with the frontend and prediction models
- Supports saving and retrieving prediction results
┌─────────────────────┐
│ User / Browser │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ Vue Frontend │
│ Visualization / UI │
└──────────┬──────────┘
│ HTTP/WebSocket
▼
┌─────────────────────┐
│ Flask Backend │
│ REST API │
└──────────┬──────────┘
│
┌──────────────┴──────────────┐
│ │
▼ ▼
┌─────────────────────┐ ┌─────────────────────┐
│ Agent Prediction │ │ Traditional Models │
│ │ │ │
│ LLM-based Analysis │ │ LSTM │
│ │ │ SVM │
└──────────┬──────────┘ └──────────┬──────────┘
│ │
└──────────────┬──────────────┘
▼
┌─────────────────────┐
│ Prediction Results │
│ + Analysis Process │
└─────────────────────┘
The agent-based prediction mode combines information from multiple sources:
Recent Price Data
│
├───────────────┐
│ │
▼ ▼
Company News Fundamentals
│ │
└───────┬───────┘
│
▼
Macroeconomic Data
│
▼
LLM Agents
│
▼
Next-Day Price Direction
The model analyzes price data from the most recent 20 trading days, together with company news, fundamental data, and macroeconomic information, to predict the direction of the stock's movement on the next trading day.
The analysis process is sent to the frontend in real time through WebSocket, allowing users to observe the model's reasoning process instead of seeing only the final prediction.
To compare the performance of different approaches, the project implements two traditional machine learning models.
The LSTM model uses stock prices and derived technical indicators from the previous 20 trading days to predict subsequent prices. The predicted prices are then used to determine the direction of the stock's movement.
The SVM model uses historical prices and technical indicators to predict the direction of the stock's movement on the next trading day.
These baseline models provide an additional reference for evaluating the performance of the LLM-based prediction approach.
A preliminary experiment was conducted on XiaoShangPinCheng (SH600415) during the following period:
2025-03-01 ~ 2025-03-31
During this period, the agent-based model achieved an accuracy of:
57.1%
This is only a preliminary result and does not represent the model's generalization ability over longer periods or across different stocks.
The prediction results showed noticeable fluctuations during the experiment. One possible reason is the short evaluation period. In addition, the historical coverage of the news data source was limited, which restricted the amount of historical information available to the model.
MultiAgentStockForecast/
├── backend/
│ ├── Flask application
│ └── API / WebSocket services
│
├── front/
│ ├── Vue application
│ └── User interface / visualization
│
├── stock_prediction/
│ ├── agent/
│ │ └── LLM-based prediction
│ ├── traditional_model/
│ │ ├── LSTM
│ │ └── SVM
│ ├── util/
│ ├── data/
│ └── temp_data/
│
├── pictures/
├── LICENSE
└── README.md
cd backend
pip install -r requirements.txt
python app.pycd front
npm install
npm run serveAfter starting both services, open:
http://localhost:8080
The system requires access to a compatible LLM API for agent-based prediction.
Configure the API information in the application's system settings before starting a prediction task.
Note: Do not commit API keys or other sensitive credentials to the repository.
The system uses multiple types of market information, including:
- Historical stock prices
- Company news
- Company fundamentals
- Macroeconomic indicators
The availability and historical coverage of external data sources may affect the experimental results.
This project is primarily an engineering and experimental project, rather than a production-grade financial forecasting system.
Some current limitations include:
- Limited evaluation period for the agent-based experiment
- Limited historical news coverage from external data sources
- Limited number of evaluated stocks
- Prediction performance may vary substantially across different market conditions
More extensive experiments across multiple stocks and longer time periods would be necessary to draw stronger conclusions.
This project is for educational and research purposes only.
The predictions generated by the system do not constitute investment advice or financial recommendations.
This project is licensed under the Apache License 2.0.