A simple CLI tool for real-time A-share ETF quotes and OTC fund context, designed for AI-assisted long-term trading analysis.
ETF primary data source: Eastmoney (东方财富) ETF fallback: Tencent (腾讯) OTC fund source: Tiantian Fund estimate API (天天基金估值接口) Holdings-based proxy: Eastmoney fund detail page (东方财富基金持仓)
cd etf
pip3 install -r requirements.txt
pip3 install -e .Or use the install script:
./install.shetf get 562500
etf get 562500 --json
etf get 562500 --aietf fund 018344
etf fund 018344 --json
etf fund 018344 --aietf smart robot
etf smart 562500
etf smart 018344
etf smart robot --copyetf pair add robot 562500 018344
etf pair list
etf pair get robot
etf pair get robot --ai
etf pair remove robot# Add fund with optional reference ETF
etf fundw add 020404 --ref 159540
etf fundw add 009447
# List watchlist
etf fundw list
# Batch intraday estimate for all funds
etf fundw watch
etf fundw watch --json
# Remove fund
etf fundw remove 020404# Show all fund watchlist + all pairs in one view
etf est# Set current holding amount by code
etf holding set 020404 561.89
etf holding set 159887 12150.50
etf holding set cash 7125.69
# List/remove holdings
etf holding list
etf holding remove 020404
# Estimate whole portfolio intraday gain/loss
etf pnl
etf pnl --jsonetf pnl reports both:
- Total asset return: today's estimated gain/loss divided by all configured holdings, including cash/repo
- Risk asset return: today's estimated gain/loss divided only by non-cash holdings
etf pnl uses the best available intraday estimate:
- Exchange-traded ETF quote for ETF codes
- Official OTC fund estimate when available
- Reference ETF if bound through
fundw add --ref - Holdings-based proxy estimate when needed
cash,repo,reverse_repo,现金,逆回购are treated as 0% change
# Sell 200 yuan of bank ETF
etf holding adjust 159887 -200
# Buy 500 yuan of Nasdaq fund
etf holding adjust 270042 +500
# Also works for cash changes
etf holding adjust cash -500# Save a snapshot of current portfolio (run daily after close)
etf snapshot
# Draw terminal line curve from saved snapshots
etf curve
etf curve --last 90
# Show bar/area chart instead
etf curve --barSnapshots are stored in ~/.etf/snapshots.jsonl. The curve shows total assets, return percentage, and max drawdown.
etf add 562500
etf list
etf remove 562500
etf watch| Type | Example | What the tool shows |
|---|---|---|
| Exchange-traded ETF | 562500 |
Real-time market price from Eastmoney |
| OTC linked fund | 018344 |
NAV + estimated NAV from Tiantian Fund |
| Active/mixed fund | 009447 |
NAV estimate + holdings-based proxy estimate |
For active/mixed funds where Tiantian Fund estimate is unavailable or unreliable:
- Fetches top 10 holdings and their weights from Eastmoney fund detail page
- Fetches intraday change for each holding stock
- Calculates weighted average change as proxy estimate
- Shows holdings coverage percentage as confidence indicator
Accuracy: directional reference only. Top holdings are from latest quarterly report and may be stale.
When you add a fund to the watchlist with --ref, the tool also shows the reference ETF's intraday change alongside the fund estimate. This helps when:
- The fund estimate is unavailable (e.g.
020404) - You want to cross-validate the estimate against the actual traded market
- Eastmoney: ETF quotes (primary), fund holdings data
- Tencent: ETF quotes (fallback)
- Tiantian Fund: OTC fund NAV and estimated NAV