ghostfolio-agent
AI-powered financial assistant for Ghostfolio portfolios. Ask questions about your holdings, performance, taxes, and compliance from the terminal.
Quick Start
pip install ghostfolio-agent
You need two things:
- OpenRouter API key — sign up at openrouter.ai, go to Keys, create one
- Ghostfolio Security Token — in your Ghostfolio instance, go to Settings and copy your Security Token
Set them up (pick one method):
Option A: Environment variables
export OPENROUTER_API_KEY=sk-or-v1-...
export GHOSTFOLIO_ACCESS_TOKEN=your-security-token
Option B: .env file
Create a .env file in your working directory:
OPENROUTER_API_KEY=sk-or-v1-...
GHOSTFOLIO_ACCESS_TOKEN=your-security-token
Option C: CLI flags
ghostfolio-agent --api-key sk-or-v1-... --token your-security-token
Then run:
ghostfolio-agent
Example Session
You: Show my portfolio holdings
Tools used: portfolio_analysis
| Symbol | Name | Shares | Value | Weight |
|--------|----------------|--------|-----------|--------|
| VTI | Vanguard Total | 100 | $25,430 | 45.2% |
| VXUS | Vanguard Intl | 80 | $15,200 | 27.0% |
| BND | Vanguard Bond | 150 | $15,600 | 27.8% |
Confidence: 95% (high)
You: What's my sector exposure?
Tools used: portfolio_analysis
Your portfolio is heavily weighted toward technology (38%) and healthcare (15%)...
What It Can Do
- Portfolio analysis — holdings, allocations, unrealized gains/losses, sector/country exposure
- Market data — current prices, daily changes, symbol lookup
- Transaction history — trade log, dividend history, recent activity
- Tax estimates — realized gains/losses, capital gains, dividend income
- Compliance checks — portfolio health rules, concentration risk, diversification
- Financial math — percentages, projections, share calculations
Prerequisites
- A running Ghostfolio instance (self-hosted)
- An OpenRouter API key for LLM access
CLI Options
ghostfolio-agent [options]
Options:
--api-key KEY OpenRouter API key (or set OPENROUTER_API_KEY)
--token TOKEN Ghostfolio security token (or set GHOSTFOLIO_ACCESS_TOKEN)
--url URL Ghostfolio API URL (default: http://localhost:3333)
--model MODEL LLM model ID (default: anthropic/claude-haiku-4.5)
--timeout SECS Max seconds per request (default: 180)
-v, --verbose Show debug logging (LLM calls, tool execution)
Configuration Reference
All settings can be provided via environment variables, a .env file, or CLI flags:
| Variable | Required | Default | Description |
|---|---|---|---|
OPENROUTER_API_KEY |
Yes | — | OpenRouter API key |
GHOSTFOLIO_ACCESS_TOKEN |
Yes* | — | Security token from Ghostfolio Settings |
GHOSTFOLIO_JWT |
No | — | Direct JWT (advanced, skips token exchange) |
GHOSTFOLIO_API_URL |
No | http://localhost:3333 |
Ghostfolio API URL |
LLM_MODEL |
No | anthropic/claude-haiku-4.5 |
OpenRouter model ID |
MAX_TOOL_STEPS |
No | 5 |
Max tool calls per turn |
MAX_RESPONSE_SECONDS |
No | 180 |
Agent timeout in seconds |
LANGSMITH_API_KEY |
No | — | LangSmith tracing (optional) |
LANGSMITH_PROJECT |
No | — | LangSmith project name |
* Either GHOSTFOLIO_ACCESS_TOKEN or GHOSTFOLIO_JWT is required. Most users should use GHOSTFOLIO_ACCESS_TOKEN — the package automatically exchanges it for a JWT.
Server Mode
For programmatic access, run as a FastAPI server:
pip install "ghostfolio-agent[server]"
python -m ghostfolio_agent.server
Endpoints:
POST /chat— send a message, get a responsePOST /chat/stream— Server-Sent Events streamingGET /health— health check
How Authentication Works
You provide your Ghostfolio Security Token (found in Ghostfolio Settings). On startup, the agent automatically exchanges it for a short-lived JWT by calling your Ghostfolio instance's auth endpoint. You never need to manually handle JWTs.
Development
git clone https://github.com/christensenca/ghostfolio-agent
cd ghostfolio-agent
pip install -e ".[dev,server]"
pytest
License
AGPL-3.0 — see LICENSE
Metadata
Release files for ghostfolio-agent 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ghostfolio_agent-0.1.0.tar.gz | 171.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ghostfolio_agent-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 236.6 kB
Release files / ghostfolio_agent-0.1.0.tar.gz
| Download URL | ghostfolio_agent-0.1.0.tar.gz |
|---|---|
| Size | 171.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df0e982202ad1252ed3c8ad0178f0169b722d7bae359a90a98f2d3c4b00f9e6e
|
|
BLAKE2b-256 checksum How to use checksums |
871bad8c3f0e5d00a262be53a0065f87c2a35b57dab87414ab69096b24195c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency logRelease files / ghostfolio_agent-0.1.0-py3-none-any.whl
| Download URL | ghostfolio_agent-0.1.0-py3-none-any.whl |
|---|---|
| Size | 65.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b568c0fafd37d7c5b500e09230b5455adf7b2401dd1f2e22889941f772cc42f5
|
|
BLAKE2b-256 checksum How to use checksums |
e6688dd736585de3c2f47d996d60dfa2f50ac2f3d0597bf579b48dd8d0a1ba01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.
Transparency log