General Introduction
FinGPT is an open source financial grand language modeling platform developed by the AI4Finance Foundation, designed for the financial sector to solve complex financial tasks and drive innovation in fintech.FinGPT utilizes lightweight adaptation techniques and reinforcement learning methods to provide powerful tools for financial data processing, analysis, and prediction. Compared to traditional financial big models, such as BloombergGPT, FinGPT has lower training cost and higher flexibility, especially for small teams and individual developers. The platform supports a wide range of financial tasks, including sentiment analysis, financial relationship extraction, news classification, named entity recognition and quantitative prediction, providing users with a wide range of application scenarios.
Function List
- Financial data analysis: Provide a variety of data analysis tools to support the analysis of historical and real-time data.
- market forecast: Utilizes big language models to forecast market trends and help users develop investment strategies.
- Investment decision support: Provide intelligent investment advice to help users optimize their portfolios.
- open source platform: All tools and models are open source and users can freely access and modify the code.
- Community Support: With an active developer community, users have access to timely technical support and networking opportunities.
- multitasking support: supports a wide range of tasks such as sentiment analysis, financial relationship extraction, news classification, named entity recognition, and quantitative forecasting.
- Multimodal data processing: Ability to process multimodal financial data from stocks, futures, cryptocurrencies, and other markets.
Using Help
Installation process
- environmental preparation: Ensure that Python 3.6 and above is installed and that you have a basic GPU device (RTX 3090 or above recommended).
- Installation of FinGPT: Run the following command in a terminal to install FinGPT:
pip install fingpt
- clone warehouse: Run the following command in a terminal to clone the FinGPT repository:
git clone https://github.com/AI4Finance-Foundation/FinGPT.git
- Installation of dependencies: Go to the project directory and install the dependencies:
cd FinGPT
pip install -r requirements.txt
- Configuration environment: Configure environment variables and related parameters according to project requirements.
Data preparation
FinGPT provides support for several open source datasets, which can be accessed from the links below:
- fingpt-sentiment-train
- fingpt-headline
Store the dataset in the data
directory to be loaded for use.
Usage Process
- Data preparation: Import the financial data to be analyzed into the project directory in the
data
Folder. - model training: Run the following command for model training:
python train.py --config config.yaml
Users can modify as required config.yaml
parameters in the file to adjust the details of model training.
- model prediction: After training is complete, run the following command for market prediction:
python predict.py --model model.pth --data data/test.csv
The prediction results will be saved in the results
folder, the user can perform further analysis based on the results.
Core Functions and Code Demonstration
Example 1: Financial Sentiment Analysis
The following code shows how to load FinGPT's sentiment analysis model and make sentiment predictions for news:
from fingpt import FinGPT
# Initialize the model
model = FinGPT.load_pretrained("fingpt-sentiment_llama2-13b_lora")
# Import financial news
text = "Apple's revenue exceeds expectations in Q3 earnings."
# Perform sentiment analysis
result = model.analyze_sentiment(text)
print(result) # Output : Positive
Example 2: Stock Forecast
FinGPT offers the FinGPT-Forecaster module, which supports stock price movement forecasting:
from fingpt.forecaster import FinGPTForecaster
# Initialize the forecaster
forecaster = FinGPTForecaster()
# Setting the predictor parameters
params = {
"ticker": "AAPL",
"start_date": "2023-01-01",
"news_window": 4, # Retrieve news data for the past 4 weeks
"add_financials": True # Adds the latest financials.
}
# Make a prediction
prediction = forecaster.predict(params)
print(prediction)
Once run, the system will return a detailed analysis of the company's stock and a forecast of future price trends.
Featured Functions
- Real-time data processing: Supports the processing and analysis of real-time financial data to help users respond quickly to market changes.
- Multi-language support: The platform supports a wide range of programming languages and tools, allowing users to choose the appropriate development environment according to their needs.
- Community ContributionsThe GitHub platform allows users to submit code and suggestions to improve projects with developers around the world.