vike-cli trade
An interactive REPL over a running vike-tradehub node — short verbs, a preview before every write, and each command's outcome read off its own ticket.
vike-cli trade is the human, terminal-driven sibling of
the MCP tools: a person types short verbs and they are dispatched to a
running vike-tradehub node's authenticated observe
(read) and control (write) servers over the light wire crate
(crates/vike-cli/src/cmd/trade.rs).
usage: vike-cli trade --node <host:port> [--yes]| flag | meaning |
|---|---|
--node <host:port> | required. The node to attach to |
--yes, -y | skip the per-write confirm? [y/N] prompt |
-h, --help | print the usage and the verb reference, and exit 0 |
The two halves, each gated on a key
Reads need VIKE_TRADEHUB_OBSERVE_KEY and give a handle subscribed to the node's pushed snapshot
stream. Writes need VIKE_TRADEHUB_CONTROL_KEY. With neither, the command exits with an error that
names both places it looked, the credential store's path included. Both keys are resolved once
by the dispatcher — process environment first, then <project>/settings/secrets.env, the same store
the daemon loads them from — and the connection line prints which source answered, without echoing
the key.
Writes disabled is three different problems, and it used to report only one
With the node's control flag off and a perfectly good key in the store, a write used to print
no VIKE_TRADEHUB_CONTROL_KEY — nothing was sent. The key was fine: the node had refused the
scope, and had said so once, at connect time, before scrolling away. The three cases are now
distinguished at connect and carried forward — no key resolved, the node refused the control
scope (turn its tradehub_control on and restart it), or the connection could not be opened at
all. Every message still ends in "nothing was sent", the one fact all three share.
The verbs
commands:
WRITE (preview + confirm):
submit <venue> <symbol> <buy|sell> <qty> [@<price>|@market] [--reduce-only] [--coid <id>]
buy|sell <venue> <symbol> <qty> [@<price>|@market] [--reduce-only] [--coid <id>]
(a client_order_id is MINTED per order and shown in the preview; --coid pins one)
<id> is 1..=32 alphanumeric characters, A-Z a-z 0-9
cancel <coid> (fire-and-forget: the node cannot confirm a match)
modify <coid> [--qty Q] [--price P]
flatten <venue> <symbol>
mass-cancel [venue] [symbol]
market-exit [venue] (panic: cancel all + flatten all)
state <active|reducing|halted>
any WRITE line may end with:
--reason <text to end of line> recorded in the node's audit trail
READ:
orders [symbol]
positions [venue]
equity
recent [N]
state (show current)
snapshot
meta: help quit|exit (or Ctrl-D)The help screen states the client-order-id charset because a rejection is the wrong place to learn a
constraint — and because cancel, which takes the same field, only warns: a cancel that matches
nothing still reports as accepted, so a mistyped id is silent unless something says so up front.
Ctrl-C cancels the current line; Ctrl-D quits. Line history persists under the settings directory's
state/ sub-directory, best-effort; with no project above the working directory it is simply not
persisted.
Every write previews first
The resolved command is printed, together with a client-side guardrail check, and then
confirm? [y/N] — skipped with --yes. Only on y is anything sent. The guardrail is advisory and
reads two caps: max_notional_per_order from this box's
policy.toml, and VIKE_MAX_ORDER_QTY, a local typo-catcher
with no policy field and no enforcing counterpart anywhere. A market order with no price cannot be
sized client-side, so only the notional half is skipped — guardrail_check still measures the
quantity against its cap.
The node is the enforcing gate; this preview is UX
The node's server-side control limits and the core risk gate are the backstop regardless — see the control boundary and risk and arming. The notional cap moved out of the environment deliberately: a ceiling any exported variable can raise is not a ceiling.
Every order carries a client order id this side minted, from the session's generator, filled in
before the preview prints — so the id shown is the id sent and the id you type back at cancel. The
generator is session-scoped: an 8-hex prefix from OS entropy per process, then a counter, so two
REPLs open side by side, or one restarted while an order still rests at the venue, cannot collide. A
duplicate id is idempotent at the node, which would silently book nothing the second time.
submit … --coid <id> pins one explicitly.
After sending, the REPL waits up to two seconds for the node's verdict on that command and reports accepted, refused, or unknown. It is a deadline, not a sleep — the answer returns the instant the reply lands.
Read a command's outcome from its own ticket, never a shared side-channel
This used to poll a handle-wide error field that latches: after one refusal every later write in
the session printed that same refusal, including commands the node accepted and ran. An operator who
fat-fingered an order, got a correct refusal, then typed market-exit was told the panic button was
rejected when it had executed.
--reason
Any write line may end with --reason <text to end of line> — an operator rationale recorded in the
node's audit trail beside the command, so an incident review reads why, not just what. It is
split off the line before the verb grammar sees it, shown in the preview, and sent beside the
command; it never becomes part of the order. No quoting is needed (one optional layer of surrounding
quotes is stripped), and the node sanitizes it before recording — control characters stripped, capped
at 512 characters.
Related
strategy-status asks the same node what it is running,
read-only. Stop, liquidate, restart and
triage a stuck order are the two procedures this REPL exists
for. The wire it speaks is the node protocol.