AI-powered financial assistant for Ghostfolio portfolios
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghostfolio_agent-0.1.0.tar.gz.
File metadata
- Download URL: ghostfolio_agent-0.1.0.tar.gz
- Upload date:
- Size: 171.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df0e982202ad1252ed3c8ad0178f0169b722d7bae359a90a98f2d3c4b00f9e6e
|
|
| MD5 |
56c5edcd5e87721abd4300021879b8e3
|
|
| BLAKE2b-256 |
871bad8c3f0e5d00a262be53a0065f87c2a35b57dab87414ab69096b24195c9e
|
Provenance
The following attestation bundles were made for ghostfolio_agent-0.1.0.tar.gz:
Publisher:
publish.yml on christensenca/ghostfolio-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghostfolio_agent-0.1.0.tar.gz -
Subject digest:
df0e982202ad1252ed3c8ad0178f0169b722d7bae359a90a98f2d3c4b00f9e6e - Sigstore transparency entry: 1006815593
- Sigstore integration time:
-
Permalink:
christensenca/ghostfolio-agent@65e9001ce2c200726703328c0067b898ebb1e1f9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/christensenca
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@65e9001ce2c200726703328c0067b898ebb1e1f9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ghostfolio_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ghostfolio_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 65.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b568c0fafd37d7c5b500e09230b5455adf7b2401dd1f2e22889941f772cc42f5
|
|
| MD5 |
3759fde072fc0f62e32c4d7c2b6f5f8b
|
|
| BLAKE2b-256 |
e6688dd736585de3c2f47d996d60dfa2f50ac2f3d0597bf579b48dd8d0a1ba01
|
Provenance
The following attestation bundles were made for ghostfolio_agent-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on christensenca/ghostfolio-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghostfolio_agent-0.1.0-py3-none-any.whl -
Subject digest:
b568c0fafd37d7c5b500e09230b5455adf7b2401dd1f2e22889941f772cc42f5 - Sigstore transparency entry: 1006815613
- Sigstore integration time:
-
Permalink:
christensenca/ghostfolio-agent@65e9001ce2c200726703328c0067b898ebb1e1f9 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/christensenca
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@65e9001ce2c200726703328c0067b898ebb1e1f9 -
Trigger Event:
push
-
Statement type: