Wiki Reference
mirexa-cli
Every mirexa-cli command and flag — CSV ingest and query, live subscriptions, stream listing, and the calendar, lineage, cache and gap settings on the control listener.
mirexa-cli drives a Mirexa node from a shell: write CSV into a stream, read a range back as
CSV, follow a stream live, list what a node holds, and change the stream settings that live
on the node — trading calendar, lineage, hot-cache size and incomplete-bar acceptance. It
uses the same client library as the Go SDK. For loading files in bulk, with
column mapping and a report, use mirexa-cli load instead.
Names
The source is /cmd/cli. make build writes it as bin/cli; its messages call it
mirexa-cli, as does this page.
Two listeners
The commands talk to one of two listeners on one node:
| Commands | Listener | Address flag |
|---|---|---|
ingest, query, subscribe, streams |
the data port (wire protocol, network.) |
-, default localhost: |
calendar, lineage, cache, gap |
the control listener (gRPC, control.), off unless control. |
-, default 127. |
The control listener defaults to port 9091, beside the metrics listener's 9090; see
mirexa-server. It is loopback-only unless
control.admin_auth is on.
On a cluster the CLI talks to the one node you name and does not follow redirects. A data command for a stream another node is primary of fails with a redirect naming that node; run it there. Send setting changes to the stream's primary too: copies take their primary's settings.
Conventions
- Timestamps you give are RFC 3339 (
2026-10-20T09:30:00Z) or Unix nanoseconds, exceptsubscribe -from, which is Unix nanoseconds only. - A range is
[start, end). - A stream is
exchange:symbol:timeframe, for examplebinance:BTCUSDT:1m. - Results go to standard output; progress, summaries and warnings go to standard error, so output can be piped.
- Exit status: 0 on success, 1 on any failure, with
mirexa-cli: <reason>on standard error. Asking for help (-h) also exits 1, after printing the flags. Running with no command, or an unknown one, prints the list of commands and exits 1.
Flags shared by the data-port commands
| Flag | Default | Meaning |
|---|---|---|
- |
localhost: |
The node's data port. |
- |
exchange:. Accepted by streams but unused there. |
|
- |
$MIREXA_ |
A session token from mirexa-. |
- |
A file holding the token. Re-read on every reconnect, and used for renewal over the open connection. | |
- |
A PEM file with the CA to trust. Setting it turns TLS on, TLS 1.3 only. | |
- |
the - host |
The name the node's certificate must carry. |
- |
3 | Connection attempts per operation, so a command rides out a node restarting. 1 fails on the first refused dial. Not used by subscribe without -. |
The token comes from the first of -token, -token-file, $MIREXA_TOKEN that is set; giving
both flags is an error. With none, the CLI connects unauthenticated, which only a node with
authentication off accepts. A token from -token or $MIREXA_TOKEN cannot be refreshed, so
a long-running command fails once it expires (at most an hour); with -token-file, rewrite
the file before then. Against a single node with no trusted_keys configured,
-token-file <data_dir>/auth/admin.token is the file the node itself rewrites
(Authentication).[1]
ingest and streams check the node's grant before reading any input, and stop naming the
missing permission ("this session cannot write candles: granted …, need …"). The other
commands get the node's own refusal.
| Command | Permission |
|---|---|
ingest |
WRITE_, or WRITE_ with - |
query, subscribe |
READ_, or READ_ with - |
streams |
LIST_ |
calendar, lineage, cache, gap |
ADMIN_, only when the node sets control. |
ingest
Reads CSV from standard input and writes it to one stream. Candle rows are
timestamp,open,high,low,close,volume; tick rows (-ticks) are timestamp,price,volume.
There is no header line: every row must parse, and the first that does not stops the run
("row N column M: …").
| Flag | Default | Meaning |
|---|---|---|
- |
true |
Wait for each batch to be in the node's write-ahead log and fsynced. - sends fire-and-forget: faster, and a batch the node refuses is lost without a message. |
- |
1000 | Records per batch. |
- |
100ms | Send a partial batch once its oldest record has waited this long, so a slow pipe (tail -) still makes progress. |
- |
false | Read ticks instead of candles. |
- |
false | Bulk back-fill: the node compresses the rows straight into chunks, skipping the write-ahead log and hot cache. The only way to load bars older than anything the stream holds. Batches are sent fire-and-forget and the last one is acknowledged, which is when the whole load becomes readable; - does not apply. |
- |
false | Strict correction: restate bars the node already stores, and refuse the batch if any bar is newer than the newest stored. A plain ingest restates stored bars too and also takes new ones. |
- |
false | Write a derived stream, which the node otherwise refuses. Combines with - or -. |
| plus the shared flags |
-history, -correct and -overwrite apply to candles only, and -history with
-correct is refused. A batch the node sheds under load is re-sent automatically; standard
error says so ("server overloaded; batch of N records took K attempts"). A connection lost
while a batch is in flight stops the run with an ambiguous-write error rather than re-sending
it: read the range back before running again.
mirexa-cli ingest -stream binance:BTCUSDT:1m < candles.csv
ingested 1440 candles into binance:BTCUSDT:1m in 2 batch(es)
mirexa-cli ingest -stream binance:BTCUSDT:1m -history < last-year.csv
mirexa-cli ingest -stream binance:BTCUSDT:1s -ticks < trades.csv
A live write must fall within the stream's hot cache, near its newest data, and a batch must
not span more slots than the cache holds (see cache). See
Writing data.
query
Reads [start, end) and prints CSV with no header, timestamps in RFC 3339 with
nanoseconds, UTC. Long ranges are paged automatically.
| Flag | Default | Meaning |
|---|---|---|
-, - |
required | The range. |
- |
0 | Stop after this many rows; 0 reads the whole range. |
- |
false | Also print a row for each slot with no candle: empty prices and gap in a seventh column. Data rows then get an empty seventh column. The row does not say whether the gap is a market closure; use the dashboard, the SDK or ListGaps for that. |
- |
false | Read trades: timestamp,price,volume. |
- |
0 | Answer bars of this length (7m, 4h, 24h) made at query time from the stream's candles, or with - from its trades. Nothing is stored; only closed bars are answered. |
| plus the shared flags |
mirexa-cli query -stream binance:BTCUSDT:1m -start 2026-10-20T09:30:00Z -end 2026-10-20T09:33:00Z -gaps
2026-10-20T09:30:00Z,67012.5,67248.75,66981.25,67104,148.2,
2026-10-20T09:31:00Z,,,,,,gap
2026-10-20T09:32:00Z,67171.3,67202,67120.45,67140.8,121.9,
Give -stream a comma-separated list to read several streams over the same range in one
round trip (a multi-query). Each row then starts with its stream. If some streams fail (for
example, one does not exist), the others' rows are printed and the command then fails naming
the ones that did: N of M streams failed: binance:X:1m: status 2.
mirexa-cli query -stream binance:BTCUSDT:1m,binance:ETHUSDT:1m -start 2026-10-20T09:30:00Z -end 2026-10-20T09:31:00Z
binance:BTCUSDT:1m,2026-10-20T09:30:00Z,67012.5,67248.75,66981.25,67104,148.2
binance:ETHUSDT:1m,2026-10-20T09:30:00Z,2412.1,2415.8,2409.55,2414.95,182.4
A single-stream query of a stream the node does not know fails with network: stream not found: <symbol:timeframe:exchange>.
subscribe
Prints every new bar (or trade, with -ticks) as the node stores it, as CSV with Unix
nanosecond timestamps, until interrupted.
| Flag | Default | Meaning |
|---|---|---|
- |
false | Send stored history first, then live data, with no gap between them. Standard error says backfill complete; live from here at the switch. |
- |
0 | Where the history starts, Unix nanoseconds; 0 is the earliest stored. Requires -. |
- |
0 | Stop (and unsubscribe) after this many records; 0 runs until stopped. |
- |
false | If the connection drops, reconnect and carry on from just past the last record received (up to 5 consecutive reconnect attempts, 200ms apart). |
- |
false | Follow trades instead of candles. |
| plus the shared flags |
A record written while the history is being sent can be printed twice, once on each side of
the switch, and is never missed. If the consumer falls behind, the node drops batches rather
than slowing the stream; standard error says how many and which sequences
(warning: N batch(es) dropped, sequences A-B missing). Those records are gone from the
subscription; read them back with query. See Subscribing to live data.
mirexa-cli subscribe -stream binance:BTCUSDT:1m -backfill -resume
streams
Lists every stream the node holds, as CSV with a header, and the count on standard error.
| Flag | Default | Meaning |
|---|---|---|
- |
false | Add persisted_, chunks, corrections, bytes_, first_, last_ (RFC 3339; empty when unknown). One index read per stream. |
| plus the shared flags |
mirexa-cli streams
exchange,symbol,timeframe
binance,BTCUSDT,1m
nyse,AAPL,1m
On a cluster this lists one node's streams, including any it holds as a copy.
Flags shared by the setting commands
calendar, lineage, cache and gap each take a sub-command (calendar get, …) and these
flags:
| Flag | Default | Meaning |
|---|---|---|
- |
127. |
The node's control listener. |
- |
exchange:. |
|
- |
$MIREXA_ |
A token carrying ADMIN_, sent as authorization:, needed when the node sets control.. |
- |
A file holding that token. | |
- |
A PEM file with the CA to trust, when the node sets control.. TLS 1.3 only. |
|
- |
the - host |
The name the node's certificate must carry. |
- |
30s | Deadline for the whole command. |
The node's refusals are translated: an unknown stream ("the node does not know this
stream"), a missing or insufficient token (naming ADMIN_CLUSTER and control.admin_auth),
or an invalid argument ("refused: <the node's reason>"). Running one of these commands with
no sub-command, or an unknown one, prints its usage and exits 1. See
Control-plane gRPC API for the RPCs behind them.
calendar
A stream's trading calendar is what tells a market closure from missing data: weekly hours in an IANA time zone, declared closures, and, for a market with no hours, how long a pause must be to count as a closure. Every change re-files the gaps the stream has already recorded before the command returns; standard error says how much was re-filed. The calendar is printed as JSON (protobuf field names, unset fields included). See Gaps and trading calendars.
| Sub-command | Flags | What it does |
|---|---|---|
calendar get |
Print the calendar. | |
calendar set |
-, -, -, -, - |
Change the weekly hours and thresholds. Flags not given keep their values (TestCalendarEdit_). A stream the node does not know is registered with these settings. |
calendar add- |
-, -, - |
Declare a closure over [from, to): a holiday, a halt, or a gap that was expected. |
calendar remove- |
-, - |
Remove a range from the declared closures, cutting any that overlap it. |
| Flag | Meaning |
|---|---|
- |
IANA zone the hours are written in, for example America/. |
- |
DAYS=WINDOWS, repeatable, replacing the weekly hours. Days are names or three-letter abbreviations, a range (mon-, wrapping allowed) or a comma list; windows are HH:, several separated by commas. A day given twice is refused. |
- |
Remove the weekly hours (the market never closes). Not with - or -. |
- |
Shortest gap recorded, a Go duration such as 5m. |
- |
On a stream with no hours, a gap at least this long is a closure, such as 12h. |
-, - |
RFC 3339 or Unix nanoseconds; both required, - before -. |
- |
Free text kept with the closure. |
mirexa-cli calendar set -stream nyse:AAPL:1m -timezone America/New_York -hours mon-fri=09:30-16:00
mirexa-cli calendar set -stream tse:7203:1m -timezone Asia/Tokyo -hours mon-fri=09:00-11:30,12:30-15:00
mirexa-cli calendar add-closure -stream nyse:AAPL:1m -from 2026-11-26T09:30:00-05:00 -to 2026-11-26T16:00:00-05:00 -note Thanksgiving
lineage
Declares that a stream's candles are derived from a source — the same instrument's trades,
or its shorter candles — so the node writes them as the source's data arrives. Prints the
lineage as JSON, or null for a stream that is not derived. A derived stream refuses
ordinary writes; write it with ingest -overwrite. See
Derived streams and lineage.
| Sub-command | What it does |
|---|---|
lineage get |
Print the lineage. |
lineage set |
Declare or change it. |
lineage clear |
Stop deriving. Candles already derived are kept. |
Flag (set) |
Default | Meaning |
|---|---|---|
- |
ticks or candles. |
|
- |
the - itself |
The source stream. For ticks, the stream's own trades feed its candles. |
- |
required | from- derives what arrives from now on; rederive also derives everything the source holds, walking it in the background — rederive_ in the printed lineage stays true until it has caught up. |
- |
node default, 1s | How long past a bar's close late data still joins that bar. |
- |
node default, 10s | Ticks only: the longest silence between trades that is not missing data. |
mirexa-cli lineage set -stream binance:ETHUSDT:1m -kind ticks -history from-now
mirexa-cli lineage set -stream binance:ETHUSDT:5m -kind candles -source binance:ETHUSDT:1m -grace 2s -history rederive
cache
Each stream keeps its newest bars in a hot cache of fixed-width slots, one bar-length apart.
Its size is the stream's memory (40 bytes a slot, whether or not a bar fills it) and the
widest batch a live write may span. By default the node sizes it from the timeframe: enough
slots for ingestion.live_candle.cache_span, at least 2,048 and at most
cache_arena_capacity (50,000). With the span unset, that is what 50,000 one-minute slots
cover: 1m and shorter get 50,000, 5m 10,000, 30m and longer 2,048. See
The hot cache.
| Sub-command | Flags | What it does |
|---|---|---|
cache get |
Print the size and where it comes from: N slots (override) or N slots (node default for <timeframe>). |
|
cache set |
- (required, 16 to 8,388,608) |
Override the size. Registers a stream the node does not know. |
cache clear |
Remove the override; the timeframe default applies again. |
The running stream takes the new size before the command returns: what its cache holds is
written to a chunk and the cache is rebuilt; nothing is lost. The override is kept with the
stream across restarts, and a copy takes its primary's. Raise it when a client writes live
batches wider than the cache (a year of hourly bars at once); lower it to save memory, but
not below the batch width your writers send, or their batches are refused as too wide.
Loading old data with ingest -history needs no cache at all.
mirexa-cli cache set -stream nyse:IBM:1h -slots 8760
8760 slots (override)
gap
A bar the node derived while some of its source data was missing carries an INCOMPLETE mark.
gap accept marks it accepted ("known incomplete, keep it"); gap unaccept puts it back to
open. Only an incomplete mark can be accepted: a gap with no data is filled or left open.
Prints the mark as JSON.
| Flag | Meaning |
|---|---|
- |
Required: the mark's start exactly as a gap listing reports it, RFC 3339 or Unix nanoseconds. |
mirexa-cli gap accept -stream binance:ETHUSDT:5m -start 2026-10-22T09:00:00Z
The CLI cannot list or fill gaps; use the dashboard, the Go SDK or the Python SDK. See Finding and filling gaps.
References
Source
- /cmd/cli/main.go — the dispatcher,
ingest,query,subscribe,streams, CSV formats. - /cmd/cli/calendar.go —
calendar, the shared control-listener flags and error translation. - /cmd/cli/lineage.go, /cmd/cli/cache.go, /cmd/cli/gap.go.
- /internal/clicommon/clicommon.go — token resolution, TLS, the grant check (shared with
mirexa-cli load).
Tests
TestCLI_CSVRoundTripsByteIdentical— /tests/cli_roundtrip_test.go.TestCLI_MultiStreamQueryMatchesSingleRuns,TestCLI_MultiStreamQueryNamesTheMissingStream— /tests/cli_multiquery_test.go.TestCLI_SlowStdinFlushesOnTheTimeThreshold,TestCLI_BackfillSubscribeReportsNoSequenceGap,TestCLI_BackfillToLivePivotReachesTheUser— /tests/cli_subscribe_test.go.TestCLI_QueryRollsUpCandlesAtQueryTime— /tests/cli_rollup_test.go.TestCLI_ADerivedStreamIsWrittenOnlyWithOverwrite— /tests/cli_overwrite_test.go.TestCLI_CalendarChangesRefileAStreamsGaps— /tests/cli_calendar_test.go.TestCLI_LineageIsDeclaredReadAndCleared— /tests/cli_lineage_test.go.TestCLI_ACachesSizeIsReadSetAndCleared— /tests/cli_cache_test.go.TestCLI_AnIncompleteMarkIsAcceptedAndPutBack— /tests/cli_gap_accept_test.go.TestCalendarEdit_KeepsWhatItIsNotGiven— /cmd/cli/calendar_test.go.TestAuth_SDKPresentsACLIIssuedToken— /tests/auth_end_to_end_test.go.
Further reading
- Quickstart, Writing data, Reading data
- mirexa-cli load, mirexa-cli token
- Authentication and tokens, Permissions
External
- RFC 3339: Date and Time on the Internet: Timestamps, G. Klyne and C. Newman — https://www.rfc-editor.org/rfc/rfc3339
- RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files, Y. Shafranovich — https://www.rfc-editor.org/rfc/rfc4180
Connection.ResolveTokenandConnection.ClientOptionsin /internal/clicommon/clicommon.go. ↩︎