Xpersona
A

A股模拟账户交易

CLAWHUB · Unverified

A股模拟盘交易与回测技能。Use when 用户要启动模拟仓服务、创建多账户、下限价单/市价单、撤单、查询持仓资金、验证涨跌停成交逻辑或运行A股回测。 Skill: A股模拟账户交易 Owner: shouldnotappearcalm Summary: A股模拟盘交易与回测技能。Use when 用户要启动模拟仓服务、创建多账户、下限价单/市价单、撤单、查询持仓资金、验证涨跌停成交逻辑或运行A股回测。 Tags: a-share:1.0.0, backtest:1.0.0, latest:1.0.1, paper-trading:1.0.0, simulation:1.0.0 Version history: v1.0.1 | 2026-04-14T05:31:24.261Z | user - 新增服务控制脚本 paper_trading_ctl.py,支持服务一键启动、停止、状态检测和 macOS 启动项安装。 - 默认端口更改为 18765 ,CLI 及服务不再与常用开发端口冲突。 - 默认数据库路径迁移至用户数据目录(macOS/Linux),避免覆盖 skill 目录

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/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 s1746yykccqhx5c0wye32wcx3183nm3h:a-share-paper-trading
  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-shouldnotappearcalm-a-share-paper-trading/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

16,815 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: a-share-paper-trading
description: A股模拟盘交易与回测技能。Use when 用户要启动模拟仓服务、创建多账户、下限价单/市价单、撤单、查询持仓资金、验证涨跌停成交逻辑或运行A股回测。
---

# A股模拟盘

独立的模拟盘 skill。交易服务、CLI、账户、撮合与行情适配都在本目录内,不依赖其他 skill 脚本。

## 何时使用

- 启动或检查模拟盘服务
- 创建/重置账户
- 限价买卖、市价买卖、撤单
- 查询账户、持仓、订单、成交
- 验证涨跌停、T+1、收盘过期
- 跑简单回测

## 启动

```bash
SKILL_DIR="<本skill绝对路径>"
python3 "$SKILL_DIR/scripts/paper_trading_service.py" --host 127.0.0.1 --port 18765
```

默认监听 `http://127.0.0.1:18765`,默认数据库不再落在 skill 目录,而是落到用户级数据目录:

- macOS: `~/Library/Application Support/a-share-paper-trading/paper_trading.db`
- Linux: `${XDG_DATA_HOME:-~/.local/share}/a-share-paper-trading/paper_trading.db`

若本机该端口**已有**模拟盘进程在跑,**不要**再启动第二个实例:会报 `Address already in use`,且多进程可能争用同一 SQLite 库文件。启动前可先检查端口是否在监听,例如:

```bash
lsof -iTCP:18765 -sTCP:LISTEN
```

或向 `http://127.0.0.1:18765/accounts` 发 `GET`(CLI 默认 `--base-url` 与此一致)。已有服务时直接用 `paper_trade_cli.py` 即可。

更推荐使用控制脚本常驻运行:

```bash
python3 "$SKILL_DIR/scripts/paper_trading_ctl.py" start
python3 "$SKILL_DIR/scripts/paper_trading_ctl.py" status
python3 "$SKILL_DIR/scripts/paper_trading_ctl.py" stop
```

在 macOS 上,如需持续自启动,可安装 launchd:

```bash
python3 "$SKILL_DIR/scripts/paper_trading_ctl.py" install-launchd
```

服务会:
- 交易时段定时撮合挂单
- 非交易时段停止撮合
- 收盘后让当日未成单过期
- 定时写账户净值快照

可用启动参数:

- `--host`
- `--port`
- `--db-path`
- `--match-interval`
- `--valuation-interval`
- `--idle-valuation-interval`

默认端口与 CLI 基址已改为 `18765`,避免和常见本地开发服务冲突。

## CLI

```bash
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" create-account alpha --cash 500000
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" list-accounts
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" show-default-account
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" set-default-account alpha
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" reset-account alpha --cash 300000
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" add-cash alpha 50000 --note 入金
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" deduct-cash alpha 10000 --note 出金
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" buy alpha 600519 100 --market
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" sell alpha 600519 100 --price 1450
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" orders alpha
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" positions alpha
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" show-account alpha
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" trades alpha
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" cancel <order_id>
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" process-orders
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" run-snapshots
python3 "$SKILL_DIR/scripts/paper_trade_cli.py" backtest 600519 --strategy sma_cross --start 2025-01-01 --end 2026-03-31 --cash 200000
```

支持的 CLI 子命令:

- `create-account`
- `show-default-account`
- `set-default-account`
- `reset-account`
- `list-accounts`
- `show-account`
- `positions`
- `orders`
- `trades`
- `buy`
- `sell`
- `cancel`
- `add-cash`
- `deduct-cash`
- `process-orders`
- `run-snapshots`
- `backtest`

