ctrader-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Overview

概述

The cTrader CLI is a headless client for the cTrader platform: accounts and symbols, market data, orders and positions, history, price alerts, and the full cBot lifecycle, all without the desktop UI.
It offers two invocation pipelines, and choosing the right one is the single most valuable thing to internalize. Batch verbs return compact machine-readable payloads for scripting. Shell-routed verbs run through the interactive command shell, which reaches a much larger command surface and returns a richer payload. The same verb can be served by either pipeline, and the pipeline you land in determines the JSON casing, the payload wrapper, and which flags are accepted. Everything below exists to make that choice deliberate rather than accidental.
The CLI runs natively on every platform. On Windows it installs with
winget install Spotware.cTrader.CLI
as
ctrader-cli.exe
; on macOS and Linux it installs from the Spotware Homebrew tap (
brew tap spotware/tap https://github.com/spotware/homebrew-tap
, then
brew install spotware/tap/ctrader-cli
) as
ctrader-cli
— the same CLI with identical verbs, flags, and environment variables. Command shapes throughout this skill use the Windows executable name; on macOS or Linux drop the
.exe
suffix and everything else carries over unchanged (
references/setup.md
covers the per-OS credential setup).
Behavior described here matches build
5.9.0.38
; re-confirm details that matter on a newer build.
cTrader CLI是cTrader平台的无头客户端:无需桌面UI即可操作账户与交易品种、获取市场数据、管理订单与持仓、查看历史记录、设置价格预警,以及完成cBot的全生命周期管理。
它提供两种调用管道,理解并选择正确的管道是最关键的要点。批处理(Batch) 动词返回紧凑的机器可读负载,适用于脚本编写。Shell路由(Shell-routed) 动词通过交互式命令Shell运行,可调用的命令范围更广,返回的负载更丰富。同一个动词可通过任意一种管道调用,管道类型决定了JSON的大小写、负载包装方式以及可接受的参数。以下内容旨在帮助你有意识地做出正确选择,而非误选管道。
CLI可在所有平台原生运行。在Windows系统上,可通过
winget install Spotware.cTrader.CLI
安装,文件名为
ctrader-cli.exe
;在macOS和Linux系统上,需先添加Spotware的Homebrew源(
brew tap spotware/tap https://github.com/spotware/homebrew-tap
),再执行
brew install spotware/tap/ctrader-cli
进行安装,文件名为
ctrader-cli
——不同平台的CLI拥有完全相同的动词、参数和环境变量。本技能中所有命令示例均使用Windows可执行文件名;在macOS或Linux系统上,只需去掉
.exe
后缀,其余内容保持不变(
references/setup.md
涵盖了各平台的凭证设置方法)。
本文描述的行为对应版本
5.9.0.38
;若使用更新版本,请重新确认关键细节。

Invocation discipline

调用规范

Use this template for every call, adjusting only the timeout:
bash
timeout 30 ctrader-cli.exe <verb> [flags] -e </dev/null 1>out.txt 2>err.txt; echo "EXIT:$?"
Each element earns its place:
  • timeout
    bounds every call. Use 30 seconds for data commands and 240 for
    build
    ,
    backtest
    , and
    run
    .
  • </dev/null
    guarantees termination. With stdin redirected the process never waits for a prompt; it completes the requested work, reaches end of stream, and exits.
  • Separate
    1>
    and
    2>
    captures, with unique file names per invocation, keep the payload away from the command echo. Concurrent sessions on a shared machine can otherwise clobber fixed names.
  • Read
    $?
    directly. A pipe reports the exit status of the last stage, so piping into
    head
    or
    grep
    discards the CLI's own code.
Budget roughly 1.5 to 2 seconds of process start-up per call. When you need several read-only results, fold them into one process through piped stdin, which amortizes that cost:
bash
printf 'accounts\nsymbols\nq\n' | timeout 60 ctrader-cli.exe -e --account=<n>
Two commands run in 4.1 to 4.4 seconds this way versus 5.1 to 5.8 seconds as separate calls. Blank lines and lines beginning with
#
are ignored, so a piped script may carry comments. Note that a piped session is a shell session: its output arrives in shell-routed shape (camelCase, wrapped objects), not batch shape.
On Windows, bash consumes backslashes in unquoted arguments, so always double-quote Windows paths:
--report-json="C:\reports\run.json"
.
每次调用请使用以下模板,仅需调整超时时间:
bash
timeout 30 ctrader-cli.exe <verb> [flags] -e </dev/null 1>out.txt 2>err.txt; echo "EXIT:$?"
每个元素都有其作用:
  • timeout
    限制每次调用的时长。数据查询命令使用30秒,
    build
    backtest
    run
    命令使用240秒。
  • </dev/null
    确保进程终止。重定向标准输入后,进程不会等待用户输入,完成请求的工作后即会结束并退出。
  • 使用独立的
    1>
    2>
    捕获输出,且每次调用使用唯一的文件名,避免命令回显干扰负载内容。若在共享机器上并发执行会话,固定文件名可能会被覆盖。
  • 直接读取
    $?
    的值。管道会报告最后一个阶段的退出状态,因此若将输出通过管道传递给
    head
    grep
    ,会丢失CLI自身的退出码。
每次调用进程启动大约需要1.5到2秒。若需要获取多个只读结果,可通过管道将多个命令合并到一个进程中执行,从而分摊启动成本:
bash
printf 'accounts\
symbols\
q\
' | timeout 60 ctrader-cli.exe -e --account=<n>
通过这种方式执行两个命令耗时4.1到4.4秒,而分开执行则需要5.1到5.8秒。空行和以
#
开头的行会被忽略,因此管道脚本可包含注释。请注意,管道会话属于Shell会话:其输出采用Shell路由格式(小驼峰命名、对象包装),而非批处理格式。
在Windows系统中,bash会解析未加引号参数中的反斜杠,因此Windows路径需始终使用双引号包裹:
--report-json="C:\\reports\\run.json"

Routing: batch verbs and shell-routed verbs

路由:批处理动词与Shell路由动词

Six verbs have a genuine batch code path:
periods
,
accounts
,
symbols
,
metadata
,
run
,
backtest
— the six that
--help
itself names for BATCH mode.
create
and
build
appear in
--help
's BATCH MODE reference section, but they execute through the command shell in every invocation shape — banner first, then a camelCase JSON payload, and without
-q
a fall-through into the interactive menu — so call them with
-q
. Everything else is reached only through the command shell.
-q
/
--quick
is a routing flag, not a quiet flag. Adding it to one of the six batch verbs moves the whole invocation into the shell pipeline, which changes the payload casing, wraps it under a command-name key, prepends a banner and a timestamp header, and can change which flags are accepted.
Verb classCall itPayload
Batch data (
accounts
,
symbols
,
metadata
)
without
-q
PascalCase JSON, no banner
Batch streaming (
run
,
backtest
)
without
-q
backtest
: plain-text progress log, then a final compact PascalCase JSON summary;
run
: streams the algo's output until stopped
Scaffolding (
create
,
build
)
with
-q
camelCase JSON after the banner and timestamp header
Shell-routed (
account
,
account-stats
,
symbol
,
sessions
,
price
,
prices
,
candles
,
orders
,
positions
,
order
,
position
,
exposure
,
orders-history
,
deals
,
alerts
,
alert
,
indicators
,
indicator
)
with
-q
camelCase wrapped under the command name, after a banner
periods
bare, no flags at allplain text, no credentials needed
Concrete consequences worth knowing before your first call:
  • accounts -e
    does not accept
    --account
    ;
    symbols -e
    requires it. The two batch verbs differ deliberately.
  • Batch
    symbols
    returns
    Id
    ,
    Name
    ,
    Description
    per entry. The same verb with
    -q
    returns
    name
    ,
    description
    ,
    category
    ,
    assetClass
    — it swaps the numeric
    Id
    for classification fields rather than extending the batch schema, so use batch
    symbols
    whenever you need symbol ids.
  • periods
    takes no flags whatsoever; passing
    -e
    to it returns
    Error: Parameter e is not allowed
    .
  • Shell-routed verbs take their arguments as explicit flags at launch time.
    symbol --symbol=EURUSD
    works; a bare
    EURUSD
    positional does not.
  • -q
    is recommended rather than required for shell-routed reads: it skips the command menu that otherwise prints after the payload, keeping stdout minimal for parsing. Without it the call still terminates cleanly under redirected stdin, printing the menu once and then
    Bye.
    at exit 0.
  • An unrecognized verb routes to the shell menu and exits 0 under closed stdin, so never treat "exit 0" alone as proof the verb you intended actually ran.
