LIBB is an open-source, opinionated research library designed to automatically manage portfolio state and compute key metrics, while still giving users flexibility over the system.
This project originally began as a generic benchmark for LLM-based trading in U.S. equities. While surveying existing LLM trading projects (including my own), I noticed a consistent lack of rigorous sentiment, behavioral, and performance metrics; most projects reported little more than an equity curve.
This raised a fundamental question: “Why isn’t LLM trading held to the same analytical standards as the rest of finance?”
So I developed a library designed to support rigorous evaluation of LLM-driven trading systems. The long-term goal is to provide a shared foundation for this work and, ultimately, to establish a community standard for this type of research.
-
Persistent portfolio state
All portfolio data is explicitly stored on disk, enabling inspection, reproducibility, and post-hoc analysis across runs. -
Sentiment analysis metrics
Built-in support for sentiment analysis, with results persisted as first-class research artifacts. -
Performance tracking (in progress)
Infrastructure for performance metrics is included, with ongoing integration into the core model workflow. Behavioral analytics is still being devolopped. -
Reproducible run structure
Each model run follows a consistent on-disk directory layout, making experiments easy to reproduce, compare, and archive. -
Flexible execution workflows
Execution logic remains fully user-controlled, allowing researchers to integrate custom strategies, models, or data sources.
LIBB operates as a file-backed execution loop where portfolio state, analytics, and research artifacts are explicitly persisted to disk.
For each run, the framework:
- Loads and processes existing portfolio state
- Recieves inputs (e.g., via an LLM)
- Computes and stores analytical signals (such as sentiment) via explicit user calls
- saves execution instructions (orders) by passing JSON block
- Persists all outputs for inspection and reuse
Execution scheduling (e.g., daily vs. weekly runs) and model orchestration are intentionally left to the user, preserving flexibility while maintaining a consistent on-disk state.
New to LIBB?
Start here → Documentation Guide
This guide explains the system philosophy, execution workflow, and how to read the codebase effectively.
This guide shows two supported setup paths:
- Option A (Recommended): Virtual Environment
- Option B: Global / No Virtual Environment
Choose the option that best fits your workflow.
This option isolates dependencies and avoids conflicts with other Python projects.
git clone https://github.com/LuckyOne7777/LLM-Investor-Behavior-Benchmark.git
cd LLM-Investor-Behavior-BenchmarkVerify contents:
lsYou should see folders like libb/, user_side/, and requirements.txt.
Windows:
python -m venv .venvmacOS / Linux:
python3 -m venv .venv
Windows (PowerShell) If activation fails due to script execution policy, run once:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSignedThen activate:
.venv\Scripts\activateWindows (Command Prompt alternative)
.venv\Scripts\activate.batmacOS / Linux
source .venv/bin/activateVerify activation:
python --versionYou should see (.venv) in your shell prompt.
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .python -c "import libb; print(libb.__file__)"Expected output should point to libb/__init__.py.
macOS / Linux:
export OPENAI_API_KEY="your_key_here"
export DEEPSEEK_API_KEY="your_key_here"Windows (PowerShell):
setx OPENAI_API_KEY "your_key_here"
setx DEEPSEEK_API_KEY "your_key_here"Restart the terminal after using setx.
python -m user_side.workflowDeactivate:
To remove the virtual environment entirely:
Linux / macOS:
rm -rf .venvWindows:
Remove-Item -Recurse -Force .venvThis option installs dependencies into the active Python environment. Recommended only for users comfortable managing global Python packages.
git clone https://github.com/LuckyOne7777/LLM-Investor-Behavior-Benchmark.git
cd LLM-Investor-Behavior-BenchmarkLIBB requires Python 3.10 or newer.
python --versionpython -m pip install --upgrade pippip install -r requirements.txt
pip install -e .Verify installation:
python -c "import libb; print(libb.__file__)"Same as Option A.
python -m user_side.workflowpip uninstall libbNotes
Dependencies may remain installed if they were already present.
Windows users may encounter PowerShell execution policy restrictions.
Command Prompt can be used instead of PowerShell if preferred.
Execution scheduling and orchestration are intentionally left to the user.
- Run directory structure
- Portfolio files
- Metrics files
No manual file setup is required.
After running for the first time, LIBB generates a fixed directory structure at the user-specified output path.
<output_dir>/
├── metrics/ # evaluation
│ ├── behavior.json
│ ├── performance.json
│ └── sentiment.json
├── portfolio/ # trading state & history
│ ├── pending_trades.json
│ ├── portfolio.csv
│ ├── portfolio_history.csv
│ ├── position_history.csv
│ └── trade_log.csv
|
|── loggging/ # JSON log files
|
└── research/ # generated analysis
├── daily_reports/
└── deep_research/
LIBB will use this file tree to save artifacts for all future runs in the output directory.
LIBB is an exploratory research library, and its development is driven by ongoing areas of improvement rather than a fixed roadmap.
Areas of current interest include:
- Deeper integration of performance analytics into the core workflow
- Behavioral analysis derived from trading decisions and execution patterns
- Expansion of sentiment analytics across multiple data sources
- Improved tooling for comparing runs and strategies over time
- General design improvements for efficiency and code quality
To see the current roadmap for major features, check out: roadmap.md
These directions reflect current research interests and may evolve, change, or be abandoned as the project develops.