mcpField
F
fund-assistant

fund-assistant

github.com/xer97Other5427 installsUpdated 37w ago
Repository

About fund-assistant

fund-assistant is a fund lookup and portfolio-tracking skill for people monitoring funds and investments. It combines query scripts with locally stored, per-user holdings and distinguishes daily gains from total holding returns.

Key features

  1. 01Query estimates, details, and historical NAV
  2. 02Search funds and view holdings or managers
  3. 03Check market indices and capital flows
  4. 04Manage local portfolios by user
  5. 05Export holdings and calculate returns

Use cases

  1. 01Check intraday estimates and historical NAV
  2. 02Track fund holdings for different users
  3. 03Calculate returns from estimates and purchase costs

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/xer97/fund-assistant --skill fund-assistant

After installing, type/fund-assistantin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

.gitignore
README.md
references/
api.md
storage.md
scripts/
portfolio.py
fund_api.py

Details

From the project README

基金投资助手

脚本命令

基金 API(scripts/fund_api.py)
python scripts/fund_api.py query 001618,000001   # 查询实时估值
python scripts/fund_api.py search 白酒           # 搜索基金
python scripts/fund_api.py detail 001618         # 基金详情
python scripts/fund_api.py history 001618 y      # 历史净值 (y/3y/6y/n/3n/5n)
python scripts/fund_api.py position 001618       # 持仓明细
python scripts/fund_api.py manager 001618        # 基金经理
python scripts/fund_api.py index                 # 大盘指数
python scripts/fund_api.py flow                  # 资金流向
python scripts/fund_api.py north                 # 北向资金
持仓管理(scripts/portfolio.py)
python scripts/portfolio.py init                 # 初始化数据目录
python scripts/portfolio.py list                 # 查看持仓
python scripts/portfolio.py add 001618 1000 1.5  # 添加持仓(代码 份额 成本)
python scripts/portfolio.py update 001618 shares=1500  # 更新持仓
python scripts/portfolio.py remove 001618        # 删除持仓
python scripts/portfolio.py user 老婆            # 切换用户
python scripts/portfolio.py users                # 列出所有用户
python scripts/portfolio.py export portfolio.json  # 导出持仓
python scripts/portfolio.py import portfolio.json  # 导入持仓

数据存储

位置:.fund-assistant/users/{用户名}/portfolio.json(项目本地目录)

{"funds": [{"code": "001618", "name": "天弘中证食品饮料", "shares": 1000, "cost": 1.5}]}

详细结构:references/storage.md

收益计算

// 当日预估收益(今天赚/亏多少)
dailyGains = (gsz - nav) * shares;
dailyGainsRate = gszzl;  // 直接用API返回的涨跌幅

// 持仓总收益(从买入到现在总共赚/亏多少)
costGains = (gsz - cost) * shares;
costGainsRate = ((gsz - cost) / cost) * 100;

重要区分:

  • 当日收益 = (估算净值 - 昨日净值) × 份额 → 今天赚了多少
  • 持仓收益 = (估算净值 - 成本价) × 份额 → 总共赚了多少

字段说明:

  • nav: 昨日净值(已公布)
  • gsz: 估算净值(盘中实时)
  • gszzl: 估算涨跌幅(%)
  • gztime: 估值更新时间
  • cost: 用户买入成本价

操作流程

用户意图执行步骤
查询基金fund_api.py query {代码} → 解析 JSON 输出
添加持仓portfolio.py add {代码} {份额} {成本}
查看持仓收益portfolio.py list → fund_api.py query {代码列表} → 计算收益
切换用户portfolio.py user {用户名}
查看行情fund_api.py index

API 响应字段

详见 references/api.md

注意事项

  1. 首次使用需运行 portfolio.py init 初始化数据目录
  2. 实时估值使用天天基金接口 http://fundgz.1234567.com.cn/js/{code}.js
  3. 交易时段:9:30-11:30, 13:00-15:00(排除节假日)
  4. QDII基金估值可能延迟,部分新发基金无估值数据

Comments

Markdown supported