Mirexa

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.addr) -addr, default localhost:8080
calendar, lineage, cache, gap the control listener (gRPC, control.addr), off unless control.enabled -control, default 127.0.0.1:9091

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, except subscribe -from, which is Unix nanoseconds only.
  • A range is [start, end).
  • A stream is exchange:symbol:timeframe, for example binance: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
-addr localhost:8080 The node's data port.
-stream exchange:symbol:timeframe. Accepted by streams but unused there.
-token $MIREXA_TOKEN A session token from mirexa-cli token issue.
-token-file A file holding the token. Re-read on every reconnect, and used for renewal over the open connection.
-tls-ca A PEM file with the CA to trust. Setting it turns TLS on, TLS 1.3 only.
-tls-server-name the -addr host The name the node's certificate must carry.
-reconnect 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 -resume.

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_CANDLES, or WRITE_TICKS with -ticks
query, subscribe READ_CANDLES, or READ_TICKS with -ticks
streams LIST_STREAMS
calendar, lineage, cache, gap ADMIN_CLUSTER, only when the node sets control.admin_auth

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
-ack true Wait for each batch to be in the node's write-ahead log and fsynced. -ack=false sends fire-and-forget: faster, and a batch the node refuses is lost without a message.
-batch 1000 Records per batch.
-flush 100ms Send a partial batch once its oldest record has waited this long, so a slow pipe (tail -f … |) still makes progress.
-ticks false Read ticks instead of candles.
-history 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; -ack does not apply.
-correct 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.
-overwrite false Write a derived stream, which the node otherwise refuses. Combines with -history or -correct.
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.

bash
mirexa-cli ingest -stream binance:BTCUSDT:1m < candles.csv
text
ingested 1440 candles into binance:BTCUSDT:1m in 2 batch(es)
bash
mirexa-cli ingest -stream binance:BTCUSDT:1m -history < last-year.csv
bash
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
-start, -end required The range.
-max 0 Stop after this many rows; 0 reads the whole range.
-gaps 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.
-ticks false Read trades: timestamp,price,volume.
-rollup 0 Answer bars of this length (7m, 4h, 24h) made at query time from the stream's candles, or with -ticks from its trades. Nothing is stored; only closed bars are answered.
plus the shared flags
bash
mirexa-cli query -stream binance:BTCUSDT:1m -start 2026-10-20T09:30:00Z -end 2026-10-20T09:33:00Z -gaps
text
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.

bash
mirexa-cli query -stream binance:BTCUSDT:1m,binance:ETHUSDT:1m -start 2026-10-20T09:30:00Z -end 2026-10-20T09:31:00Z
text
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
-backfill false Send stored history first, then live data, with no gap between them. Standard error says backfill complete; live from here at the switch.
-from 0 Where the history starts, Unix nanoseconds; 0 is the earliest stored. Requires -backfill.
-count 0 Stop (and unsubscribe) after this many records; 0 runs until stopped.
-resume false If the connection drops, reconnect and carry on from just past the last record received (up to 5 consecutive reconnect attempts, 200ms apart).
-ticks 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.

bash
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
-stats false Add persisted_records, chunks, corrections, bytes_on_disk, first_time, last_time (RFC 3339; empty when unknown). One index read per stream.
plus the shared flags
bash
mirexa-cli streams
text
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
-control 127.0.0.1:9090 The node's control listener.
-stream exchange:symbol:timeframe.
-token $MIREXA_TOKEN A token carrying ADMIN_CLUSTER, sent as authorization: Bearer …, needed when the node sets control.admin_auth.
-token-file A file holding that token.
-tls-ca A PEM file with the CA to trust, when the node sets control.use_tls. TLS 1.3 only.
-tls-server-name the -control host The name the node's certificate must carry.
-timeout 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 -timezone, -hours, -no-hours, -threshold-low, -threshold-high Change the weekly hours and thresholds. Flags not given keep their values (TestCalendarEdit_KeepsWhatItIsNotGiven). A stream the node does not know is registered with these settings.
calendar add-closure -from, -to, -note Declare a closure over [from, to): a holiday, a halt, or a gap that was expected.
calendar remove-closure -from, -to Remove a range from the declared closures, cutting any that overlap it.
Flag Meaning
-timezone IANA zone the hours are written in, for example America/New_York.
-hours DAYS=WINDOWS, repeatable, replacing the weekly hours. Days are names or three-letter abbreviations, a range (mon-fri, wrapping allowed) or a comma list; windows are HH:MM-HH:MM, several separated by commas. A day given twice is refused.
-no-hours Remove the weekly hours (the market never closes). Not with -hours or -timezone.
-threshold-low Shortest gap recorded, a Go duration such as 5m.
-threshold-high On a stream with no hours, a gap at least this long is a closure, such as 12h.
-from, -to RFC 3339 or Unix nanoseconds; both required, -from before -to.
-note Free text kept with the closure.
bash
mirexa-cli calendar set -stream nyse:AAPL:1m -timezone America/New_York -hours mon-fri=09:30-16:00
bash
mirexa-cli calendar set -stream tse:7203:1m -timezone Asia/Tokyo -hours mon-fri=09:00-11:30,12:30-15:00
bash
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
-kind ticks or candles.
-source the -stream itself The source stream. For ticks, the stream's own trades feed its candles.
-history required from-now derives what arrives from now on; rederive also derives everything the source holds, walking it in the background — rederive_pending in the printed lineage stays true until it has caught up.
-grace node default, 1s How long past a bar's close late data still joins that bar.
-no-trade-limit node default, 10s Ticks only: the longest silence between trades that is not missing data.
bash
mirexa-cli lineage set -stream binance:ETHUSDT:1m -kind ticks -history from-now
bash
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 -slots N (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.

bash
mirexa-cli cache set -stream nyse:IBM:1h -slots 8760
text
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
-start Required: the mark's start exactly as a gap listing reports it, RFC 3339 or Unix nanoseconds.
bash
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

Tests

Further reading

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

  1. Connection.ResolveToken and Connection.ClientOptions in /internal/clicommon/clicommon.go. ↩︎