ctrader-cli.exe --commands
prints the full shell command reference, needs no credentials and no network, and is the zero-cost way to confirm a verb's exact argument forms.
有六个动词拥有真正的批处理执行路径:
periods
accounts
symbols
metadata
run
backtest
——这六个动词在
--help
的BATCH模式下被列出。
create
build
出现在
--help
的BATCH MODE参考部分,但无论以何种方式调用,它们都会通过命令Shell执行——先显示横幅,然后返回小驼峰命名的JSON负载,若未添加
-q
参数则会进入交互式菜单——因此调用时需添加
-q
。其余所有动词仅能通过命令Shell调用。
-q
/
--quick
是一个路由参数,而非静默参数。将其添加到六个批处理动词中的任意一个,会将整个调用切换到Shell管道,这会改变负载的大小写格式、将负载包装在命令名称对应的键下、添加横幅和时间戳头部,还可能改变可接受的参数。
动词类别调用方式负载格式
批处理数据(
accounts
,
symbols
,
metadata
不添加
-q
大驼峰命名JSON,无横幅
批处理流(
run
,
backtest
不添加
-q
backtest
:纯文本进度日志,最后返回紧凑的大驼峰命名JSON摘要;
run
:持续输出算法结果直至停止
脚手架(
create
,
build
添加
-q
横幅和时间戳头部之后的小驼峰命名JSON
Shell路由(
account
,
account-stats
,
symbol
,
sessions
,
price
,
prices
,
candles
,
orders
,
positions
,
order
,
position
,
exposure
,
orders-history
,
deals
,
alerts
,
alert
,
indicators
,
indicator
添加
-q
小驼峰命名,包裹在命令名称对应的键下,位于横幅之后
periods
直接调用,无任何参数纯文本,无需凭证
首次调用前需要了解的实际影响:
  • accounts -e
    不接受
    --account
    参数;
    symbols -e
    则需要该参数。这两个批处理动词的设计故意不同。
  • 批处理模式的
    symbols
    返回每个条目的
    Id
    Name
    Description
    。添加
    -q
    参数后,同一动词会返回
    name
    description
    category
    assetClass
    ——它用分类字段替换了数字
    Id
    ,而非扩展批处理模式的 schema,因此当你需要交易品种ID时,请使用批处理模式的
    symbols
  • periods
    不接受任何参数;若传递
    -e
    会返回
    Error: Parameter e is not allowed
  • Shell路由动词在启动时需使用显式参数。
    symbol --symbol=EURUSD
    有效;而直接传入
    EURUSD
    作为位置参数无效。
  • 对于Shell路由的读取操作,推荐添加
    -q
    参数:它会跳过负载输出后显示的命令菜单,使标准输出保持简洁以便解析。若未添加该参数,在重定向标准输入的情况下,调用仍会正常终止,显示一次菜单后输出
    Bye.
    并以0状态码退出。
  • 若调用未识别的动词,会进入Shell菜单并在标准输入关闭时以0状态码退出,因此切勿仅以"退出码0"作为验证目标动词是否实际执行的依据。
ctrader-cli.exe --commands
会打印完整的Shell命令参考,无需凭证和网络连接,是确认动词确切参数形式的零成本方式。

Credentials

凭证

Two credential shapes work non-interactively. Prefer the first, which keeps secrets out of the process arguments entirely.
bash
undefined
两种凭证格式支持非交互式调用。优先选择第一种,可完全避免将机密信息暴露到进程参数中。
bash
undefined

Environment-variable credentials: CTID and PWD-FILE are set in the environment.

环境变量凭证:CTID和PWD-FILE已在环境中设置。

timeout 30 ctrader-cli.exe accounts -e </dev/null
timeout 30 ctrader-cli.exe accounts -e </dev/null

Explicit credentials.

显式凭证。

timeout 30 ctrader-cli.exe accounts --ctid="<id>" --pwd-file="<path>" </dev/null

The mapping rule for `-e` is exact: an environment variable is consulted only when its name matches the long option name verbatim, hyphens preserved, compared case-insensitively, and only when `-e` is on the command line. So `CTID`, `PWD-FILE`, and `ACCOUNT` are read; `account` also works; `PWD_FILE` with an underscore is not consulted, and `ACCOUNT_ID` yields `Error: Option account does not exist`. An explicit flag always wins over the matching variable. `--environment-variables` is the long form of `-e`.

`--ctid` identifies the user (the cTrader ID, an email address) in every path; the trading account is selected separately with `--account`. The password file's first line is the password. `--pwd-file` is the flag name; there is no short alias. `--password` belongs to interactive use and should not appear in a scripted invocation.

Never read or print the value of `CTID` or `PWD-FILE`. Check presence and length only, and remember that `PWD-FILE` contains a hyphen, so `$PWD-FILE` does not interpolate it:

```bash
val="$(printenv 'PWD-FILE')"; echo "PWD-FILE length: ${#val}"
The shell banner prints the cTrader ID on stdout as
Connecting as <id>...
. Redact it when quoting captured output into reports or anything shared.
timeout 30 ctrader-cli.exe accounts --ctid="<id>" --pwd-file="<path>" </dev/null

`-e`的映射规则非常严格:仅当环境变量的名称与长选项名称完全匹配(保留连字符,大小写不敏感),且命令行中添加了`-e`参数时,才会读取该环境变量。因此会读取`CTID`、`PWD-FILE`和`ACCOUNT`;`account`也有效;而带有下划线的`PWD_FILE`不会被读取,`ACCOUNT_ID`会返回`Error: Option account does not exist`。显式参数始终优先于对应的环境变量。`--environment-variables`是`-e`的长格式。

`--ctid`在所有路径中用于标识用户(即cTrader ID,一个电子邮件地址);交易账户需通过`--account`单独选择。密码文件的第一行即为密码。`--pwd-file`是参数名称,无短别名。`--password`仅适用于交互式使用,不应出现在脚本化调用中。

切勿读取或打印`CTID`或`PWD-FILE`的值。仅检查其是否存在及长度,且需注意`PWD-FILE`包含连字符,因此`$PWD-FILE`无法正确插值:

```bash
val="$(printenv 'PWD-FILE')"; echo "PWD-FILE length: ${#val}"
Shell横幅会在标准输出中打印
Connecting as <id>...
,其中包含cTrader ID。当将捕获的输出引用到报告或共享内容中时,请将其脱敏。

Reading the output

读取输出

Locate the payload structurally, never by a fixed line count or byte offset. Scan for the timestamp header line or the first balanced
{
or
[
; transient connection-retry lines can precede a payload that still arrives successfully.
Batch payloads begin at byte zero: no banner, no header, flat PascalCase JSON. Shell-routed payloads carry a banner of several lines whose wording varies, then a header line of the form
[yyyy-MM-dd HH:mm:ss <local numeric offset>]
echoing the command, then camelCase JSON wrapped under the command name such as
{"orders": [...]}
. That header is local wall-clock time with the machine's own zone offset, which is distinct from timestamps inside the JSON body: those are UTC with a
Z
suffix.
Casing therefore follows the pipeline, not the verb.
accounts
returns
Id
and
Balance
;
orders
returns
id
and
volumeLots
.
backtest
is worth singling out: its compact stdout summary is PascalCase (
Equity
,
NetProfit
) while the file it writes for
--report-json
is camelCase (
main
,
equity
,
tradeStatistics
).
build
takes no report flags; its stdout payload is camelCase (
projectPath
,
success
,
errors
).
Stderr carries the CLI's own echo of the command line on batch-routed calls, on success as well as failure, so its mere presence never signals an error. Shell-routed calls typically leave stderr empty. Because of that split, treat stderr as a hint about which pipeline you reached, and never as a pass/fail signal.
Plain-text rather than JSON output comes from
periods
,
--help
,
--commands
,
--version
, confirmation and refusal messages, and not-found messages such as
Order #N not found.
. The timestamp-header rule applies to shell-routed JSON commands only.
Line endings are CRLF on Windows. Numbers are plain JSON numbers, already rounded by the CLI's own formatting, with no locale-dependent separators; the one exception is a zero-trade backtest summary, which renders
AverageTrade
and
ProfitFactor
as a bare
-
token that strict JSON parsers reject.
请通过结构定位负载,切勿依赖固定行数或字节偏移。扫描时间戳头部行或第一个匹配的
{
[
;临时的连接重试行可能会出现在成功返回的负载之前。
批处理负载从字节0开始:无横幅、无头部,为扁平的大驼峰命名JSON。Shell路由负载包含几行内容各异的横幅,然后是一行格式为
[yyyy-MM-dd HH:mm:ss <本地数字偏移>]
的头部行(回显命令),接着是包裹在命令名称下的小驼峰命名JSON,例如
{"orders": [...]}
。该头部使用本地时钟时间及机器自身的时区偏移,与JSON主体内的时间戳不同:主体内的时间戳为UTC时间,带有
Z
后缀。
因此,大小写格式由管道类型决定,而非动词。
accounts
返回
Id
Balance
orders
返回
id
volumeLots
backtest
值得单独说明:其标准输出中的紧凑摘要是大驼峰命名(
Equity
,
NetProfit
),而通过
--report-json
写入文件的内容是小驼峰命名(
main
,
equity
,
tradeStatistics
)。
build
不接受报告参数;其标准输出负载为小驼峰命名(
projectPath
,
success
,
errors
)。
在批处理路由调用中,标准错误输出会携带CLI自身的命令行回显,无论成功或失败均会显示,因此仅存在标准错误输出并不代表错误。Shell路由调用通常会保持标准错误输出为空。因此,可将标准错误输出作为判断所使用管道的提示,但切勿将其作为成功/失败的信号。
纯文本输出(非JSON)来自
periods
--help
--commands
--version
、确认与拒绝消息,以及未找到消息(如
Order #N not found.
)。时间戳头部规则仅适用于Shell路由的JSON命令。
Windows系统上的行结尾为CRLF。数字为纯JSON数字,已由CLI自身格式化进行四舍五入,无区域相关分隔符;唯一例外是零交易的回测摘要,它会将
AverageTrade
ProfitFactor
渲染为纯
-
标记,严格的JSON解析器会拒绝该标记。

Exit codes and failure detection

退出码与故障检测

CodeMeaning
0Success
1Invalid usage, unrecognized flag, missing required parameter, or a validation error
81Invalid cTrader ID or password
82Account cannot be found
124The external
timeout
ended the process
Message text is the primary detection signal and the exit code is the branch key. Nonzero codes outside this table exist for further error conditions but are not publicly documented, so read the message rather than assuming a numbered meaning. A wrapper shell can report a different code than a direct invocation, so prefer the message when the two disagree.
Never infer failure from the exit code alone.
build
exits 0 for a successful compile and for a failed one: the JSON body's
success
boolean is the authoritative signal, with diagnostics in
errors: [{file, line, column, code, text}]
.
backtest
continues running after printing its summary, so the completion signal is the final JSON summary or the
--report-json
file appearing; a 124 with those artifacts present is a completed run, not a failure.
A non-numeric value for a numeric flag exits 1, but the message shape depends on the flag and the pipeline:
candles --count=abc
returns a clean
Error: Option --count has invalid number: abc
line on stdout,
--account=abc
on batch-routed
symbols
surfaces a
System.FormatException
trace, and
--account=abc
on shell-routed verbs such as
orders
prints
Invalid account number: 'abc'. Expected a numeric login id.
on stderr with no
Error:
prefix. No single stream or prefix covers this class, so validate numeric flag values before invoking.
代码含义
0成功
1使用无效、参数未识别、缺少必填参数或验证错误
81cTrader ID或密码无效
82账户未找到
124外部
timeout
终止了进程
消息文本是主要的检测信号,退出码是分支依据。除本表外,还存在其他未公开文档的非零退出码用于表示更多错误条件,因此请读取消息内容,而非假设代码的固定含义。包装Shell报告的退出码可能与直接调用不同,因此当两者不一致时,优先以消息内容为准。
切勿仅通过退出码推断故障。
build
在编译成功失败时均会以0状态码退出:JSON主体中的
success
布尔值才是权威信号,诊断信息位于
errors: [{file, line, column, code, text}]
中。
backtest
在打印摘要后会继续运行,因此完成信号是最终的JSON摘要或
--report-json
文件的出现;若出现124退出码但存在这些文件,则表示运行已完成,而非故障。
若为数值参数传入非数值值,会以1状态码退出,但消息格式取决于参数和管道:
candles --count=abc
会在标准输出中返回清晰的
Error: Option --count has invalid number: abc
行;在批处理路由的
symbols
中使用
--account=abc
会显示
System.FormatException
跟踪信息;在Shell路由动词(如
orders
)中使用
--account=abc
会在标准错误输出中打印
Invalid account number: 'abc'. Expected a numeric login id.
,且无
Error:
前缀。此类错误没有统一的输出流或前缀,因此请在调用前验证数值参数的值。

Mutating commands

变更命令

The state-changing verbs are
order place-market
,
order place-limit
,
order place-stop
,
order place-stop-limit
,
order modify
,
order cancel
,
position close
,
position close-partial
,
position modify
,
alert create
,
alert delete
, and
stop
.
Authorization gate. On a mutating verb,
-q
is the confirmation: it answers the confirmation prompt automatically and the command executes. Because
-q
is also the routine flag for shell-routed reads, it is easy to carry over by habit. Add
-q
to a mutating command only after the user has explicitly authorized that specific action, and only after you have confirmed the target account is a demo account by checking that
accounts
reports
"Live": false
. Never run a mutating command to discover how it behaves.
At a flag-style launch line,
-q
is the confirmation form that applies.
--yes
and
-y
return
Refused: confirmation required
and exit 1. A trailing bare
yes
is shell-prompt syntax; mixing it into a flag-style line ends the process with a
ConsoleInvalidUsageException
usage trace at exit 1. The
all
keyword likewise belongs to the shell prompt;
--help
documents a separate
--all
launch flag — verify it before relying on it.
Volume is expressed in units by default. On EURUSD,
--volume=1000
with no
--volume-type
,
--volume=1000 --volume-type=units
, and
--volume=0.01 --volume-type=lots
all resolve to the identical stored order of
volume: 1000, volumeLots: 0.01
. Read the instrument's own limits first with
symbol --symbol=<name>
, which returns
lotSize
,
minVolume
,
maxVolume
,
volumeStep
,
digits
, and
pipSize
.
Stop loss and take profit are three-state on modify. A value replaces,
0
removes, and omitting the flag preserves the current value. Supply prices as absolute values. A price on the wrong side of the reference is rejected before submission with a two-line
Warning:
then
Error:
message at exit 1, leaving server state untouched.
Use the exact flag names
--order=<id>
,
--position=<id>
, and
--alert=<id>
. Response keys differ per command:
order place-limit
returns
orderId
with
status: "placed"
(pending placements share this shape; expect
positionId
with
status: "opened"
from a market order that fills immediately),
alert create
returns
id
with
status: "created"
, and
alert delete
returns
alertId
with
status: "deleted"
. Read the key that the command you called returns.
After every mutation, re-read the affected entity with
orders
,
positions
, or
orders-history
and confirm the applied state before reporting success.
会改变状态的动词包括
order place-market
order place-limit
order place-stop
order place-stop-limit
order modify
order cancel
position close
position close-partial
position modify
alert create
alert delete
stop
授权验证。对于变更动词,
-q
即表示确认:它会自动回答确认提示并执行命令。由于
-q
也是Shell路由读取操作的常规参数,很容易习惯性地添加。仅当用户明确授权特定操作,且通过
accounts
确认目标账户为模拟账户(
"Live": false
)后,才可在变更命令中添加
-q
参数。切勿为了测试行为而运行变更命令。
在参数式启动行中,
-q
是有效的确认形式。
--yes
-y
会返回
Refused: confirmation required
并以1状态码退出。末尾直接添加
yes
属于Shell提示语法;将其混入参数式启动行,进程会以
ConsoleInvalidUsageException
跟踪信息并以1状态码退出。
all
关键字同样属于Shell提示语法;
--help
文档中存在单独的
--all
启动参数——请在依赖前验证其有效性。
默认情况下,交易量以单位表示。对于EURUSD,
--volume=1000
(无
--volume-type
)、
--volume=1000 --volume-type=units
--volume=0.01 --volume-type=lots
最终都会存储为相同的订单:
volume: 1000, volumeLots: 0.01
。请先通过
symbol --symbol=<name>
读取工具自身的限制,它会返回
lotSize
minVolume
maxVolume
volumeStep
digits
pipSize
修改订单时,止损和止盈为三态。传入值会替换原有设置,
0
会移除设置,省略参数则保留当前值。价格需提供绝对值。若价格位于参考价格的错误一侧,会在提交前被拒绝,输出两行
Warning:
Error:
消息并以1状态码退出,不会改变服务器状态。
请使用准确的参数名称
--order=<id>
--position=<id>
--alert=<id>
。不同命令的响应键不同:
order place-limit
返回
orderId
status: "placed"
(待处理订单也采用此格式;若市价订单立即成交,会返回
positionId
status: "opened"
),
alert create
返回
id
status: "created"
alert delete
返回
alertId
status: "deleted"
。请读取你调用的命令返回的对应键。
每次变更后,请通过
orders
positions
orders-history
重新读取受影响的实体,并在报告成功前确认状态已生效。

Session preflight

会话预检

Before the first authenticated call, run the four-step preflight in
references/setup.md
: executable reachability, presence-and-length-only checks of
CTID
and
PWD-FILE
, password-file sanity, and a single go/no-go probe with
accounts -e
. The three outcomes are exit 0 with a JSON account array (ready), exit 81 (credentials rejected), and exit 1 with a missing-parameter message (a fast, clear failure, never a hang). That reference also carries the exact wording to give a user whose configuration needs fixing.
首次认证调用前,请执行
references/setup.md
中的四步预检:可执行文件可达性检查、
CTID
PWD-FILE
的存在性及长度检查、密码文件完整性检查,以及使用
accounts -e
进行一次成功/失败探测。三种结果分别为:以0状态码退出并返回JSON账户数组(就绪)、以81状态码退出(凭证被拒绝)、以1状态码退出并返回缺少参数的消息(快速明确的失败,不会挂起)。该文档还包含向配置需要修复的用户提供的准确说明话术。

Reference files

参考文件

  • references/setup.md
    - the preflight sequence and the user-facing setup instructions for each failure mode.
  • references/routing-and-output.md
    - the full routing matrix, payload anatomy, and parsing recipes.
  • references/commands.md
    - per-verb flags and payload shapes for the read-only surface.
  • references/trading-write.md
    - the guarded mutation sequence, volume and protection semantics, and response shapes.
  • references/algo-lifecycle.md
    - create, build, metadata, backtest, and run for cBots and indicators.
  • references/errors-and-exit-codes.md
    - the failure table, message shapes, and recovery actions.
  • references/setup.md
    - 预检流程及针对每种故障模式的用户端设置说明。
  • references/routing-and-output.md
    - 完整的路由矩阵、负载结构及解析方法。
  • references/commands.md
    - 只读命令的逐动词参数及负载格式。
  • references/trading-write.md
    - 受保护的变更流程、交易量与保护语义及响应格式。
  • references/algo-lifecycle.md
    - cBots和指标的创建、构建、元数据、回测及运行。
  • references/errors-and-exit-codes.md
    - 故障表、消息格式及恢复操作。",