A multi-broker wealth aggregation tool with three interfaces:
🖥️ GUI — Next.js dashboard for visual overview
⌨️ CLI — wealthlens / wl command, works with or without backend
💬 Chat — AI-powered queries via Telegram/OpenClaw
- 📈 Stocks: Futu (HK/US) + Interactive Brokers (US/Global)
- 💎 Crypto: OKX, Binance, Bitget (spot + earn)
- 💱 FX Rates: Multi-source with smart caching & disk persistence
- CEX: OKX, Binance, Bitget spot/earn/funding
- Stocks (Futu): HK & US markets via Futu OpenD API
- Stocks (IBKR): US & global markets via IB Gateway + IBC
- Manual: Custom entries for cash, funds, etc.
- Three-tier data flow: Backend API → Direct exchange APIs → Disk cache
- 10-minute snapshot caching with automatic invalidation
- FX rate caching: open.er-api.com → disk cache (24h) → hardcoded fallback
- Proxy-aware HTTP client (auto-detects
HTTPS_PROXY, uses curl for external requests)
- Colorized terminal output with P&L
- Automatic currency conversion (HKD → USD)
- Options detection & display (e.g.,
TSLA期权) - CJK-aware column alignment
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Browser │ │ CLI/TUI │ │ OpenClaw │
│ :3000 │ │ wl / wealthlens │ │ Telegram │
└────┬─────┘ └────┬─────┘ └────┬─────┘
│ │ │
└─────────────┼──────────────┘
│ HTTP
▼
┌──────────────┐
│ NestJS │
│ Backend │
│ :3001 │
└──────┬───────┘
│
┌─────────┬───┴───┬──────────┐
│ │ │ │
▼ ▼ ▼ ▼
┌─────────┐ ┌──────┐ ┌────────┐ ┌───────┐
│ Futu │ │ IBKR │ │ Crypto │ │ FX │
│ :8000 │ │ :8001│ │ Direct │ │ Rates │
└─────────┘ └──────┘ └────────┘ └───────┘
│ │ │
▼ ▼ ▼
Futu OpenD IB GW OKX/Binance/Bitget
:4001
cp config/secrets.example.json config/secrets.json
# Edit with your exchange API keys (read-only recommended)secrets.json format:
{
"okx": { "apiKey": "...", "secret": "...", "password": "..." },
"binance": { "apiKey": "...", "secret": "..." },
"bitget": { "apiKey": "...", "secret": "...", "password": "..." }
}# Symlink to PATH (pick one)
ln -sf $(pwd)/wealthlens /usr/local/bin/wl
ln -sf $(pwd)/wealthlens /usr/local/bin/wealthlens# One-shot view (auto-detects backend, falls back to direct)
wl
# Force direct mode (bypasses backend, talks to exchanges directly)
wl --direct
# Auto-refresh every 60s
wl --watch
# Custom interval
wl --watch --interval 30Requires Futu OpenD running on port 11111.
cd backend-futu
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python main.py # Starts on :8000Requires IB Gateway + IBC.
# 1. Start IB Gateway via IBC
cd ~/ibc && bash gatewaystartmacos.sh -inline &
# Wait for port 4001 to be ready
# 2. Start IBKR backend
cd backend-ibkr
source venv/bin/activate
uvicorn main:app --host 127.0.0.1 --port 8001IBC config (~/ibc/config.ini) key settings:
IbLoginId=your_username
IbPassword=your_password
TradingMode=live
OverrideTwsApiPort=4001
ReadOnlyApi=yes
⚠️ Session conflict: IBKR only allows one active session per username. If you log into IB Gateway with the same username you use on the mobile TWS app, the mobile session will be kicked off (and vice versa).Solution: Create a second username (sub-account) in IBKR Account Management, and use it exclusively for IB Gateway. This way your mobile TWS and the API gateway can run simultaneously without conflicts.
Full backend with snapshots, history, and aggregation:
cd backend && npm install && npm run build
npm run start:dev # or: pm2 start ecosystem.config.jscd frontend && npm install
npm run devThe CLI uses a three-tier fallback strategy:
- Backend API (
:3001) — Full snapshot with all sources aggregated - Direct Mode — Connects to Futu (
:8000), IBKR (:8001), and crypto exchanges directly - Disk Cache — Falls back to cached snapshots (10-min TTL) and FX rates (24h TTL)
If any source fails, it's silently skipped — you always get whatever data is available.
| Cache | TTL | Location |
|---|---|---|
| Snapshot | 10 min | data/snapshot-cache.json |
| FX Rates | 24h (API) / 8h (refresh) | data/rates-cache.json |
💰 WealthLens 2026-01-15 10:30 [direct]
总资产 $125,000 (¥906,250)
── Futu ──────────────────────────────────
AAPL $ 15,000 +$2,100
00700 $ 12,500 +$1,800
MSFT $ 8,200 +$450
── IBKR ──────────────────────────────────
VOO $ 5,000 +$320
GOOG $ 3,500 +$180
── 加密 ──────────────────────────────────
OKX $ 10,000 USDT BTC ETH
Binance $ 5,000 USDT BNB
── 📊 盈亏 ───────────────────────────────
Futu +$4,350
IBKR +$500
总盈亏 +$4,850
USD/CNY 7.2500 (2.3h ago)
- ✅ All API keys stored in
config/secrets.json(git-ignored) - ✅ No secrets in source code
- ✅ Read-only API keys recommended
- ✅ IB Gateway runs with
ReadOnlyApi=yes - ✅ All data stays local — no external analytics or telemetry
Add a fetch_xxx(secrets) function in the CLI that returns:
[{"symbol": "BTC", "amount": 0.5, "value_usd": 25000, "price": 50000, "exchange": "NewExchange", "type": "spot"}]Then call it in the main() direct mode block.
Edit backend/src/scheduler/snapshot.scheduler.ts:
@Cron('0 */6 * * *') // Every 6 hours
async handleSnapshotCron() { ... }| Issue | Solution |
|---|---|
| No Futu data | Check Futu OpenD is running (port 11111) and backend-futu on port 8000 |
| No IBKR data | Start IB Gateway via IBC, wait for port 4001, then start backend-ibkr |
| "Invalid API signature" | Verify key format in secrets.json, check system clock sync |
| Stale data | Delete data/snapshot-cache.json, or use wl --direct |
| Proxy issues | Set HTTPS_PROXY env var, CLI auto-detects and uses curl |
WealthLens ships with a skill definition for AI agents. Say wl or 看板 in chat and your agent runs the dashboard for you.
Full skill spec: skills/SKILL.md
-
Clone or symlink this repo into your agent's skill directory:
# Option A: symlink ln -s /path/to/wealthlens ~/.openclaw/workspace/skills/wealthlens # Option B: reference in AGENTS.md echo '- wealthlens skill: /path/to/wealthlens/skills/SKILL.md' >> ~/.openclaw/workspace/AGENTS.md
-
Make sure
wlis on PATH:ln -sf /path/to/wealthlens/wealthlens /usr/local/bin/wl
-
The agent will automatically pick up the skill. Say
wlor看板in any connected channel (Telegram, Discord, etc.) and get your portfolio.
Add the skill to your AGENTS.md or project instructions:
## Tools
When the user says "wl", "看板", "dashboard", or "wealthlens":
1. Run `wl` in the terminal
2. Return the output as a code block
WealthLens CLI reference: see skills/SKILL.mdOr pass it as a system prompt flag:
claude --system "$(cat /path/to/wealthlens/skills/SKILL.md)"The skill is a plain Markdown file — drop skills/SKILL.md into whatever context/rules/instructions file your agent uses. The key info:
- Command:
wl(orwl --directif no backend) - Trigger words:
wl,看板,dashboard,wealthlens - Output: Terminal text, best rendered in a code block
- No dependencies: Pure Python CLI, zero pip packages
- skills/SKILL.md — OpenClaw agent skill (chat-based dashboard)
- SETUP.md — Complete setup guide with troubleshooting
- QUICKSTART.md — Quick reference for common tasks
- AGENT_HANDOFF.md — For AI agents to understand the system
MIT License — Free for personal use.
Disclaimer: This tool is for personal wealth tracking only. Always verify financial data against official exchange statements.
Made with ❤️ for personal finance tracking
Last updated: 2026-03-13