返回列表
SKILLdatayes-fund-data

datayes-fund-data

0.0.2

| 基金与 ETF 数据查询 skill。通过 Python 脚本访问 Datayes API,覆盖净值、收益、持仓、 折溢价、资金流、基金经理、基金公司等场景。 用户提到基金、ETF、LOF、净值、持仓、收益、折溢价、基金经理、规模、资金流时使用。

已上线版本数: 2来源: local下载次数: 11

基金数据查询

前提条件

1. 获取 Datayes Token

访问 https://r.datayes.com/auth/token/login 获取可撤销的 API token。

2. 配置 Token

macOS / Linux:

export DATAYES_TOKEN='your-token'

Windows CMD:

set "DATAYES_TOKEN=你的token"

Windows PowerShell:

$env:DATAYES_TOKEN = "你的token"

永久设置(Windows):

setx DATAYES_TOKEN "你的token"

setx 只对新开的终端生效。

使用原则

  • 所有请求统一走 python3 scripts/datayes_api.py
  • 调接口前先查规格,再发正式请求
  • token 只从环境变量 DATAYES_TOKEN 读取
  • 脚本自动附带请求头 Authorization: Bearer <token>
  • 真实业务接口的 httpUrl 会先校验主机名,只允许 Datayes 受信任域名,避免把 token 发送到非 Datayes 地址

常用命令

python3 scripts/datayes_api.py spec fund_return_interval
python3 scripts/datayes_api.py call search_mutual_data --param keyword=华夏上证50ETF --param size=3
python3 scripts/datayes_api.py call fund_return_interval --param fundCode=510050 --param type=INTERVAL

推荐流程

  1. 先用 search_mutual_datafundCodeaccountIdsecurityId
  2. spec 查看目标接口的 httpMethodhttpUrlparametersInput
  3. call 发请求,脚本会按接口规格自动分配 query、body、path 参数
  4. 需要调试时,加 --show-request

常用接口

场景 nameEn 常用参数
基金搜索 search_mutual_data keyword, size
基金基本信息 fund_basic_info fundCode
区间收益 fund_return_interval fundCode, type=INTERVAL
年度收益 fund_return_yearly fundCode, type=YEARLY
折溢价率 fund_dprate_hk ticker, dateString, num
持仓分析 fund_holding_analysis fundCode, withExtra=true
ETF 资金流 get_fund_etf_mf ticker, beginDate, endDate
基金经理观点 fund_manager_viewpoint personId
ETF 排行 fund_market_ranking category, sortKey, pageSize, pageNum

约定

  • 缺 token 时直接报错,不回退到本地文件
  • POST 请求会自动带 Content-Type: application/json
  • 业务返回若不是成功码,会直接报错退出
  • search_mutual_data 会优先把更接近用户关键词的结果排在前面
  • 返回值默认是格式化 JSON;需要更紧凑的输出时可加 --compact

执行约束

  • 禁止网页搜索: 本 Skill 依赖 Datayes API,不使用 WebSearch/WebFetch
  • 减少探索: 优先使用已知接口(见常用接口表),避免重复查询规格
  • 明确边界: 不处理非 Datayes 数据源,不做非基金/ETF 类查询

跨平台注意事项

  • Windows: 脚本已内置 UTF-8 输出处理(_ensure_utf8_stdio),推荐使用 CMD 执行
  • 所有脚本执行时可添加 -X utf8 参数确保编码正确
  • 路径参数使用正斜杠 / 或双反斜杠 \\(Windows)