Xpersona
A

Akshare Backtest

CLAWHUB · Unverified

A股量化策略回测工具。基于 AkShare 获取历史行情数据,模拟执行强势股轮动策略。 支持自定义初始资金、回测周期、止盈止损参数。输出收益曲线、买卖记录、月度统计。 适用于验证"涨停基因+均线多头+量价配合"等短线策略的历史表现。 Skill: Akshare Backtest Owner: gracexiaoo Summary: A股量化策略回测工具。基于 AkShare 获取历史行情数据,模拟执行强势股轮动策略。 支持自定义初始资金、回测周期、止盈止损参数。输出收益曲线、买卖记录、月度统计。 适用于验证"涨停基因+均线多头+量价配合"等短线策略的历史表现。 Tags: latest:1.0.3 Version history: v1.0.3 | 2026-04-01T03:21:56.910Z | auto - 增加详细使用说明与策略介绍,方便用户理解回测流程与买卖规则。 - 明确输出文件格式,新增 daily_values.csv 和 trades.csv 说明。 - 提供完整的命令行调用示例和可配置参数说明。 - 补充风险提示及结果解读,帮助用户正确理解回测数据。 - 列出依赖安装步骤及未来扩展方向。 Archive index: Archive

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17cq1jzew7f21gg9tvh9g9wgx83jy70:akshare-backtest
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-gracexiaoo-akshare-backtest/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

5,513 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: akshare_backtest
description: >
  A股量化策略回测工具。基于 AkShare 获取历史行情数据,模拟执行强势股轮动策略。
  支持自定义初始资金、回测周期、止盈止损参数。输出收益曲线、买卖记录、月度统计。
  适用于验证"涨停基因+均线多头+量价配合"等短线策略的历史表现。
metadata:
  {
    "openclaw": {
      "install": [
        {
          "id": "pip-deps",
          "kind": "python",
          "package": "akshare",
          "label": "Install AkShare"
        },
        {
          "id": "pip-deps",
          "kind": "python",
          "package": "pandas",
          "label": "Install Pandas"
        },
        {
          "id": "pip-deps",
          "kind": "python",
          "package": "numpy",
          "label": "Install NumPy"
        }
      ]
    }
  }
---

# A股量化策略回测 (AkShare Backtest)

基于 AkShare 免费行情数据,实现 A股量化策略的历史回测。

## 策略说明

### 默认策略:强势股轮动

| 条件 | 说明 |
|------|------|
| 涨停基因 | 近5日有涨停,或单日涨幅>7% |
| 均线多头 | 5日均线>10日均线>20日均线 |
| 量价配合 | 今日成交量 > 5日均量 × 1.2 |

### 买卖规则

| 触发条件 | 操作 |
|----------|------|
| +5% | 卖出 1/3 |
| +8% | 再卖出 1/3(剩余1/3继续持有) |
| +10%以上 | 尾盘不涨停则全部清仓 |
| -3% | 无条件止损 |
| 持仓满3天 | 第3天尾盘强制平仓 |

### 仓位管理

- 初始资金:默认 5 万(可配置)
- 单票仓位:20%-35%
- 同时持仓:最多 3 只
- 每日保留 30% 现金

## 安装依赖

```bash
pip install akshare pandas numpy
```

## 使用方法

### 命令行调用

```bash
python {baseDir}/scripts/backtest.py --capital 50000 --start 20240101 --end 20240630
```

### 参数说明

| 参数 | 说明 | 默认值 |
|------|------|--------|
| `--capital` | 初始资金(元) | 50000 |
| `--start` | 开始日期(YYYYMMDD) | 20240101 |
| `--end` | 结束日期(YYYYMMDD) | 当前日期 |
| `--output` | 输出目录 | miaoxiang/backtest |
| `--query` | 自然语言参数 | 暂不支持 |

### 示例

```bash
# 回测2024年全年
python scripts/backtest.py --capital 100000 --start 20240101 --end 20241231

# 回测2024下半年
python scripts/backtest.py --start 20240701 --end 20241231
```

## 输出文件

| 文件 | 说明 |
|------|------|
| `daily_values.csv` | 每日净值曲线(日期、现金、持仓市值、总净值、收益率) |
| `trades.csv` | 全部买卖记录(日期、股票、买卖价、数量、收益率、原因) |

## 结果解读

回测脚本会输出:

```
========== 回测结果 ==========
初始资金:     50,000
最终净值:     58,234
总收益率:     +16.47%
年化收益率:   +32.18%
最大回撤:     -12.35%
交易次数:     45
卖出次数:     42
胜率:         58.5%
==============================
```

### 关键指标

- **总收益率**:回测期间累计收益
- **年化收益率**:折算为年化收益(按250交易日/年)
- **最大回撤**:从峰值到谷底的最大跌幅
- **胜率**:盈利交易 / 总卖出次数

## 风险提示

1. **历史不代表未来**:回测结果仅供参考,不构成投资建议
2. **滑点成本**:实际交易会有滑点,回测可能偏乐观
3. **流动性风险**:小盘股可能无法按回测价格买入
4. **手续费**:未计入佣金和印花税(建议手动扣除)

## 扩展方向

- 接入实时行情实现模拟交易
- 添加大盘择时(沪深300均线过滤)
- 多策略组合轮动
- 优化止盈止损参数
- 接入实盘券商API

_meta.json

{
  "ownerId": "kn74vjkdb3y33jhwjd67b8za9s82k8hb",
  "slug": "akshare-backtest",
  "version": "1.0.3",
  "publishedAt": 1775013716910
}

skill-card.md

## Description:

A-share quantitative backtesting skill that uses AkShare market data to run a short-term rotation strategy and report portfolio performance, trades, and monthly statistics.

This skill is ready for commercial/non-commercial use.

## Publisher:

[gracexiaoo](https://clawhub.ai/user/gracexiaoo)

### License/Terms of Use:

MIT-0

## Use Case:

External users and developers use this skill to run historical A-share strategy backtests, inspect simulated trade records, and compare portfolio performance over a configurable date range. Results are for research and evaluation, not investment advice.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Backtest output can be mistaken for investment advice or a predictor of future market performance.

Mitigation: Treat results as research, independently validate assumptions, and avoid using the output for live trading decisions without separate financial review.

Risk: Python dependencies are not pinned, so future package changes could alter behavior or installation results.

Mitigation: Install in an isolated Python environment and pin reviewed versions of akshare, pandas, and numpy before repeated or production-like use.

Risk: The script writes CSV results to the selected output directory.

Mitigation: Run with a dedicated output directory and review generated files before sharing or reusing them.

Risk: Some documented strategy settings and output filenames differ from the script behavior.

Mitigation: Inspect the script parameters and generated filenames before relying on the documented defaults or comparing runs.

## Reference(s):


## Skill Output:

**Output Type(s):** [Text, Markdown, Code, Shell commands, Configuration, Files, Guidance]

**Output Format:** [Markdown guidance with Python command examples, console summaries, and CSV file outputs]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [The bundled script writes dragon_lowpick_daily.csv and dragon_lowpick_trades.csv to the configured output directory.]

## Skill Version(s):

1.0.3 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Akshare Backtest and adjacent AI workflows.