trading-skills
Tushare Pro 的综合金融数据命令行工具 | 7+ 交易技能模块 | 52+ 数据工具 | 生产就绪
一个专业级的技能开发和培训项目,提供全面的金融数据查询、分析和交易策略开发工具。采用模块化技能架构,完整的命令行实现以及广泛的测试覆盖。
📋 功能特性
- 7 个专业技能模块:股票、期货、指数、外汇、Alpha、概念、财务
- 52+ 数据查询工具:全面覆盖 Tushare Pro API
- 生产级命令行工具:类型安全的命令行客户端,支持缓存和多种输出格式
- 全面测试:覆盖 CLI、缓存、配置和数据输出的 992+ 测试
- 基于技能的学习:模块化知识库,帮助理解交易概念和数据
- 基于 Git 的配置管理:通过版本控制进行配置管理
📁 项目结构
trading-skills/
├── skills/ # Trading skill modules (7 categories)
│ ├── tushare-stock/ # Stock trading fundamentals and techniques
│ ├── tushare-futures/ # Futures contracts and strategies
│ ├── tushare-index/ # Index data and analysis
│ ├── tushare-forex/ # Foreign exchange trading
│ ├── tushare-alpha/ # Alpha factor generation
│ ├── tushare-concepts/ # Key trading and financial concepts
│ └── tushare-financial/ # Financial statement analysis
├── tools/tushare_cli/ # CLI implementation
│ ├── src/ # Python package
│ │ └── tushare_cli/ # Main CLI code
│ │ ├── commands/ # Command modules by category
│ │ ├── api.py # Tushare API wrapper
│ │ ├── cache.py # Response caching layer
│ │ ├── config.py # Configuration management
│ │ ├── output.py # Output formatting (JSON, CSV, Table)
│ │ └── main.py # CLI entry point
│ └── pyproject.toml # Package configuration
├── tests/ # Test suite (992+ tests)
│ └── tushare_cli/ # CLI tests
│ ├── test_cache.py # Cache functionality tests
│ ├── test_commands_*.py # Command tests by category
│ ├── test_config.py # Configuration tests
│ ├── test_main.py # CLI entry point tests
│ └── test_output.py # Output format tests
└── docs/plans/ # Design and implementation plans🚀 Quick Start
1. Install the CLI
# Clone the repository
git clone git@github.com:oopslink/trading-skills.git
cd trading-skillsInstall the CLI in development mode
pip install -e tools/tushare_cli/2. 设置你的Tushare令牌
在Tushare Pro获取你的令牌
# Option 1: Config file (recommended, persists across sessions)
tushare-cli config set-token YOUR_TOKENOption 2: Environment variable
export TUSHARE_TOKEN=YOUR_TOKENOption 3: Command-line flag
tushare-cli --token YOUR_TOKEN stock daily --ts-code 000001.SZ3. 在 Claude Code 中设置技能(可选)
如果您想在 Claude Code 中使用交易技能:
/plugin marketplace add oopslink/trading-skills
/plugin install trading-skills@trading-skills
这将安装所有7个交易技能模块,使它们作为参考知识在Claude Code对话中可用。4. 尝试你的第一个查询
# Get stock daily data
tushare-cli stock daily --ts-code 000001.SZGet in JSON format
tushare-cli stock daily --ts-code 000001.SZ --format jsonGet with caching enabled
tushare-cli --cache stock daily --ts-code 000001.SZ📚 API 分类
| 分类 | 技能 | 命令 | 数据工具 | |----------|--------|----------|------------| | 股票 | tushare-stock | 8+ 命令 | 日线,复权,周线,月线,行情 | | 期货 | tushare-futures | 7+ 命令 | 日线,连续,保证金 | | 指数 | tushare-index | 6+ 命令 | 日线,周线,成分股 | | 外汇 | tushare-forex | 4+ 命令 | 日线,开高低收 | | Alpha | tushare-alpha | 5+ 命令 | 因子,评分,回测 | | 概念 | tushare-concepts | 3+ 命令 | 概念股,更新 | | 财务 | tushare-financial | 6+ 命令 | 利润表,资产负债表,现金流,指标 |
🛠️ 使用示例
查询股票数据
# Daily prices for a stock
tushare-cli stock daily --ts-code 000001.SZ --start-date 20240101Weekly prices
tushare-cli stock weekly --ts-code 000001.SZStock quotes (real-time equivalent)
tushare-cli stock quotes --ts-code 000001.SZ查询期货数据
# Futures daily data
tushare-cli futures daily --ts-code IF --trade-date 20240115Continuous contract data
tushare-cli futures continuous --ts-code IF --start-date 20240101查询索引数据
# Index daily data
tushare-cli index daily --ts-code 000001.SHIndex constituents
tushare-cli index constituents --ts-code 000001.SH输出格式
# Table format (default)
tushare-cli stock daily --ts-code 000001.SZJSON format
tushare-cli stock daily --ts-code 000001.SZ --format jsonCSV format
tushare-cli stock daily --ts-code 000001.SZ --format csv🧪 Testing
Run the comprehensive test suite:
# Run all tests
pytest tests/Run tests with coverage
pytest tests/ --cov=tools/tushare_cli/src/tushare_cliRun specific test file
pytest tests/tushare_cli/test_commands_stock.pyRun with verbose output
pytest tests/ -v
项目包含 992+ 测试,涵盖:
- CLI 命令执行
- API 缓存行为
- 配置管理
- 输出格式化
- 错误处理
📖 技能文档
每个交易技能都有详细文档:
- tushare-stock - 股票交易基础
- tushare-futures - 期货市场与策略
- tushare-index - 指数分析
- tushare-forex - 外汇
- tushare-alpha - 阿尔法生成
- tushare-concepts - 交易概念
- tushare-financial - 财务报表
🔧 配置
设置配置
# Set Tushare token
tushare-cli config set-token YOUR_TOKENView current configuration
tushare-cli config showReset to defaults
tushare-cli config reset环境变量
TUSHARE_TOKEN=your_token_here
TUSHARE_CACHE_ENABLED=true
TUSHARE_CACHE_TTL=3600💾 Caching
The CLI includes intelligent response caching:
# Enable cache (cache TTL: 3600 seconds by default)
tushare-cli --cache stock daily --ts-code 000001.SZClear cache
tushare-cli cache clearCheck cache status
tushare-cli cache statusBenefits:
- 减少 API 调用次数和成本
- 提高查询性能
- 遵守速率限制
� Claude 代码集成
作为插件使用
该项目设计为与 Claude 代码无缝协作,作为完整的交易技能插件套件:
# Step 1: Add the plugin marketplace entry
/plugin marketplace add oopslink/trading-skillsStep 2: Install the plugin with all skill modules
/plugin install trading-skills@trading-skills安装内容包括:
- 所有7个交易技能模块(股票、期货、指数、外汇、Alpha、概念、金融)
- 完整的交易概念和Tushare API知识库
- 各数据类别的参考文档
- 与Claude Code技能系统的集成
在Claude Code中使用技能
安装完成后,您可以在Claude Code对话中引用任何技能:
@skill tushare-stock # Stock trading concepts and techniques
@skill tushare-futures # Futures market knowledge
@skill tushare-index # Index data and analysis
@skill tushare-forex # Foreign exchange trading
@skill tushare-alpha # Alpha factor generation
@skill tushare-concepts # Financial and trading terminology
@skill tushare-financial # Financial statement analysis本地开发环境设置
用于本地开发或不使用市场的情况:
# Clone the repository
git clone https://github.com/oopslink/trading-skills.git
cd trading-skillsInstall CLI tools
pip install -e tools/tushare_cli/Skills are automatically available in the project
Reference them via: @skill tushare-
📋 设计与规划
- Tushare CLI 设计 - 架构和 API 设计
- Tushare CLI 实现 - 实现细节
📝 许可
MIT 许可 - 详情见 LICENSE 文件
🤝 贡献
欢迎贡献!请注意:
- 所有新交易技能必须遵循 SKILL.md 格式
- 为新命令添加测试
- 根据需要更新文档
- 遵守项目结构规范
📞 支持
- 📖 查看技能文档,了解交易概念
- 🐛 在问题追踪器中报告问题
- 💬 在讨论区交流想法
为金融数据爱好者和交易者倾心打造 ❤️
--- Tranlated By Open Ai Tx | Last indexed: 2026-04-18 ---