Skip to main content
Glama

A股数据 API (A-Share Data API)

ashare_backtest

量化回测:按策略跑历史收益(返回收益/最大回撤/交易次数/净值曲线等)。用户问'回测一下/这个策略收益如何/买卖点效果/最大回撤'用这个。⚠️ 两种模式:mode=single(默认)单标的实时计算,须配 code;mode=portfolio 组合(须用 strategies 里的组合策略,区间受预置批次限制)。⚠️ weighting=inv_vol(按波动率倒数配仓)仅组合模式 + 机构版可用。⚠️ 想知道有哪些策略/参数范围,先调 ashare_strategies;想一次跑多标的×多策略,用 ashare_backtest_batch。⚠️ 付费工具(需 Key):单标的 Standard(¥29.9)起;组合 / 批量回测为 Pro 及以上,且有独立日额度,余量可查 ashare_usage。

Input Schema

NameRequiredDescriptionDefault
endNo结束日期 YYYY-MM-DD(mode=single 时可用)
codeNo股票代码:sh600667(mode=single 时必填)
modeNosingle 单标的实时(默认,须配 code)/ portfolio 组合(预置区间)single
startNo起始日期 YYYY-MM-DD(mode=single 时可用)
strategyYes策略名(如 buy_hold / mom20 / lowvol20;清单见 ashare_strategies)
weightingNo组合配仓:equal 等权(默认)/ inv_vol 波动率倒数(仅组合模式 + 机构版)
initial_cashNo初始资金(默认 1000000 = 100 万)
include_equityNo是否返回净值曲线(默认 false —— 曲线数据量大,只在需要画图时开)

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / weighting / description
      Previous value: -"组合配仓:equal 等权(默认)/ inv_vol 波动率倒数(仅组合模式 + 不限量版)"New value: +"组合配仓:equal 等权(默认)/ inv_vol 波动率倒数(仅组合模式 + 机构版)"
  2. Added

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so well: it discloses the two modes and their constraints, that portfolio intervals are limited by preset batches, that inv_vol requires portfolio mode plus institutional tier, that it is a paid tool with tiers (¥29.9+ Standard, Pro+ for portfolio/batch) and separate daily quota checkable via ashare_usage. It stops short of stating latency/expected runtime or failure behavior, which keeps it below 5.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose and trigger phrases are front-loaded, and the ⚠️ blocks make the high-risk constraints (mode/code pairing, tier requirement, cost) scannable. It is dense and emoji-heavy, but essentially every warning carries decision-relevant information, so little is wasted.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be explained. For an 8-parameter, paid, mode-dependent tool, the description covers everything blocking a correct call: the mode/code pairing, weighting availability, prerequisite lookup via ashare_strategies, quota/pricing gating, and the batch alternative.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the schema descriptions already state the mode=single/code dependency, the inv_vol restriction, and the include_equity data-volume tradeoff, so the description mostly restates structured data. It does consolidate the cross-parameter conditional logic into a usable decision framing, but adds little meaning that the schema does not already carry — baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ('量化回测:按策略跑历史收益') plus the concrete outputs (收益/最大回撤/交易次数/净值曲线), so the agent knows exactly what comes back. It explicitly differentiates from siblings by naming ashare_backtest_batch and ashare_strategies as the tools for multi-target runs and strategy discovery.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives direct user-phrase triggers ('回测一下/这个策略收益如何/买卖点效果/最大回撤') that select this tool, and explicit exclusions routing to ashare_strategies (to see strategy lists) and ashare_backtest_batch (multi-target × multi-strategy). Nothing about tool selection is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources