Mirexa

Wiki Guides

Quickstart

Build Mirexa, start a node, write and read candles with mirexa-cli, subscribe to a stream, and do the same from Go — in a few minutes, on one machine.

This page takes you from a source checkout to a running node holding your first candles, read back from the command line and from a Go program. It uses one machine and no configuration file; Running a node covers the rest.

You need Go 1.25 or newer, make and git, on Linux.

1. Build

bash
git clone https://github.com/AmiraliOmidvar/mirexa.git
bash
cd mirexa && make build

make build runs go build -o bin/ ./cmd/..., so each binary is named after its directory under cmd/:[1]

Binary What it is Called elsewhere in this wiki
bin/server the storage node mirexa-server (its name in the Docker image)
bin/cli every operator command: ingest, query, subscribe, bulk load, calendars, lineage, cluster, and the offline token and certs mirexa-cli
bin/dashboard the web dashboard's API —

2. Start a node

bash
./bin/server -data-dir ./data

With no -config, the node uses its defaults (overridable with MIREXA_* environment variables); -data-dir is the one thing it needs.[2] It listens on:

Address What answers there
:8080 the data port: Mirexa's binary protocol, spoken by the CLI and the SDKs
:9090 /metrics (Prometheus), /health and /ready

Check it is up:

bash
curl -s localhost:9090/ready

The admin token

Authentication is on by default, so the data port answers only a client presenting a signed token. With no keys configured, the node made its own on first start: an issuer key in ./data/auth/issuer.key and an admin token carrying every permission in ./data/auth/admin.token. The startup log names both (auth: no trusted_keys configured, so this node issues its own tokens). The token is valid for one hour and the node rewrites the file every 20 minutes while it runs, so read it from the file rather than copying it; every client below does.[3]

That token carries every permission, administrative ones included. The data port listens on every interface, so give other clients narrower tokens minted from the same key (Authentication and tokens).

3. Write some candles

mirexa-cli ingest reads CSV from standard input, one bar per line, no header: timestamp,open,high,low,close,volume. A timestamp is RFC 3339 or Unix nanoseconds, and must be the start of the bar, on the stream's grid (a whole minute for a 1m stream). A stream is named exchange:symbol:timeframe.[4]

Save this as candles.csv:

text
2026-10-20T09:30:00Z,67012.50,67248.75,66981.25,67104.00,148.2
2026-10-20T09:31:00Z,67104.00,67190.10,67055.00,67171.30,96.4
2026-10-20T09:32:00Z,67171.30,67202.00,67120.45,67140.80,121.9
bash
./bin/cli ingest -token-file ./data/auth/admin.token -stream binance:BTCUSDT:1m < candles.csv
text
ingested 3 candles into binance:BTCUSDT:1m in 1 batch(es)

The stream did not exist before this; the first write created it. The command returned once the node had written the batch to its write-ahead log and fsynced it, so these candles survive a crash from here on (Durability).

4. Read them back

bash
./bin/cli query -token-file ./data/auth/admin.token -stream binance:BTCUSDT:1m \
    -start 2026-10-20T09:30:00Z -end 2026-10-20T09:33:00Z
text
2026-10-20T09:30:00Z,67012.5,67248.75,66981.25,67104,148.2
2026-10-20T09:31:00Z,67104,67190.1,67055,67171.3,96.4
2026-10-20T09:32:00Z,67171.3,67202,67120.45,67140.8,121.9

The start is inclusive, the end exclusive. Add -gaps to get empty slots as rows too (marked gap in a seventh column); through the SDKs each one also says whether the market was closed or the data is missing (Gaps).

Longer bars, made at query time from the stored ones and stored nowhere:

bash
./bin/cli query -token-file ./data/auth/admin.token -stream binance:BTCUSDT:1m \
    -start 2026-10-20T09:30:00Z -end 2026-10-20T09:33:00Z -rollup 3m
text
2026-10-20T09:30:00Z,67012.5,67248.75,66981.25,67140.8,366.5

(A rollup answers only buckets that have closed; for bars this old, all of them have.)

List what the node holds:

bash
./bin/cli streams -token-file ./data/auth/admin.token

5. Subscribe

bash
./bin/cli subscribe -token-file ./data/auth/admin.token -stream binance:BTCUSDT:1m -backfill

