# 对比

> 在主图上叠加其他品种。

Source: https://kcq.nebutra.com/zh/docs/agent/tools/comparisons


<Callout>
  由固定提交的图表源码生成（

  [`1aa5e22`](https://github.com/TsekaLuk/KLineChartQuant/blob/1aa5e22c61313a34d08878ad895e604e0d4a85e9/packages/core/src/foundation/agent/chartToolRegistry.ts)

  ）。工具说明保留模型实际收到的英文原文，不做翻译。
</Callout>

comparisons_list [#comparisons_list]

<ToolMeta label="List comparison symbols" safety="read-only" safetyLabel="只读" mode="可并行" origin="图表内核" source="https://github.com/TsekaLuk/KLineChartQuant/blob/1aa5e22c61313a34d08878ad895e604e0d4a85e9/packages/core/src/engine/data/comparisonCommands.ts#L148" sourceLabel="源码" />

List every comparison symbol currently overlaid on the chart. Each item exposes the stable identity, the complete symbol spec, and the assigned line color. Use identity with comparison\_remove.

**参数**

此工具不需要输入。

<ToolSchema name="comparisons_list" label="JSON Schema" />

comparison_create [#comparison_create]

<ToolMeta label="Add comparison symbol" safety="destructive" safetyLabel="修改图表" mode="按序执行" origin="图表内核" source="https://github.com/TsekaLuk/KLineChartQuant/blob/1aa5e22c61313a34d08878ad895e604e0d4a85e9/packages/core/src/engine/data/comparisonCommands.ts#L169" sourceLabel="源码" />

Add one comparison symbol to the main chart. symbol is required and is resolved against the active market-data sources so the real exchange, id, and params are used; source, exchange, and assetClass restrict which instrument the code may resolve to; assetClass only accepts a known class, never unknown. primary is the chart main symbol; its source, period, and adjust only fill omitted fields and never override the resolved instrument. When several distinct instruments match, nothing is added and the result is \{ status: "ambiguous", candidates: \[...] }: ask the user to choose with the ask\_user tool, then retry with the chosen candidate's source and exchange (add assetClass only when its class is not unknown). Never pick a candidate yourself. Fails with an actionable reason only when the symbol cannot be resolved or is already compared; an unknown market is rejected.

**参数**

| 字段                             | 类型                  | 必填 | 约束                                                                                         | 说明 |
| ------------------------------ | ------------------- | -- | ------------------------------------------------------------------------------------------ | -- |
| <code>symbol</code>            | <code>string</code> | 是  | min length <code>1</code>                                                                  |    |
| <code>market</code>            | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>exchange</code>          | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>source</code>            | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>assetClass</code>        | <code>enum</code>   | —  | one of <code>"stock", "index", "fund", "etf", "future", "option", "forex", "crypto"</code> |    |
| <code>period</code>            | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>adjust</code>            | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary</code>           | <code>object</code> | —  | closed                                                                                     |    |
| <code>primary.symbol</code>    | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.market</code>    | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.exchange</code>  | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.source</code>    | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.period</code>    | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.adjust</code>    | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.startDate</code> | <code>string</code> | —  | min length <code>1</code>                                                                  |    |
| <code>primary.endDate</code>   | <code>string</code> | —  | min length <code>1</code>                                                                  |    |

**最小输入** · 仅含必填字段，占位值由 schema 推导。

```json
{
  "symbol": "<symbol>"
}
```

<ToolSchema name="comparison_create" label="JSON Schema" />

comparison_remove [#comparison_remove]

<ToolMeta label="Remove comparison symbol" safety="destructive" safetyLabel="修改图表" mode="按序执行" origin="图表内核" source="https://github.com/TsekaLuk/KLineChartQuant/blob/1aa5e22c61313a34d08878ad895e604e0d4a85e9/packages/core/src/engine/data/comparisonCommands.ts#L219" sourceLabel="源码" />

Remove one comparison line by its identity from comparisons\_list; a matching symbol code also works. The primary symbol and chart mode remain unchanged.

**参数**

| 字段                    | 类型                  | 必填 | 约束                        | 说明 |
| --------------------- | ------------------- | -- | ------------------------- | -- |
| <code>identity</code> | <code>string</code> | 是  | min length <code>1</code> |    |

**最小输入** · 仅含必填字段，占位值由 schema 推导。

```json
{
  "identity": "<identity>"
}
```

<ToolSchema name="comparison_remove" label="JSON Schema" />

comparisons_clear [#comparisons_clear]

<ToolMeta label="Clear comparison symbols" safety="destructive" safetyLabel="修改图表" mode="按序执行" origin="图表内核" source="https://github.com/TsekaLuk/KLineChartQuant/blob/1aa5e22c61313a34d08878ad895e604e0d4a85e9/packages/core/src/engine/data/comparisonCommands.ts#L240" sourceLabel="源码" />

Remove every comparison line while keeping the primary symbol and chart mode unchanged. Returns the number of removed symbols.

**参数**

此工具不需要输入。

<ToolSchema name="comparisons_clear" label="JSON Schema" />
