Skip to content

arbaleast/fund-analyzer

Repository files navigation

fund-analyzer (基金分析工具)

Chinese mutual fund analysis tool with CLI and TUI

Features

  • Fund Search - Search funds by name or code
  • NAV History - View historical net asset value data
  • Holdings - View fund stock holdings
  • Backtest - Dollar-cost averaging (DCA) strategy backtesting
  • Risk Metrics - Volatility, max drawdown, Sharpe ratio
  • Compare - Compare multiple funds side by side
  • Screener - Filter funds by type and other criteria
  • Annotation - Add personal notes to funds for tracking observations

Installation

# Clone project
cd /vol1/1000/projects/fund-analyzer

# Install Go dependencies
go mod tidy

# Build CLI
go build -o fund-analyzer ./cmd/cli/

# Build TUI
go build -o fund-analyzer-tui ./cmd/tui/

# Or use Makefile
make build

Database

Data stored in SQLite at ~/.fund-analyzer/funds.db

Database tables:

  • funds - Fund basic information
  • nav_history - NAV historical records
  • holdings - Fund holdings data
  • portfolios - Portfolio management
  • portfolio_holdings - Portfolio fund holdings
  • annotations - Fund annotation/memo notes

CLI Usage

# Fetch fund data (single fund or all)
fund-analyzer fetch 000001
fund-analyzer fetch

# Analyze fund (risk metrics, performance)
fund-analyzer analyze 000001

# Show NAV history
fund-analyzer nav 000001

# Search funds by name or code
fund-analyzer search 招商

# Show fund holdings
fund-analyzer holdings 000001

# Compare two funds
fund-analyzer compare 000001 110011

# Run backtest (DCA strategy)
fund-analyzer backtest 000001
fund-analyzer backtest 000001 -s 2023-01-01 -e 2024-01-01 -m 1000

Backtest Flags

Flag Short Default Description
--start -s 2023-01-01 Start date (YYYY-MM-DD)
--end -e 2024-01-01 End date (YYYY-MM-DD)
--initial -i 0 Initial investment amount
--monthly -m 1000 Monthly DCA amount

Backtest Example

$ fund-analyzer backtest 000001 -s 2023-01-01 -e 2024-01-01 -m 1000

═══════════════════════════════════════════════════════
  定投回测结果: 000001
═══════════════════════════════════════════════════════
  回测区间: 2023-01-01 ~ 2024-01-01
  定投期数: 12 次
  月定投金额: 1000.00 元
───────────────────────────────────────────────────────
  总投入:      13000.00 元
  最终价值:    14250.00 元
  总收益:      +1250.00 元 (+9.62%)
───────────────────────────────────────────────────────
  年化收益:    +9.62%
  最大回撤:    -8.50%
  夏普比率:    0.85
═══════════════════════════════════════════════════════

Backtest simulates dollar-cost averaging (DCA) strategy:

  • Initial investment on start date
  • Fixed monthly investment on the 1st of each month
  • Calculates total return, annualized return, max drawdown, and Sharpe ratio

TUI Usage

# Launch terminal UI
./fund-analyzer-tui

TUI Keybindings

ViewList Mode (Fund List)

Key Action
j/k Move up/down
g Jump to top
G Jump to bottom
Enter View fund detail
Tab Switch to search
c Add to compare list
x Remove from compare
v Show compare list
f Open screener
i Show analysis
A Add new fund
p Show portfolio
S Toggle selection mode
Space Toggle fund selection (in selection mode)
a Show NAV chart
r Show risk metrics
P Show holdings pie chart
h Show holdings tracking
m Show/edit annotation
s Sync fund data
d Delete fund
? Show help
Ctrl+K Command palette
q Quit

ViewDetail Mode

Key Action
j/k Move up/down
a Show NAV chart
r Show risk metrics
i Show analysis
v Add to compare
u Show real-time valuation
h Show holdings tracking
m Show/edit annotation
Esc Return to list

ViewChart Mode

Key Action
r Show risk metrics
Esc Return to detail

ViewRisk Mode

Key Action
a Show NAV chart
Esc Return to detail

ViewScreener Mode

Key Action
1-6 Filter by fund type
s Cycle sort field (name/scale/code)
Enter Apply filter
Esc Return to list

ViewCompare Mode

Key Action
j/k Select fund
x Remove from compare
Esc Return to list

ViewAnalyze Mode

Key Action
j/k Select fund
Enter Show fund detail
Esc Return to list

ViewAdd Mode

Key Action
Enter Add selected fund
Esc Return to list

ViewPortfolio Mode

Key Action
j/k Select portfolio
Enter View portfolio detail
n Create new portfolio
a Add fund to portfolio
Esc Return to list

ViewBacktest Mode

Key Action
F Set fund code
S Set start date
E Set end date
I Set initial amount
M Set monthly amount
Enter Run backtest
Esc Return to list

ViewSync Mode

Key Action
Esc Return to list

ViewHelp Mode

Key Action
Esc Return to previous view

License

MIT License

About

Go CLI + TUI 基金分析工具

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors