The Problem
Financial institutions need LLMs tuned for domain-specific tasks—sentiment analysis, forecasting, report generation—but proprietary models are costly and closed. FinGPT provides open-source, fine-tunable financial LLMs and a benchmark suite, letting teams build and evaluate models without relying on Wall Street's locked-down APIs.
What This Does
FinGPT is a collection of financial AI projects, not a single library. The fingpt/ directory holds the core work: FinGPT_Benchmark for evaluating models on financial tasks, FinGPT_Forecaster for stock prediction, FinGPT_RAG for retrieval-augmented generation, and FinGPT_Sentiment_Analysis_v1 for sentiment classification. The finogrid/ directory is a separate, newer codebase with database models, services, and MCP servers—likely a production-oriented extension.
The repo includes training scripts (train_lora.py), inference notebooks, and a Flask-based forecaster app (fingpt/FinGPT_Forecaster/app.py). A React frontend exists, though its role isn't clear from the structure.
How It Is Wired
The main training entry point is main in fingpt/FinGPT_RAG/instruct-FinGPT/training/supervised_finetuning/main.py:177, reaching 138 functions. It flows through create_prompt_dataset (filesystem) and into load_dataset (called 16 times from __init__), showing heavy data preparation. The forecaster's predict function (line 260) reaches 36 functions and calls model.generate—a direct model inference path.
The most-connected modules are finogrid/database/models/__init__ (9 importers, 7 imports) and finogrid/corridors/base (9 importers, 0 imports)—a stable hub. The pyfolio package has a circular import cycle across __init__.py, utils.py, and plotting.py, making changes there risky. plotting.py is 1,560 lines, a maintenance burden. The most-called functions—generate (19 callers), cum_returns (15), requests_get (15)—are the blast-radius hotspots.
The finogrid services touch external systems: payment_required.py hashes signatures, kya_validator/server.py makes network calls and DB writes. Traced paths show callback -> process_batch -> db.execute and dispatch -> hashlib.sha256, so this codebase handles payments and identity validation.
How To Use It
Setup: Install dependencies per project, e.g., pip install -r fingpt/FinGPT_Forecaster/requirements.txt. No lockfiles exist, so builds aren't reproducible.
Configuration: fingpt/FinGPT_RAG/.env.example shows required environment variables. Model configs live in config.json files.
Running it: For the forecaster, run python fingpt/FinGPT_Forecaster/app.py. For training, use fingpt/FinGPT_RAG/instruct-FinGPT/training/supervised_finetuning/main.py with the train.sh scripts in training_scripts/. The README's exact commands aren't documented in the excerpt—check each subproject's README.
Real-World Use
A team building a financial sentiment tool could fine-tune a Llama-2 model using FinGPT_Sentiment_Analysis_v1, evaluate it on FinGPT_Benchmark, then deploy the forecaster as a Flask API. The finogrid services handle agent identity and payment validation, so a production system could chain: kya_validator checks identity → agent_ledger_api tracks usage → forecaster serves predictions.
Code Health & Issues
Static analysis found 84 issues: 47 high, 37 medium. Key findings:
- High - Deep nesting (44 instances):
pyfolio/utils.py,txn.pyhit indentation depth 9. Hard to follow control flow. - High - Import cycles (4):
pyfolio/__init__.py,utils.py,plotting.pyare mutually reachable. - High - Duplicated code: 922 repeated 6-line blocks across 112 files in
FinGPT_Benchmark/benchmarks/. - High - Oversized file:
pyfolio/plotting.pyat 1,560 lines. - Medium - Broad exception handling:
payment_required.py,kya_validator/server.pyswallow errors. - Medium - Unmanaged file handles:
eval_mmlu.py,gen_mmlu.pyuseopen()without context managers. - SDLC gaps: No CI/CD, no lockfiles, no Dependabot. Tests exist (22 files) but nothing runs them automatically.
The Bottom Line
FinGPT is a valuable research resource with real, working training and inference code, but it's a research monorepo, not a polished product. The finogrid codebase looks more production-ready but shares the repo's hygiene problems. Use it for experimentation and benchmarking; budget time for dependency and code cleanup before production deployment.