Implementation:AI4Finance Foundation FinGPT Market Sentiment Labeler
| Knowledge Sources | |
|---|---|
| Domains | Data_Preparation, Sentiment_Classification, domain:Trading |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete tool for labeling Chinese A-share news with market-based sentiment derived from post-news stock price movements provided by the FinGPT Sentiment Analysis v1 subproject.
Description
The add_labels module downloads A-share daily price data via FinRL-Meta's Akshare processor (or the `akshare` package directly), merges news timestamps with price movements, and assigns sentiment labels (up/down/neutral) based on the price change after each news event.
Usage
Import this module when you need to create market-labeled sentiment training data from Chinese financial news and A-share price data. Requires FinRL-Meta or akshare.
Code Reference
Source Location
- Repository: AI4Finance_Foundation_FinGPT
- File: fingpt/FinGPT_Sentiment_Analysis_v1/FinGPT_v1.0/data_preparations/add_labels.py
- Lines: 1-122
Signature
class Akshare:
"""Data processor for A-share market data via akshare.
Args:
provider: data provider name
start_date: start date string
end_date: end date string
time_interval: data granularity
"""
def download_data(self, code_list, save_path): ...
Import
from data_preparations.add_labels import Akshare
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| code_list | list[str] | Yes | A-share stock codes (e.g., ["000001", "600519"]) |
| start_date | str | Yes | Start date (YYYY-MM-DD) |
| end_date | str | Yes | End date (YYYY-MM-DD) |
| save_path | str | No | Where to save the downloaded price CSV |
Outputs
| Name | Type | Description |
|---|---|---|
| dataframe | pd.DataFrame | Daily price data with code column |
Usage Examples
from data_preparations.add_labels import Akshare
processor = Akshare(
provider="akshare",
start_date="2023-01-01",
end_date="2023-12-31",
time_interval="daily",
)
processor.download_data(
code_list=["000001", "600519"],
save_path="a_share_prices.csv",
)
print(processor.dataframe.head())