Wiki Reference
mirexa-cli load
The bulk loader — every flag, the column-mapping syntax, CSV and Parquet input, exact decimal handling, how rows are routed and reconciled, the JSON report and the exit statuses.
mirexa-cli load loads candle files — CSV (plain, gzip or zstd) and Apache Parquet — into a
Mirexa node or cluster. You declare how the file's columns map onto a candle and a stream;
it reads every row, checks it with the node's own rules, sends each stream through the write
route that can hold it, and reports exactly what landed, what was already there, and what
was refused and why. It is safe to run again: a re-run loads nothing twice. For a walkthrough,
see Bulk loading files.
It loads candles only; for trades, use mirexa-cli ingest -ticks
or an SDK. The Parquet reader is linked into mirexa-cli for this command, never into the
client libraries.[1]
Usage
mirexa-cli load [flags] FILE|DIR ...
mirexa-cli load -addr node1:8080,node2:8080 -stream binance:BTCUSDT:1m -ts-format unix-ms dump/*.csv.gz
mirexa-cli load -map 'ts=open_time,open=o,high=h,low=l,close=c,volume=v,symbol=sym' -exchange binance -timeframe 1m -ts-format rfc3339 vendor.parquet
A directory argument stands for the loadable files directly in it (.csv, .csv.gz,
.csv.zst, .parquet), in name order; a directory holding none is an error. A file argument
is read whatever its name: .parquet as Parquet, anything else as CSV, decompressed by a
.gz or .zst suffix. At least one path is required.[2]
Flags
| Flag | Default | Meaning |
|---|---|---|
- |
localhost: |
Node addresses, comma-separated. Any node of a cluster will do: the loader follows redirects and sends each stream to its partition's primary. |
- |
$MIREXA_ |
A session token from mirexa-. |
- |
A file holding the token, re-read on reconnect. Not with -. |
|
- |
A PEM file with the CA to trust; turns TLS 1.3 on. | |
- |
the first - host |
The name the node's certificate must carry. |
- |
One stream for every row, exchange:. |
|
-, -, - |
One part of the stream for every row, when no column names it. | |
- |
Column mapping, field=source,. (below). |
|
- |
A file of field=source lines, one per line; blank lines and # comments ignored. Not with -. |
|
- |
unix-, unix-, unix-, unix-, rfc3339, or a Go time layout. Required for CSV. A Parquet TIMESTAMP column needs none. |
|
- |
IANA zone for timestamps that carry none: a Go layout without an offset, or a Parquet TIMESTAMP not adjusted to UTC. |
|
- |
auto |
Whether a CSV's first line is a header: auto, yes or no. |
- |
, (tab for .) |
CSV field separator, one character; \t means tab. |
- |
false | Restate a stored bar a row disagrees with, instead of refusing the row. |
- |
false | Read, map and validate every row and report; send nothing and ask the node nothing. |
- |
4 | Streams loaded at once. |
- |
Write the JSON report to this file, or - for standard output. |
The session must hold both WRITE_CANDLES and READ_CANDLES (the loader reads back what it
wrote); it stops before reading any file if it does not. See Permissions.
Column mapping
A mapping says where each field of a candle comes from.
| Field | Also accepted as | Source may be a constant? |
|---|---|---|
ts |
timestamp, time |
no |
open, high, low, close, volume |
no | |
exchange, symbol, timeframe |
yes |
A source is one of:
| Form | Example | Meaning |
|---|---|---|
| a header name | close=c |
The CSV column with that header (exact match; a leading BOM is stripped), or the Parquet column with that name — a dotted name reaches into a group. |
#N |
close=#5 |
The N-th column, 1-based. CSV only. |
| a quoted constant | exchange='binance' |
The same value for every row. Stream fields only. |
Rules, each refused with a message before any row is read:[3]
- every one of
ts open high low close volumemust have a source; - a field may be mapped once;
- a CSV mapping may not mix header names and
#Npositions; - the stream must be complete: each of
exchange,symbol,timeframecomes from a column, a constant,-exchange/-symbol/-timeframe, or-stream— and a field given both a column and a flag is refused.
So a stream can differ per row: map symbol=sym (and the others) to columns, and one file
loads into as many streams as it names.
With no -map or -map-file, a CSV is read by position as
timestamp,open,high,low,close,volume (the mirexa-cli ingest layout), and a Parquet file by
column name: timestamp, open, high, low, close, volume.
# vendor.map — one field=source per line
ts=open_time
open=o
high=h
low=l
close=c
volume=v
symbol=sym
exchange='binance'
timeframe='1m'
Input formats
CSV
- Compression by suffix:
.gz(gzip),.zst(zstd)..tsvswitches the default separator to tab. - Header detection (
-header auto): with a mapping by header name, the first line is the header. Otherwise the first line is a header only when none of its mapped candle fields reads as a value; a line that half reads is treated as a data row with a mistake in it, and refused, rather than swallowed as a header.-header yes/nodecide it outright;nowith a mapping by name is refused. - A row with too few fields, a quoting error, or an empty value is refused with its file and line; reading goes on with the next row.
Parquet
Columns are matched by name, and each mapped column's type is checked before any row is read:
| Field | Accepted column types |
|---|---|
ts |
TIMESTAMP (milli-, micro- or nanoseconds; a legacy TIMESTAMP_/_ too); an INT32/INT64 with -; text with any - |
open … volume |
DOUBLE, FLOAT, INT32, INT64, DECIMAL (on INT32, INT64 or byte arrays), or text |
exchange, symbol, timeframe |
text (byte array) |
Refused: a repeated column, a #N position, a legacy DECIMAL with no logical type ("rewrite
it with a DECIMAL logical type"), and a TIMESTAMP not adjusted to UTC unless -tz is
given. A Parquet row's origin is its row number from 1.
Timestamps
- |
Reads |
|---|---|
unix-, unix-, unix-, unix- |
An integer count since the Unix epoch in that unit. |
rfc3339 |
RFC 3339 with or without a fraction; the offset is required. |
a Go layout, e.g. 2006- |
That layout. A layout without an offset needs -, and is refused without one before any row is read. |
A timestamp with no zone and no -tz is refused, never assumed UTC: a file of New York
local times read as UTC would put every bar four or five hours off, and nothing downstream
could tell.[4] Without -ts-format, a CSV's timestamps cannot be read and every row is
refused (timestamp "…" does not match ""). Every timestamp must lie on the stream's grid
(for example a whole minute on a 1m stream); one that does not is refused.
Prices and volumes are read exactly
Mirexa stores values as fixed point with four decimal places. The loader reads decimal text,
and Parquet DECIMAL values, straight into that fixed point in integer arithmetic — never
through a binary float — so the same digits in a CSV and in a Parquet file land on the same
stored value (TestLoad_AParquetAndACSVOfTheSameCandlesLoadToByteIdenticalChunks). Digits past
the fourth decimal place are rounded half away from zero, which is what the node does to any
value it is sent; each row that needed it is counted as rounded. An exponent (1.5e3) is
accepted. A Parquet DOUBLE or FLOAT is converted the way the node converts a float. Values
outside what the store can hold, and candles the node would refuse (high below low, a
non-finite value), are refused with the node's own check.[5]
Above a magnitude of about 4.5 × 10¹¹ some fixed-point values have no float64 the node would
convert back exactly; such a value can land one unit (0.0001) off. Below that every value is
exact (TestFixedToFloat_TheStoreRecoversTheFixedPointExactly).
What a load does
The loader first reads every file and holds all rows in memory, grouped by stream; a file
that cannot be opened or read stops the load before anything is sent. Then it loads up to
-parallel streams at once. For each stream:[6]
- Sort and de-duplicate. Rows are ordered by time. Exact repeats of a row keep the
first and count the rest as
duplicates. Rows that share a timestamp but disagree are all refused, because nothing says which is right. - Look at what is stored. It lists the stream's gaps over the rows' window and reads the window back, from the stream's primary (never a copy, so it sees every acknowledged write).
- Classify each row. A row whose bar is stored with the same values is
skipped. A row whose bar is stored with different values is refused ("differs from the bar stored at this timestamp; re-run with -correct to restate it") — unless-correctis given, when it is sent by the correction route. Every other row is absent and will be sent. - Send. If the stream holds no data at all, every absent row goes by the history
route, in batches of 10,000, each acknowledged. Otherwise absent rows go by the ordinary
live route in batches spanning at most 1,024 slots, split wherever a stored bar lies
between two rows; a batch the node answers
HistoryRequired(bars older than anything stored, or between stored chunks) is re-sent by the history route. Every write is acknowledged. - Reconcile an ambiguous batch. If the connection fails with a batch in flight, the
loader reads the batch's range back: every row present with its values means it landed;
a history batch only partly present is refused; otherwise the batch is sent once more
(
TestLoad_AnAmbiguousBatchIsReadBackNeverBlindlyResent). - Report gaps. It lists gaps again and reports those that were open before and are closed (or gone) after, and those still open in the window.
A failure that stops one stream (the node unreachable, a read-back that fails) marks that
stream's report with error and its unsent rows as refused; other streams carry on
(TestLoad_AStreamThatFailsStopsOnlyItself). Interrupting the loader (SIGINT, SIGTERM)
cancels what is in flight; a run interrupted and run again stores every row exactly once
(TestLoad_KilledMidRunAndRunAgainEveryRowIsStoredOnce).
The loader writes nothing into a market closure the stream has filed; the node refuses such
rows and they are reported as refused with its reason
(TestLoad_AFillOfAnOutageClosesItsGapAndAClosureStaysOffTime).
Output
A summary goes to standard error, one line per stream, followed by up to ten refusals with their origin:
binance:BTCUSDT:1m: 2 read, 0 would load (0 as history, 0 corrected), 0 already stored, 0 duplicate, 2 refused
t.csv:2: timestamp 1761800000000000000 is not on the 1m grid
t.csv:3: timestamp 1761800060000000000 is not on the 1m grid
(A dry run of this build, 2026-10-30, on a file whose millisecond stamps were not whole
minutes. A real load says loaded where a dry run says would load, and adds
; gaps closed N, still open M when the window has gaps.)
With -report, the full JSON report is written (indented) to the file or standard output.
Report schema
| Field | Type | Meaning |
|---|---|---|
files |
string[] | The files read, in order. |
streams |
object[] | One per stream, sorted by name (below). |
unattributed |
Refusal[] | Rows refused before they named a stream (for example, a symbol column that was empty). Omitted when empty. |
dry_ |
bool | Whether this was a dry run. |
Each element of streams:
| Field | Type | Meaning |
|---|---|---|
stream |
string | exchange:. |
read |
int | Every row read for this stream. loaded + skipped + duplicates + refused (+ would_ in a dry run) equals it exactly. |
loaded |
int | Rows stored, including history and corrected. |
skipped |
int | Rows already stored with these values. |
duplicates |
int | Exact repeats of an earlier row of the same files. |
would_ |
int | Dry run only: rows that read and validated. Omitted otherwise. |
refused |
int | Rows not stored. |
refusals |
Refusal[] | Each refused row and why. Omitted when empty. |
rounded |
int | Rows with a value carrying more than four decimal places. |
corrected |
int | Rows that restated a stored bar (-). |
history |
int | Rows that went by the history route. |
gaps_ |
Gap[] | Gaps open before the load and closed after it. Omitted when empty. |
gaps_ |
Gap[] | Gaps still open in the loaded window. Omitted when empty. |
error |
string | A failure that stopped this stream part way. Omitted when none. |
A Refusal is {"origin": {"file": string, "line": int}, "reason": string}; line counts
a CSV's header line, or a Parquet file's rows from 1. A Gap is
{"start": int, "end": int, "status": string, "reason": string}, times in Unix
nanoseconds, status and reason as named in Gaps and trading calendars.
A dry run, as produced by this build (2026-10-30), for a three-row file with one exact duplicate:
{
"files": ["t2.csv"],
"streams": [
{
"stream": "binance:BTCUSDT:1m",
"read": 3,
"loaded": 0,
"skipped": 0,
"duplicates": 1,
"would_load": 2,
"refused": 0,
"rounded": 2,
"corrected": 0,
"history": 0
}
],
"dry_run": true
}
Exit status
| Status | When |
|---|---|
| 0 | Every row was loaded, skipped as already stored, or an exact duplicate. |
| 2 | The load ran, and at least one row was refused or a stream's load stopped with an error. The report says which and why. |
| 1 | The load could not run: a bad flag or mapping, an unreadable file or directory, no paths given, a connection or permission failure, or -. The reason is printed as mirexa-. |
References
Source
- /cmd/cli/load.go — flags, the summary, the report, exit statuses.
- /internal/bulkload/load.go —
Load, de-duplication, classification, the report types. - /internal/bulkload/send.go — routes, batch sizes,
HistoryRequiredfallback, ambiguous-batch reconciliation. - /internal/bulkload/mapping.go — the mapping syntax and its rules.
- /internal/bulkload/csv.go, /internal/bulkload/parquet.go — the readers.
- /internal/bulkload/timestamp.go, /internal/bulkload/decimal.go, /internal/bulkload/rows.go.
Tests
TestLoad_AFileOverlappingStoredDataIsSeparatedIntoLoadedSkippedAndRefused,TestLoad_AParquetAndACSVOfTheSameCandlesLoadToByteIdenticalChunks,TestLoad_AFillOfAnOutageClosesItsGapAndAClosureStaysOffTime,TestLoad_KilledMidRunAndRunAgainEveryRowIsStoredOnce,TestLoad_IntoAThreeNodeClusterEveryStreamLandsOnTheNodeTheDirectoryNames— /tests/bulkload_e2e_test.go.TestLoad_AnAmbiguousBatchIsReadBackNeverBlindlyResent,TestLoad_AStreamThatFailsStopsOnlyItself,TestLoad_ADryRunSendsNothing— /internal/bulkload/load_test.go.TestMapping_RefusesWhatItCannotUse,TestCSV_HeaderDetectionAndRefusedRowsCarryTheirLine,TestCSV_StreamPerRowFromColumns,TestOpen_ReadsGzipAndZstdCSV,TestParquet_ReadsLogicalTypesAcrossRowGroups,TestParquet_ALocalTimestampIsRefusedWithoutAZone,TestTimeFormat_ANaiveTimestampIsRefusedNotAssumedUTC,TestTimeFormat_EveryUnitRoundTripsExactly— /internal/bulkload/reader_test.go.TestParseDecimal_ReadsDigitsExactly,TestFixedFromUnscaled_DecimalAgreesWithItsText,TestFixedToFloat_TheStoreRecoversTheFixedPointExactly— /internal/bulkload/decimal_test.go.
Further reading
External
- Apache Parquet: Logical Type Definitions, The Apache Software Foundation — https://github.com/apache/parquet-format/blob/master/LogicalTypes.md
- Package time — layout constants, The Go Authors — https://pkg.go.dev/time#pkg-constants
- RFC 8878: Zstandard Compression and the application/zstd Media Type, Y. Collet and M. Kucherawy — https://www.rfc-editor.org/rfc/rfc8878
the package comments of /cmd/cli/load.go and /internal/bulkload/decimal.go. ↩︎
ExpandPaths,formatOfandOpenin /internal/bulkload/csv.go. ↩︎ParseMapping,add,complete,SetConstantandStreamCompletein /internal/bulkload/mapping.go;readHeaderin /internal/bulkload/csv.go. ↩︎ParseTimeFormatandErrNaiveTimein /internal/bulkload/timestamp.go;checkColumnin /internal/bulkload/parquet.go. ↩︎ParseDecimal,FixedFromUnscaledandfixedToFloatin /internal/bulkload/decimal.go;buildin /internal/bulkload/rows.go. ↩︎Load,loadStream,classify,dedupeandrunsin /internal/bulkload/load.go;send,sendBatchandreconcilein /internal/bulkload/send.go. ↩︎