## Agent 执行规

README.md

# a-share-paper-trading

独立的 A 股模拟盘 skill,和数据 skill 解耦,负责:

- 多账户模拟交易
- 限价单、市价单、撤单
- 持仓、订单、成交、账户净值
- A 股规则校验与定时撮合
- 回测

## 当前规则

- A 股 `long-only`
- 买入数量必须是 `100` 股整数倍
- 卖出遵守 `T+1`
- 限价单价格必须符合 `0.01` 元最小报价单位
- 超过当日涨跌停的限价单直接拒绝
- 一字涨停默认买不进
- 一字跌停默认卖不出
- 市价单仅在连续竞价时段接受
- 集合竞价与午休时段不做自动撮合
- 行情时间戳不是当日时,视为陈旧行情,不执行市价成交
- 费用模型包含最低佣金、卖出印花税、沪市过户费
- 当日未成交 `DAY` 单收盘后过期

## 板块涨跌幅兜底

- 主板普通股:`10%`
- 创业板/科创板:`20%`
- 主板 ST:`5%`

优先使用实时 quote 自带的 `limit_up/limit_down`;只有上游缺失时才走这套兜底规则。

## 启动

默认配置已经改成用户级运行目录,不再把数据库写进 skill 目录:

- macOS: `~/Library/Application Support/a-share-paper-trading/`
- Linux: `${XDG_DATA_HOME:-~/.local/share}/a-share-paper-trading/`

默认 SQLite 路径:

- `~/Library/Application Support/a-share-paper-trading/paper_trading.db`(macOS)

默认监听地址:

- `http://127.0.0.1:18765`

前台启动:

```bash
python3 /Users/yanyun/dev/git_repo/ai-stock/ai-stock-data-v2/a-share-skill/a-share-paper-trading/scripts/paper_trading_service.py --host 127.0.0.1 --port 18765
```

推荐用控制脚本后台常驻:

```bash
python3 /Users/yanyun/dev/git_repo/ai-stock/ai-stock-data-v2/a-share-skill/a-share-paper-trading/scripts/paper_trading_ctl.py start
python3 /Users/yanyun/dev/git_repo/ai-stock/ai-stock-data-v2/a-share-skill/a-share-paper-trading/scripts/paper_trading_ctl.py status
python3 /Users/yanyun/dev/git_repo/ai-stock/ai-stock-data-v2/a-share-skill/a-share-paper-trading/scripts/paper_trading_ctl.py stop
```

若希望开机自动拉起,可安装 launchd:

```bash
python3 /Users/yanyun/dev/git_repo/ai-stock/ai-stock-data-v2/a-share-skill/a-share-paper-trading/scripts/paper_trading_ctl.py install-launchd
```

## 验证脚本

- 规则回归:`scripts/rule_regression_check.py`
- 真实股票校验:`scripts/real_stock_rule_validation.py`

其中真实股票校验会用 22 只真实股票做 3 轮验证,覆盖主板、创业板、科创板、ST。

_meta.json

{
  "ownerId": "kn7bf88r8ngbymhr9rydpm6exx822b2n",
  "slug": "a-share-paper-trading",
  "version": "1.0.1",
  "publishedAt": 1776144684261
}

skill-card.md

## Description:

Provides a local A-share paper-trading and backtesting workflow for agents to manage simulated accounts, paper orders, positions, fills, account snapshots, and A-share rule checks.

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

## Publisher:

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

### License/Terms of Use:

MIT-0

## Use Case:

External users and developers use this skill to operate local simulated A-share trading accounts, place and cancel paper orders, inspect cash, positions, orders, and trades, validate A-share trading rules, and run simple backtests.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill can run a persistent local paper-trading service and optional macOS launchd startup item.

Mitigation: Keep the service bound to 127.0.0.1, avoid exposing the port to a network, and use the documented stop or uninstall-launchd commands when background operation is no longer needed.

Risk: Simulated account state is stored in a local SQLite database under the user data directory by default.

Mitigation: Use the documented db-path or runtime home controls to choose an appropriate local storage location and avoid sharing the database unintentionally.

Risk: Paper trades and backtests depend on market-data freshness and external quote/history sources.

Mitigation: Treat outputs as simulation results, review account and order state before actions, and confirm market-data freshness before relying on fills.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/shouldnotappearcalm/skills/a-share-paper-trading)
- [README.md](README.md)
- [SKILL.md](SKILL.md)

## Skill Output:

**Output Type(s):** [guidance, shell commands, configuration, JSON responses, text]

**Output Format:** [Markdown guidance with shell commands and JSON service or CLI responses]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Operates a local HTTP service on 127.0.0.1:18765 by default and stores paper-trading state in a user-level SQLite database.]

## Skill Version(s):

1.0.1 (source: ClawHub 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 A股模拟账户交易 and adjacent AI workflows.