chore: 接入 Tushare skill 与 MCP Server

- .agents/skills/tushare + .claude/skills 符号链接:自然语言查A股/财报/资金流/板块等数据
- .mcp.json:tushareMcp(HTTP 型,token 鉴权),重启 Claude Code 后生效
- skills-lock.json:skill 版本锁定

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 15:03:40 +08:00
parent 528357c3f5
commit a9bf369a41
10 changed files with 2509 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
基金数据获取示例脚本
"""
import tushare as ts
import pandas as pd
import os
# 读取环境变量中的token, 或者读取本地记录的token
token = os.getenv('TUSHARE_TOKEN') or ts.get_token()
# 初始化pro接口
pro = ts.pro_api(token)
def get_fund_list():
"""
获取基金列表
"""
try:
data = pro.fund_basic(market='E', status='L', fields='ts_code,fund_name,fund_type,found_date,issue_date,delist_date')
print("基金列表获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取基金列表失败:{e}")
return None
def get_fund_nav(ts_code, start_date, end_date):
"""
获取基金净值数据
"""
try:
data = pro.fund_nav(ts_code=ts_code, start_date=start_date, end_date=end_date)
print(f"{ts_code}基金净值数据获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取基金净值数据失败:{e}")
return None
def get_fund_manager():
"""
获取基金经理数据
"""
try:
data = pro.fund_manager(limit=10, fields='ts_code,fund_name,manager_name,begin_date,end_date')
print("基金经理数据获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取基金经理数据失败:{e}")
return None
def main():
"""
主函数
"""
print("===== tushare 基金数据获取示例 =====")
# 获取基金列表
fund_list = get_fund_list()
if fund_list is not None:
# 获取第一只基金的代码
ts_code = fund_list['ts_code'].iloc[0]
print(f"\n使用基金代码:{ts_code}")
# 获取基金净值数据最近30天
import datetime
end_date = datetime.datetime.now().strftime('%Y%m%d')
start_date = (datetime.datetime.now() - datetime.timedelta(days=30)).strftime('%Y%m%d')
print(f"\n获取基金净值数据:{start_date}{end_date}")
get_fund_nav(ts_code, start_date, end_date)
# 获取基金经理数据
print("\n获取基金经理数据:")
get_fund_manager()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
股票数据获取示例脚本
"""
import tushare as ts
import pandas as pd
import os
# 读取环境变量中的token, 或者读取本地记录的token
token = os.getenv('TUSHARE_TOKEN') or ts.get_token()
# 初始化pro接口
pro = ts.pro_api(token)
def get_stock_list():
"""
获取股票列表
"""
try:
data = pro.stock_basic(exchange='', list_status='L', fields='ts_code,symbol,name,area,industry,list_date')
print("股票列表获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取股票列表失败:{e}")
return None
def get_daily_data(ts_code, start_date, end_date):
"""
获取股票日线数据
"""
try:
data = pro.daily(ts_code=ts_code, start_date=start_date, end_date=end_date)
print(f"{ts_code}日线数据获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取日线数据失败:{e}")
return None
def get_financial_data(ts_code, year, quarter):
"""
获取财务指标数据
"""
try:
data = pro.fina_indicator(ts_code=ts_code, year=year, quarter=quarter)
print(f"{ts_code}财务指标数据获取成功:")
print(data.head())
return data
except Exception as e:
print(f"获取财务指标数据失败:{e}")
return None
def main():
"""
主函数
"""
print("===== tushare 股票数据获取示例 =====")
# 获取股票列表
stock_list = get_stock_list()
if stock_list is not None:
# 获取第一只股票的代码
ts_code = stock_list['ts_code'].iloc[0]
print(f"\n使用股票代码:{ts_code}")
# 获取日线数据最近30天
import datetime
end_date = datetime.datetime.now().strftime('%Y%m%d')
start_date = (datetime.datetime.now() - datetime.timedelta(days=30)).strftime('%Y%m%d')
print(f"\n获取日线数据:{start_date}{end_date}")
get_daily_data(ts_code, start_date, end_date)
# 获取财务数据(最近一年)
current_year = datetime.datetime.now().year
print(f"\n获取财务数据:{current_year-1}年 第4季度")
get_financial_data(ts_code, current_year-1, 4)
if __name__ == "__main__":
main()