forked from AI4Finance-Foundation/FinGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,428 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Financial Report Analysis Project | ||
|
||
## Overview | ||
|
||
This project provides tools for analyzing financial reports, specifically annual reports (10-K), using advanced language models such as GPT-4 or other locally deployed Large Language Models (LLM). It's designed to help users generate comprehensive analysis reports in PDF format, offering insights into a company's financial health and performance over the fiscal year. | ||
|
||
## Features | ||
|
||
- **PDF Report Generation**: Automatically generate detailed analysis reports in PDF format for annual financial statements. | ||
- **GPT-4 and LLM Support**: Utilize the power of GPT-4 or any locally deployed LLM for deep and insightful analysis. | ||
- **RAG Support**: The ability to utilize the power of RAG for question-answering and summarization tasks. | ||
- **Customizable Analysis**: Users can modify the analysis scope by choosing different company symbols and models. | ||
- **Easy to Use**: Designed with simplicity in mind, simply run all cells in the provided notebook to get your report. | ||
|
||
## Requirements | ||
|
||
Before starting, ensure you have the following installed: | ||
- Python 3.11 or later | ||
- Jupyter Notebook | ||
- Necessary Python packages (pandas, matplotlib, openai, etc.) | ||
|
||
## Getting Started | ||
|
||
To begin analyzing financial reports: | ||
|
||
0. **(optional) Clone the Repository**: | ||
If you want to run the analysis with the locally deployed models, please download Ollama and have it running: https://ollama.com/download. | ||
Also, download the model you want to use in the list of available models: https://ollama.com/library with command: | ||
```bash | ||
ollama run <model_name> | ||
``` | ||
|
||
1. **Open the Notebook**: | ||
Launch Jupyter Notebook and open the `reportanalysis.ipynb` file: | ||
``` | ||
jupyter notebook reportanalysis.ipynb | ||
``` | ||
All the necessary libraries and dependencies are already imported in the notebook. | ||
2. **Configure the Notebook**: | ||
Modify the `company symbol` and `models` variables within the notebook to suit the analysis you wish to perform. | ||
3. **Run the Analysis**: | ||
Execute all cells in the notebook to generate your financial report analysis in PDF format. | ||
## Contributing | ||
We welcome contributions and suggestions! Please open an issue or submit a pull request with your improvements. |
896 changes: 896 additions & 0 deletions
896
fingpt/FinGPT_FinancialReportAnalysis/reportanalysis.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from utils.earning_calls import get_earnings_transcript, extract_speakers | ||
from utils.rag import Raptor |
69 changes: 69 additions & 0 deletions
69
fingpt/FinGPT_FinancialReportAnalysis/utils/earning_calls.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from tenacity import retry, stop_after_attempt, wait_random_exponential | ||
import requests | ||
import json | ||
from datetime import datetime | ||
import re | ||
from typing import List | ||
|
||
|
||
def correct_date(yr, dt): | ||
"""Some transcripts have incorrect date, correcting it | ||
Args: | ||
yr (int): actual | ||
dt (datetime): given date | ||
Returns: | ||
datetime: corrected date | ||
""" | ||
dt = datetime.strptime(dt, "%Y-%m-%d %H:%M:%S") | ||
if dt.year != yr: | ||
dt = dt.replace(year=yr) | ||
return dt.strftime("%Y-%m-%d %H:%M:%S") | ||
|
||
|
||
def extract_speakers(cont: str) -> List[str]: | ||
"""Extract the list of speakers | ||
Args: | ||
cont (str): transcript content | ||
Returns: | ||
List[str]: list of speakers | ||
""" | ||
pattern = re.compile(r"\n(.*?):") | ||
matches = pattern.findall(cont) | ||
|
||
return list(set(matches)) | ||
|
||
|
||
@retry(wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(2)) | ||
def get_earnings_transcript(quarter: str, ticker: str, year: int): | ||
"""Get the earnings transcripts | ||
Args: | ||
quarter (str) | ||
ticker (str) | ||
year (int) | ||
""" | ||
response = requests.get( | ||
f"https://discountingcashflows.com/api/transcript/{ticker}/{quarter}/{year}/", | ||
auth=("user", "pass"), | ||
) | ||
|
||
resp_text = json.loads(response.text) | ||
# speakers_list = extract_speakers(resp_text[0]["content"]) | ||
corrected_date = correct_date(resp_text[0]["year"], resp_text[0]["date"]) | ||
resp_text[0]["date"] = corrected_date | ||
return resp_text[0] | ||
|
||
|
||
|
||
# from utils import get_earnings_transcript | ||
|
||
# quarter = "Q4" | ||
# ticker = "AAPL" | ||
# year = 2023 | ||
# resp_dict, speakers_list = get_earnings_transcript( | ||
# quarter, ticker, year | ||
# ) |
Empty file.
Oops, something went wrong.