Skip to content

Enhancing Stock Investment Strategies through Annual Report Analysis with Large Language Models

License

Notifications You must be signed in to change notification settings

KuiMing/GPT-InvestAR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT-InvestAR

Enhancing Stock Investment Strategies through Annual Report Analysis with Large Language Models

This repository contains a set of tools and scripts designed to enhance stock investment strategies through the analysis of annual reports using Large Language Models. The components in this repository are organized as follows:

  1. download_10k.py: This Python script downloads 10-K filings of companies from the SEC website, which contain crucial financial information.

  2. convert_html_to_pdf.py: Converts HTML files to PDF files. PDFs are preferred due to their token efficiency for further analysis.

  • Alternative way
    • Use xvfb and wkhtmltopdf
    sudo apt-get install wkhtmltopdf
    sudo apt-get install xvfb
    
  1. make_targets.py: Generates a DataFrame of stock tickers with target values of different time resolutions, which can be used as investment targets for a Machine Learning model.
  • If you really want to use openbb, you need to run these:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
sudo apt-get install libglib2.0-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libsoup2.4-dev
sudo apt-get install libjavascriptcoregtk-4.0-dev
sudo apt-get install libwebkit2gtk-4.0-dev
sudo apt-get install libbz2-dev
sudo apt-get install libsqlite3-dev
pip3.9 install openbb
  • Alternative way:
    • Use yfinance
    • make_target_yf.py
  1. embeddings_save.py: Generates embeddings of PDF files and saves them using Cromadb. These embeddings are numerical representations of the textual content in annual reports.

  2. gpt_scores_as_features.py: Utilizes saved embeddings to query all questions for each annual report using a Large Language Model (LLM) such as GPT-3.5, and uses the scores or answers as features.

  3. modeling_and_return_estimation.ipynb: This Jupyter Notebook contains the core modeling process. It uses machine learning techniques, specifically Linear Regression, to model the dataset and estimate returns. The goal is to create a portfolio of top-k predicted stocks and compare their returns with the S&P 500 index.

By following the sequence of these components, you can analyze annual reports, generate embeddings, and build predictive models to potentially enhance stock investment strategies.

Feel free to explore each component for more details and usage instructions.

Dependencies

  1. LLama Index (and related dependencies)

  2. OpenBB (and related dependencies)

  3. Scikit-Learn

  4. PDFKit (and related dependencies)

It is recommended to install libraries 1 and 2 in separate virtual (conda) environments. The python scripts mentioned above do not require both these libraries to be installed in the same environment.

Citation

If you use the code or find this repository helpful, please consider citing the paper:

GPT-InvestAR: Enhancing Stock Investment Strategies through Annual Report Analysis with Large Language Models
Udit Gupta
Publication Links:

  1. arXiv Link
  2. SSRN link
@article{GPT-InvestAR,
  author = {Udit Gupta},
  title = {GPT-InvestAR: Enhancing Stock Investment Strategies through Annual Report Analysis with Large Language Models},
  journal = {arXiv e-prints},
  year = {2023},
  eprint = {arXiv:2309.03079},
  url = {https://arxiv.org/abs/2309.03079},
}

About

Enhancing Stock Investment Strategies through Annual Report Analysis with Large Language Models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 85.7%
  • Python 14.3%