This prints the stored history first, then every new bar as it is written (timestamps in Unix nanoseconds), and reports the switch to live on standard error. Ingest another bar from a second terminal to see it arrive; stop with Ctrl+C. See Subscribing to live data.

6. Use it from Go

bash
go get github.com/AmiraliOmidvar/mirexa/client
go
package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"strings"
	"time"

	"github.com/AmiraliOmidvar/mirexa/client"
)

func main() {
	// Read the token file on every connect; with a TokenSource the client also
	// renews its token over the open connection before it expires.
	c, err := client.Dial("localhost:8080", client.Options{
		TokenSource: func() (string, error) {
			b, err := os.ReadFile("data/auth/admin.token")
			return strings.TrimSpace(string(b)), err
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	ctx := context.Background()
	stream := client.NewStreamID("binance", "ETHUSDT", "1m")

	// Three closed one-minute bars, stamped on whole minutes.
	start := time.Now().UTC().Truncate(time.Minute).Add(-3 * time.Minute)
	bars := []client.Candle{
		{Timestamp: start.UnixNano(), Open: 2412.10, High: 2415.80, Low: 2409.55, Close: 2414.95, Volume: 182.4},
		{Timestamp: start.Add(time.Minute).UnixNano(), Open: 2414.95, High: 2418.20, Low: 2413.10, Close: 2416.40, Volume: 96.7},
		{Timestamp: start.Add(2 * time.Minute).UnixNano(), Open: 2416.40, High: 2417.05, Low: 2411.75, Close: 2412.60, Volume: 141.2},
	}

	// DurabilityAcked (the zero value) returns once the batch is in the
	// write-ahead log and the log is fsynced.
	if err := c.IngestCandles(ctx, stream, bars, client.DurabilityAcked); err != nil {
		log.Fatal(err)
	}

	resp, err := c.QueryCandles(ctx, client.QueryRequest{
		StreamID:  stream,
		StartTime: start.UnixNano(),
		EndTime:   start.Add(3 * time.Minute).UnixNano(),
	})
	if err != nil {
		log.Fatal(err)
	}
	if resp.Status != client.QueryStatusOK {
		log.Fatalf("query status %d", resp.Status)
	}
	for _, p := range resp.Points {
		fmt.Println(time.Unix(0, p.Candle.Timestamp).UTC().Format(time.RFC3339), p.Candle.Close)
	}
}

This program compiles against the SDK at the commit this page was verified at. The package's runnable examples, which go test executes against an in-process server, are in /client/example_test.go.[5]

From Python, the same token file goes to token_file, which the client re-reads on every connect and before each renewal:

python
import mirexa

with mirexa.connect("localhost:8080", token_file="data/auth/admin.token") as c:
    ...

See the Python SDK reference.

7. Optional: calendars and lineage

A stream's trading calendar, lineage and cache size are changed through the node's control listener (gRPC), which is off by default. Turn it on with a config file:

yaml
storage:
  data_dir: ./data
control:
  enabled: true
  addr: 127.0.0.1:9091
bash
./bin/server -config mirexa.yaml

Set control.addr explicitly. Its default, 127.0.0.1:9090, is the same port as the observability listener's default :9090, so enabling the control listener without changing one of them leaves the node unable to bind both. The CLI's -control flag defaults to 127.0.0.1:9090 too, so pass the address you chose.[6]

bash
./bin/cli calendar set -control 127.0.0.1:9091 -stream nyse:AAPL:1m \
    -timezone America/New_York -hours mon-fri=09:30-16:00

Now a hole in nyse:AAPL:1m during the session is recorded as missing data, and the nights and weekends as closures. See Gaps and trading calendars and Deriving bars.

Next

References

Source

Tests

Further reading


  1. /Makefile build; the Docker image renames server to mirexa-server (/Dockerfile). ↩︎

  2. buildConfig in /cmd/server/main.go refuses to start without a data directory. ↩︎

  3. provisionLocalIssuer and localIssuer.start in /cmd/server/local_issuer.go. ↩︎

  4. parseCandleRow and parseTime in /cmd/cli/main.go; the reader expects exactly six fields per row. ↩︎

  5. Example, Example_rows, Example_subscribe and the others in /client/example_test.go. ↩︎

  6. Control.Addr and Observability.Addr in config.Default (/internal/config/config.go); the control config's validation does not check for the collision. A wildcard listener on port 9090 and a loopback one on the same port cannot both bind on Linux (checked 2026-10-30 with two net.Listen calls). ↩︎