Mirexa

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

bash
mirexa-cli load [flags] FILE|DIR ...
bash
mirexa-cli load -addr node1:8080,node2:8080 -stream binance:BTCUSDT:1m -ts-format unix-ms dump/*.csv.gz
bash
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
-addr localhost:8080 Node addresses, comma-separated. Any node of a cluster will do: the loader follows redirects and sends each stream to its partition's primary.
-token $MIREXA_TOKEN A session token from mirexa-cli token issue.
-token-file A file holding the token, re-read on reconnect. Not with -token.
-tls-ca A PEM file with the CA to trust; turns TLS 1.3 on.
-tls-server-name the first -addr host The name the node's certificate must carry.
-stream One stream for every row, exchange:symbol:timeframe.
-exchange, -symbol, -timeframe One part of the stream for every row, when no column names it.
-map Column mapping, field=source,... (below).
-map-file A file of field=source lines, one per line; blank lines and # comments ignored. Not with -map.
-ts-format unix-s, unix-ms, unix-us, unix-ns, rfc3339, or a Go time layout. Required for CSV. A Parquet TIMESTAMP column needs none.
-tz IANA zone for timestamps that carry none: a Go layout without an offset, or a Parquet TIMESTAMP not adjusted to UTC.
-header auto Whether a CSV's first line is a header: auto, yes or no.
-delimiter , (tab for .tsv) CSV field separator, one character; \t means tab.
-correct false Restate a stored bar a row disagrees with, instead of refusing the row.
-dry-run false Read, map and validate every row and report; send nothing and ask the node nothing.
-parallel 4 Streams loaded at once.
-report 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 volume must have a source;
  • a field may be mapped once;
  • a CSV mapping may not mix header names and #N positions;
  • the stream must be complete: each of exchange, symbol, timeframe comes 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.

text
# 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). .tsv switches 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/no decide it outright; no with 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_MILLIS/_MICROS too); an INT32/INT64 with -ts-format unix-*; text with any -ts-format
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

-ts-format Reads
unix-s, unix-ms, unix-us, unix-ns 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-01-02 15:04:05 That layout. A layout without an offset needs -tz, 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]

  1. 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.
  2. 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).
  3. 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 -correct is given, when it is sent by the correction route. Every other row is absent and will be sent.
  4. 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.
  5. 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).
  6. 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:

text
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_run bool Whether this was a dry run.

Each element of streams:

Field Type Meaning
stream string exchange:symbol:timeframe.
read int Every row read for this stream. loaded + skipped + duplicates + refused (+ would_load 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_load 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 (-correct).
history int Rows that went by the history route.
gaps_closed Gap[] Gaps open before the load and closed after it. Omitted when empty.
gaps_open 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:

json
{
  "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 -h. The reason is printed as mirexa-cli load: <reason>.

References

Source

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

  1. the package comments of /cmd/cli/load.go and /internal/bulkload/decimal.go. ↩︎

  2. ExpandPaths, formatOf and Open in /internal/bulkload/csv.go. ↩︎

  3. ParseMapping, add, complete, SetConstant and StreamComplete in /internal/bulkload/mapping.go; readHeader in /internal/bulkload/csv.go. ↩︎

  4. ParseTimeFormat and ErrNaiveTime in /internal/bulkload/timestamp.go; checkColumn in /internal/bulkload/parquet.go. ↩︎

  5. ParseDecimal, FixedFromUnscaled and fixedToFloat in /internal/bulkload/decimal.go; build in /internal/bulkload/rows.go. ↩︎

  6. Load, loadStream, classify, dedupe and runs in /internal/bulkload/load.go; send, sendBatch and reconcile in /internal/bulkload/send.go. ↩︎