Skip to main content
Glama

EasyQuant Research

组合回测(按条件选股定期调仓)

backtest_portfolio

在 A 股全市场(或 market=cn_etf 全部场内 ETF、us_equity 美股、hk_stock 港股、cn_future 期货品种,后四者表达式只能用价量字段;期货可用 short_n 做空)按选股条件和排序定期调仓回测:用前一交易日数据选股、调仓日开盘价先卖后买,停牌不交易、开盘涨停买不进、跌停卖不出,100 股整手,计入手续费与印花税;财务数据按公告日次日生效,股票池包含区间内退市的股票。条件与排序都写成因子表达式(字段与函数见 catalog)。全市场首次计算一个新表达式约需 1~2 分钟:返回 status=RUNNING 时,按 retry_after_seconds 调 get_job。回答用户时只能引用返回的数字,并原样转述 caveats;不对任何个股给买卖建议。

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "backtest_portfolio"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNo回测结束日 YYYY-MM-DD,默认最近一个交易日
exitsNo止盈止损(可选)
startNo回测起始日 YYYY-MM-DD,默认 3 年前;最长 5 年
top_nNo按 rank_by 取前 N 只;填了 rank_by 时必填。不填 rank_by 时忽略(全部入选)
marketNo市场:cn_stock A 股(默认),cn_etf 场内 ETF,us_equity 美股,hk_stock 港股,cn_future 期货品种(后四者只能用价量字段,见 catalog)
rank_byNo排序表达式,例如 dv_ttm(股息率)或 -pe_ttm;不填则符合条件的全部入选
short_nNo仅期货:做空 rank_by 排名末 N 个品种(与做多的前 top_n 不重叠),有空头时多空名义各半
conditionNo选股条件表达式,结果非 0 即入选,例如 (roe_yearly > 15) * (close > MA(close, 60))。「且」用 *,「或」用 MAX(a, b)。可以不填,只按排序取前 N
rebalanceNo调仓频率,默认 monthly
weightingNo权重:equal 等权(默认),rank 按排名加权
rank_orderNo排序方向:desc 越大越好(默认),asc 越小越好
max_position_pctNo单只股票最大仓位 %,可选
capital_budget_pctNo资金预算 %:部署的名义价值占资金的比例,默认 100。股票类最多 100(其余留现金);期货最多 300(杠杆 = 名义 ÷ 资金,300 即 3 倍;多空合计)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior5/5

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

No annotations exist, so the description carries the full burden, and it does: execution model (用前一交易日数据选股、调仓日开盘价先卖后买), trading constraints (停牌不交易、涨停买不进、跌停卖不出、100 股整手), cost model (手续费与印花税), data lag (财务数据按公告日次日生效), survivorship handling (包含退市股票), and async semantics with a 1~2 分钟 first-computation wait. This far exceeds typical disclosure.

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?

Dense but front-loaded: universe and mechanism come first, then the async contract and answer rules. Some clauses restate what the schema already says (market variants, futures short), but nothing is padded or vague.

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

Completeness4/5

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

For a 13-parameter, nested-object tool with no output schema, the description covers the execution model, async polling, and caveat handling. What is missing is any description of the result payload's shape beyond status/retry_after_seconds, which matters somewhat given there is no output schema.

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 description coverage is 100%, so the schema already documents all 13 parameters, including enum meanings and limits; the baseline is therefore 3. The description adds only cross-cutting context (后四者只能用价量字段, 期货可用 short_n 做空) that largely repeats the market/short_n descriptions, adding little new per-parameter meaning.

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?

States a specific verb and resource (定期调仓回测) along with the universe scope (A 股全市场, or market=cn_etf/us_equity/hk_stock/cn_future). The selection logic (选股条件和排序), async behavior, and sibling routing (catalog, get_job) are stated up front, so an agent can tell this apart from a timing backtest or a screen without opening the schema.

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

Usage Guidelines4/5

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

Clear operational guidance: expressions require fields/functions from catalog, and status=RUNNING means call get_job using retry_after_seconds. It also sets answer-handling rules (only cite returned numbers, reproduce caveats, no individual buy/sell advice). It does not explicitly say when to prefer this over backtest_timing, which is the only gap.

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.