Xpersona
C

China Stock Quant

CLAWHUB · Unverified

A-share quantitative analysis toolkit. Use when user wants to analyze Chinese stocks, backtest trading strategies, calculate technical indicators (MACD/KDJ/R... Skill: China Stock Quant Owner: miio-jinglin Summary: A-share quantitative analysis toolkit. Use when user wants to analyze Chinese stocks, backtest trading strategies, calculate technical indicators (MACD/KDJ/R... Tags: akshare:1.0.0, china-stock:1.0.0, latest:1.0.0, quant:1.0.0, trading:1.0.0 Version history: v1.0.0 | 2026-03-24T14:31:13.898Z | user Initial release Archive index: Archive v1.0.0: 8 files, 13736 byte

62
Rank
84
Safety
1.5k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.5K 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 s17dhzte6nv2cg8p6np7hs215583gmjn:china-stock-quant
  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-miio-jinglin-china-stock-quant/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

12,301 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: china-stock-quant
description: >-
  A-share quantitative analysis toolkit. Use when user wants to analyze Chinese stocks,
  backtest trading strategies, calculate technical indicators (MACD/KDJ/RSI/Bollinger),
  implement ETF day-trading strategies (grid trading, MA crossover, volatility),
  fetch A-share/ETF market data, or perform risk assessment (max drawdown, Sharpe ratio).
  Triggers on: A股分析, 量化交易, ETF做T, 技术指标, 回测, stock analysis, quantitative trading,
  MACD, KDJ, RSI, 布林带, 网格交易, akshare, 选股策略, backtest.
---

# A股量化分析

基于 akshare(免费无需token)的A股量化分析工具包。

## 快速开始

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

## 工作流

### 1. 获取数据

```python
from scripts.fetch_data import *
# ETF日线
df = fetch_etf_daily("159915", "20250101", "20260301")
# 个股日线
df = fetch_stock_daily("000001", "20250101", "20260301")
# ETF分时(日内做T)
df = fetch_etf_intraday("159915")
# 实时行情
df = fetch_realtime("159915")
```

详见 `references/api-reference.md`

### 2. 计算技术指标

```python
from scripts.technical_indicators import *
# 单指标
df['macd'], df['signal'], df['hist'] = calc_macd(df['close'])
df['k'], df['d'], df['j'] = calc_kdj(df['high'], df['low'], df['close'])
df['rsi'] = calc_rsi(df['close'], period=14)
df['upper'], df['mid'], df['lower'] = calc_bollinger(df['close'])
df['vol_ratio'] = calc_volume_ratio(df['volume'])
# 一键全部
df = add_all_indicators(df)
# 信号检测
signals = detect_signals(df)
```

### 3. 策略回测

```python
from scripts.backtest import *
result = run_backtest(
    df,
    strategy="grid",           # grid / ma_cross / bollinger
    initial_capital=100000,
    grid_num=10,               # 网格数(grid策略)
    ma_short=5, ma_long=20,    # 均线参数(ma_cross策略)
    stop_loss=0.05,            # 止损比例
    take_profit=0.10,          # 止盈比例
)
print(result.summary())
```

### 4. 风险评估

```python
from scripts.backtest import assess_risk
risk = assess_risk(df['close'])
# returns: max_drawdown, sharpe_ratio, annual_volatility, calmar_ratio
```

## 策略库

ETF日内做T策略详解见 `references/strategies.md`,包含:

| 策略 | 适用场景 | 核心逻辑 |
|------|---------|---------|
| 网格交易 | 震荡市 | 价格跌破网格线买入,涨回卖出 |
| 均线交叉 | 趋势市 | 短均线上穿长均线买入,下穿卖出 |
| 布林带回归 | 均值回归 | 触下轨买入,触上轨卖出 |
| 波动率突破 | 突破行情 | ATR放大+价格突破时追入 |

## 风控参数(内置默认值)

```python
RISK_PARAMS = {
    "max_position_pct": 0.25,    # 单只持仓上限
    "stop_loss": 0.05,           # 止损线 5%
    "take_profit": 0.10,         # 止盈线 10%
    "max_daily_turnover": 0.05,  # 日内做T最大换手
    "min_trade_amount": 10000,   # 最低交易金额(元)
    "max_drawdown_limit": 0.15,  # 最大回撤警戒线
}
```

## 资源文件

- `scripts/fetch_data.py` — 数据获取
- `scripts/technical_indicators.py` — 技术指标计算
- `scripts/backtest.py` — 回测引擎+风险评估
- `references/strategies.md` — 策略库详解
- `references/api-reference.md` — akshare接口速查

_meta.json

{
  "ownerId": "kn78439kyewydmc1kr38vrq7wn83hy3j",
  "slug": "china-stock-quant",
  "version": "1.0.0",
  "publishedAt": 1774362673898
}

references/api-reference.md

# akshare API Quick Reference

akshare is a free, no-token-required Python library for Chinese financial data.

## Install
```bash
pip install akshare pandas
```

## Key Interfaces

### ETF Data

| Function | Parameters | Returns |
|----------|-----------|---------|
| `ak.fund_etf_hist_em(symbol)` | symbol="159915", period="daily", start_date, end_date | OHLCV DataFrame |
| `ak.fund_etf_hist_min_em(symbol)` | symbol="159915", period="1" (1/5/15/30/60 min) | Intraday OHLCV |
| `ak.fund_etf_spot_em()` | — | All ETF realtime quotes |
| `ak.fund_etf_category_sina(symbol)` | symbol="ETF基金" | ETF list by category |

### Stock Data

| Function | Parameters | Returns |
|----------|-----------|---------|
| `ak.stock_zh_a_hist(symbol)` | symbol="000001", period="daily", start_date, end_date | OHLCV DataFrame |
| `ak.stock_zh_a_spot_em()` | — | All A-share realtime quotes |
| `ak.stock_individual_info_em(symbol)` | symbol="000001" | Stock basic info |
| `ak.stock_board_concept_name_em()` | — | Concept sector list |
| `ak.stock_board_concept_cons_em(symbol)` | symbol="AI手机" | Sector constituents |

### Index Data

| Function | Parameters | Returns |
|----------|-----------|---------|
| `ak.index_zh_a_hist(symbol)` | symbol="000300", period="daily" | Index OHLCV |
| `ak.stock_index_pe_lg(symbol)` | symbol="上证50" | PE/PB valuation |
| `ak.index_stock_cons(symbol)` | symbol="000300" | Index constituents |

### Market Breadth

| Function | Returns |
|----------|---------|
| `ak.stock_market_activity_legu()` | Market activity metrics |
| `ak.stock_zt_pool_em(date)` | Limit-up stocks |
| `ak.stock_zt_pool_dtgc_em(date)` | Limit-up then opened stocks |
| `ak.stock_rank_lxsz_ths()` | Rising/falling stock count |

## Common Patterns

### Fetch ETF daily data
```python
import akshare as ak
df = ak.fund_etf_hist_em(
    symbol="159915",
    period="daily",
    start_date="20250101",
    end_date="20260324",
    adjust="qfq"  # 前复权
)
```

### Fetch intraday 1-minute
```python
df = ak.fund_etf_hist_min_em(
    symbol="159915",
    period="1",
    adjust="qfq"
)
```

### Standard column names (rename after fetch)
```python
df = df.rename(columns={
    "日期": "date",
    "开盘": "open",
    "收盘": "close",
    "最高": "high",
    "最低": "low",
    "成交量": "volume",
    "成交额": "amount",
    "涨跌幅": "pct_chg",
})
```

### Check trading hours
```python
from datetime import datetime
now = datetime.now()
# A-share: 09:30-11:30, 13:00-15:00
# ETF: same, but some have extended hours
```

## Rate Limits
- akshare uses web scraping — respect rate limits
- Add `time.sleep(0.5)` between batch requests
- Cache results locally when possible

## Error Handling
```python
import akshare as ak
try:
    df = ak.fund_etf_hist_em(symbol="159915", period="daily")
    if df.empty:
        print("No data returned — check symbol or date range")
except Exception as e:
    print(f"Fetch failed: {e}")
    # Fallback: try again after delay, or use cached data
```

references/strategies.md

# ETF Day-Trading Strategies (做T策略)

## Grid Trading (网格交易)

### Principle
Divide price range into N grids. Buy one unit when price drops to a grid line, sell when it rises to the next.

### Parameters
- `grid_num`: Number of grids (default 10)
- `grid_range`: (low, high) price range — auto-detected from 30-day range if not set
- `position_per_grid`: Capital allocated per grid buy (capital / grid_num)

### Entry/Exit Rules
```
Buy:  price <= current_grid_price AND no position at this grid
Sell: price >= next_upper_grid AND has position from lower grid
```

### Best For
- Sideways markets (震荡市)
- ETFs with moderate volatility (日波动 1-3%)
- Avoid in strong trends

### Optimization
- Reduce grid_num in high-volatility periods
- Use ATR to set dynamic grid spacing
- Add time filter: no new positions after 14:30 (close to market close)

---

## MA Crossover (均线交叉)

### Principle
Buy when short MA crosses above long MA (golden cross), sell on death cross.

### Parameters
- `ma_short`: Short moving average period (default 5)
- `ma_long`: Long moving average period (default 20)
- MA type: SMA or EMA

### Entry/Exit Rules
```
Buy:  MA_short[t] > MA_long[t] AND MA_short[t-1] <= MA_long[t-1]
Sell: MA_short[t] < MA_long[t] AND MA_short[t-1] >= MA_long[t-1]
```

### Best For
- Trending markets (趋势市)
- Works better on daily timeframe for swing trades
- Use 5/20 for intraday, 10/30 for swing

### Optimization
- Add volume confirmation: buy signal requires volume > 20-day avg
- Add RSI filter: avoid buy when RSI > 70 (overbought)

---

## Bollinger Band Mean Reversion (布林带回归)

### Principle
Price tends to revert to mean. Buy near lower band, sell near upper band.

### Parameters
- `period`: Bollinger band period (default 20)
- `std_dev`: Standard deviations (default 2)

### Entry/Exit Rules
```
Buy:  price <= lower_band AND RSI < 30
Sell: price >= upper_band OR RSI > 70
Stop: price < lower_band * 0.97
```

### Best For
- Mean-reverting markets
- ETFs with stable historical range
- Avoid in breakout scenarios

### Optimization
- Use %B (percent B) for finer entry timing
- Combine with volume spike at lower band for higher probability

---

## Volatility Breakout (波动率突破)

### Principle
Enter when price breaks out of recent range with expanding volatility.

### Parameters
- `atr_period`: ATR calculation period (default 14)
- `atr_multiplier`: Breakout threshold (default 1.5)
- `lookback`: Range calculation window (default 20)

### Entry/Exit Rules
```
Breakout Up:   close > high[lookback] AND ATR > ATR_avg * atr_multiplier → Buy
Breakout Down: close < low[lookback] AND ATR > ATR_avg * atr_multiplier → Sell (short)
Exit:          ATR contracts below ATR_avg, or fixed time exit (2 days)
```

### Best For
- Markets entering new trends
- Earnings releases, policy announcements
- Use sparingly — 20-30% of trades max

---

## Strategy Selection Guide

| Market Condition | Primary Strategy | Secondary |
|-----------------|-----------------|-----------|
| 震荡 (ADX < 20) | Gr

skill-card.md

## Description:

A-share quantitative analysis toolkit for fetching China stock and ETF data, calculating technical indicators, backtesting strategies, and assessing portfolio risk.

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

## Publisher:

[miio-jinglin](https://clawhub.ai/user/miio-jinglin)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and analysts use this skill to retrieve A-share and ETF market data, calculate MACD, KDJ, RSI, Bollinger bands, and volume indicators, run basic strategy backtests, and summarize risk metrics. It supports analysis and backtesting workflows only, not automated trade execution.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Market data fetching makes outbound requests to third-party data sources through akshare.

Mitigation: Run in a virtual environment, pin dependency versions where practical, and allow network access only when market-data retrieval is intended.

Risk: Backtest results, technical indicators, and strategy signals can be mistaken for trading advice.

Mitigation: Treat outputs as analysis and backtesting support only; require human review before any investment or trading decision.

## Reference(s):

- [akshare API Quick Reference](references/api-reference.md)
- [ETF Day-Trading Strategies](references/strategies.md)

## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, guidance]

**Output Format:** [Markdown with Python and shell command examples, plus tabular or dictionary-style analysis outputs]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May produce pandas DataFrame summaries, backtest result summaries, risk metric dictionaries, and strategy guidance.]

## Skill Version(s):

1.0.0 (source: server release metadata)

## 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 China Stock Quant and adjacent AI workflows.