tushare-base

v1.0.0

Fetch Chinese stock and futures market data via Tushare API. Supports stock quotes, futures data, company fundamentals, and macroeconomic indicators. Use when the user needs financial data from Chinese markets. Requires TUSHARE_TOKEN environment variable.

3· 2.7k·11 current·14 all-time
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Suspicious
medium confidence
!
Purpose & Capability
The skill's name, description, SKILL.md, and scripts/market.py all clearly rely on a TUSHARE_TOKEN for the Tushare API, but the registry metadata lists no required environment variables or primary credential — a mismatch between claimed purpose and declared requirements.
Instruction Scope
SKILL.md gives concrete instructions: register at tushare.pro, set TUSHARE_TOKEN in your shell, pip install tushare/pandas, and run scripts/market.py with specific commands. The instructions focus on the stated purpose and do not ask the agent to read unrelated files or send data to unknown endpoints.
Install Mechanism
There is no install spec (instruction-only plus a bundled script). The code uses the public 'tushare' Python package; SKILL.md recommends installing it via pip. No downloads from arbitrary URLs or archive extraction are present.
!
Credentials
The code and documentation expect a single API secret (TUSHARE_TOKEN), which is proportionate to the functionality. However, the registry metadata failing to declare this required environment variable is an incoherence that could mislead users and permissioning systems.
Persistence & Privilege
The skill does not request permanent presence (always=false) and does not modify other skills or system-wide settings. It relies on runtime environment variables but does not request elevated platform privileges.
What to consider before installing
This skill appears to implement exactly what it claims (fetching Chinese market data via Tushare) and the included script looks benign, but the registry metadata omission is a red flag. Before installing or running it: (1) Confirm the publisher/source — no homepage is provided. (2) Don't paste your TUSHARE_TOKEN into shared or public files; prefer exporting it in a shell session or use a secrets manager rather than committing it to dotfiles. (3) Review scripts/market.py yourself (you have the file) to ensure no hidden endpoints or logging of secrets; the visible code only calls the tushare library. (4) Install dependencies in a virtualenv or sandbox (pip3 install --user or venv) to limit impact. (5) Ask the publisher/registry owner to update the metadata to declare TUSHARE_TOKEN as a required credential so automated checks and users are not misled.

Like a lobster shell, security has layers — review code before you run it.

latestvk97ctrxg3vc3376bm56rdyh3qd80kyya
2.7kdownloads
3stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

Tushare 金融数据接口

获取中国 A 股市场和期货市场的实时及历史数据。

前提条件

1. 注册 Tushare 账号

访问 https://tushare.pro/register 注册账号并获取 API Token。

2. 配置 Token

# 添加到 ~/.zshrc
export TUSHARE_TOKEN="your-api-token-here"

然后执行:

source ~/.zshrc

3. 安装依赖

pip3 install tushare pandas --user

快速开始

获取股票列表

python3 scripts/market.py stock_basic

获取日线行情

python3 scripts/market.py daily --ts_code 000001.SZ --start_date 20240101 --end_date 20240131

获取实时行情

python3 scripts/market.py realtime 000001

股票数据

股票基础信息

python3 scripts/market.py stock_basic
python3 scripts/market.py stock_basic --exchange SSE  # 仅上交所
python3 scripts/market.py stock_basic --exchange SZSE  # 仅深交所

日线行情

# 获取单只股票近期数据
python3 scripts/market.py daily --ts_code 000001.SZ

# 指定日期范围
python3 scripts/market.py daily --ts_code 600519.SH --start_date 20240101 --end_date 20240131

# 获取指定交易日全市场数据
python3 scripts/market.py daily --trade_date 20240115

周线行情

# 获取周线数据
python3 scripts/market.py weekly --ts_code 000001.SZ

# 指定日期范围
python3 scripts/market.py weekly --ts_code 600519.SH --start_date 20230101 --end_date 20240131

月线行情

# 获取月线数据
python3 scripts/market.py monthly --ts_code 000001.SZ

# 指定日期范围
python3 scripts/market.py monthly --ts_code 600519.SH --start_date 20200101 --end_date 20240131

股票代码格式

  • 深交所:000001.SZ, 000002.SZ, 300001.SZ (创业板)
  • 上交所:600000.SH, 600519.SH, 688001.SH (科创板)

实时行情

python3 scripts/market.py realtime 000001
python3 scripts/market.py realtime 600519

资金流向

# 获取指定股票资金流向
python3 scripts/market.py moneyflow --ts_code 000001.SZ

# 获取指定日期全市场资金流向
python3 scripts/market.py moneyflow --trade_date 20240115

公司信息

python3 scripts/market.py company

期货数据

期货合约基础信息

python3 scripts/market.py fut_basic

# 指定交易所
python3 scripts/market.py fut_basic --exchange CFFEX  # 中金所
python3 scripts/market.py fut_basic --exchange SHFE   # 上期所
python3 scripts/market.py fut_basic --exchange DCE    # 大商所
python3 scripts/market.py fut_basic --exchange CZCE   # 郑商所

交易所代码

  • CFFEX - 中国金融期货交易所
  • SHFE - 上海期货交易所
  • DCE - 大连商品交易所
  • CZCE - 郑州商品交易所
  • INE - 上海国际能源交易中心

期货日线行情

# 获取铜期货数据
python3 scripts/market.py fut_daily --ts_code CU.SHF

# 获取沪深300股指期货
python3 scripts/market.py fut_daily --ts_code IF.CFX

# 指定日期范围
python3 scripts/market.py fut_daily --ts_code RB.SHF --start_date 20240101 --end_date 20240131

期货代码格式

  • 上期所:CU.SHF (铜), RB.SHF (螺纹钢), AU.SHF (黄金)
  • 大商所:M.DCE (豆粕), I.DCE (铁矿石)
  • 郑商所:SR.CZC (白糖), CF.CZC (棉花)
  • 中金所:IF.CFX (沪深300), IC.CFX (中证500)

期货持仓排名

python3 scripts/market.py fut_holding --trade_date 20240115 --symbol CU

宏观经济

GDP 数据

python3 scripts/market.py gdp

输出示例:

📈 GDP数据 (88 条):

2023年4季度: GDP 347909亿元, 增速 5.2%
2023年3季度: GDP 319992亿元, 增速 4.9%
...

CPI 数据

python3 scripts/market.py cpi

PPI 数据

python3 scripts/market.py ppi

命令速查表

命令功能示例
stock_basic股票基础信息--exchange SSE
daily日线行情--ts_code 000001.SZ --start_date 20240101
weekly周线行情--ts_code 000001.SZ --start_date 20230101
monthly月线行情--ts_code 000001.SZ --start_date 20200101
realtime实时行情000001
moneyflow资金流向--ts_code 000001.SZ
company公司信息-
fut_basic期货基础信息--exchange SHFE
fut_daily期货日线--ts_code CU.SHF
fut_holding持仓排名--symbol CU
gdpGDP数据-
cpiCPI数据-
ppiPPI数据-

常见问题

错误:请设置 TUSHARE_TOKEN 环境变量 → 在 ~/.zshrc 中添加 export TUSHARE_TOKEN="your-token" 并执行 source ~/.zshrc

错误:没有数据返回 → 检查股票/期货代码格式是否正确(如:000001.SZ, CU.SHF)

错误:权限不足 → Tushare 部分接口需要积分或付费权限,请在官网查看接口权限要求

如何获取股票代码?

python3 scripts/market.py stock_basic | grep "平安"

参考文档

Comments

Loading comments...