cTrader CLI 的 AI 工作流程¶
本文介绍如何在知道目标但不熟悉具体命令语法时, 借助 AI 助手使用 cTrader CLI。用自然语言描述任务, AI 助手会生成命令或脚本, 供你审核后运行。
注意
为了让 AI 助手生成正确的命令, 请向其提供 cTrader CLI 的 GitHub 仓库, 以便它在编写脚本之前查阅完整的命令参考文档。
AI 助手能提供哪些帮助 ¶
如果你能用自然语言描述目标, 却不知道对应的 cTrader CLI 命令, AI 助手就能派上用场。 AI 助手可以帮助你:
- 将描述的目标转换为可供审核的 cTrader CLI 命令。
- 解释不熟悉的命令、选项或输出。
- 分析错误消息的可能原因并提出修复建议。
- 检查
.cbotset文件、optimize参数文件或回测配置。 - 根据你已手动执行的一系列命令编写可重复使用的脚本。
- 使用技能, 更可靠地生成命令。
命令与提示词的区别 ¶
请明确区分以下两者。
- 命令是你在终端中输入的文本, 例如
ctrader-cli candles --account=<account-id> --symbol=EURUSD --period=h1 --count=200。 - 提示词是你发送给 AI 助手、用来描述操作目标的文本。 AI 助手会返回一条命令, 供你审核并运行。
注意
本文中的提示词用于复制到 AI 助手中。而CLI 参考文档中的命令用于在终端中执行。
编写安全的提示词 ¶
向 AI 助手提供充分的背景信息并明确限制条件, 提示词才能发挥更好的效果。请包含以下信息:
- 用简明的语言描述你的目标。
- 提供相关背景信息, 例如操作系统和计划使用的命令组。
- 要求 AI 助手不得编造 cTrader CLI 不支持的命令或选项。
- 要求使用 cTrader CLI 当前公开版本的命令语法。
- 要求明确列出它做出的任何假设。
- 要求在继续操作前指出缺失的信息。
- 要求提供安全、便于逐步审核的操作流程, 而非一条复杂的组合命令。
- 使用占位符代替文件路径、账户号码和交易品种等实际值, 避免泄露真实凭据。
通用提示词 ¶
以下提示词示例展示了如何结合 cTrader CLI 使用 AI。
解释找到的命令 ¶
请 AI 助手逐行解释命令, 指出可能有风险的选项, 并标记看似编造的内容。随后让它查阅对应的参考条目, 核对完整的选项列表。
Explain what this cTrader CLI command does, option by option, and describe any
effect it would have on a trading account:
<paste the command here>
If any option looks incorrect or risky, say so. Do not assume options that are
not shown.
诊断错误 ¶
向 AI 助手提供命令、错误输出及相关背景信息, 让它建议最可能的原因和安全的解决方法。必要时, 可按照故障排除流程操作。
I ran this cTrader CLI command:
<paste the command, with credentials removed>
It returned this error:
<paste the error output>
Suggest the most likely cause and a safe way to fix it. List the checks I should
make first. Do not invent commands or options that cTrader CLI does not provide,
and state your assumptions.
编写可重复使用的脚本 ¶
根据常见命令组, 将你已手动执行的一系列命令整理为可在首次发生错误时停止的脚本, 并确保脚本文件中不包含凭据。
I run these cTrader CLI commands in order by hand:
<list the commands, with credentials removed>
Draft a script for <operating system> that runs them in sequence and stops if a
command fails. Keep credentials in placeholders or environment variables, not
in the script. Add a comment above each command explaining what it does, and
add a note reminding me to review the script before running it on a live
account.
交易相关提示词 ¶
以下提示词针对具体的交易场景。
注意
运行任何 AI 生成的命令或脚本之前, 请先审核:
- 确认每条命令和每个选项都出现在CLI 参考文档中。
- 核对账户号码、交易品种、交易量和价格。
- 先运行只读命令, 确认配置正确。
- 先在模拟账户上测试交易命令, 再用于真实账户。
修改或取消挂单 ¶
请 AI 助手使用订单命令调整尚未成交的限价挂单价格、止损和止盈, 或直接取消该订单。
Write a cTrader CLI command that changes the price of pending order <order-id>
on account <account-id> to <new-price>, with stop-loss <price> and take-profit
<price>. Tell me how to cancel the same order instead.
通过脚本运行 cBot ¶
向 AI 助手提供 cBot 文件路径及相关参数, 以便通过run 命令启动一个实例。
Write a cTrader CLI command that runs <path-to-algo-file> on account
<account-id> with symbol <symbol> and period <period>. Show me how to pass cBot
parameters on the command line and how to make the CLI exit when the cBot stops.
为持仓添加保护设置 ¶
请 AI 助手使用持仓命令, 为尚未设置止损和止盈的持仓添加这两项保护。
Position <position-id> on account <account-id> is open on <symbol> with no
stop loss or take profit. Write the cTrader CLI command that sets stop-loss
<price> and take-profit <price> on it. A position has one take-profit level,
so use one `--tp` price. Show the command, no preview output.
操作详情
- cTrader CLI 目前不支持对市价订单设置市价范围 (market range)。
--limit-range选项仅适用于止损限价单。 - 通过 cTrader CLI 提交的挂单不会过期; 目前无法设置到期日期 (good till date), 也无法选择止损触发方式。
- cTrader CLI 目前无法设置或修改交易标签和备注, 但可以在列出持仓、订单和交易历史记录时读取并显示这些内容。通过 cTrader CLI 运行的 cBot 可以使用自身代码添加标签。在 cTrader Windows 和 Mac 应用程序中, 启用 标签 和 备注 列, 即可在 Trade Watch 面板中显示这两项信息。
- cTrader CLI 仅支持一个止损价位和一个止盈价位。目前不支持移动止损、保本保护或多级止盈。
警告
AI 助手只是辅助工具, 不能代替你的判断。你仍需对在自己账户上执行的每条命令负责。