Mirexa

Get started

Mirexa is one Go program with nothing to install beside it: no external database, no JVM, no coordinator. Build it, start a node, write some candles and read them back, from the command line and from Go. You need Go 1.25 or newer, make and git, on Linux.

  1. Build

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

    The binaries land in ./bin: server (the node), cli (the one command-line tool: ingest, query and subscribe from a shell, bulk-load files, issue access tokens and certificates for a cluster; see Command line) and dashboard (the web console’s API).

  2. Start a node

    shell
    ./bin/server -data-dir ./data
    AddressWhat answers there
    :8080The data port: Mirexa’s binary protocol, which the CLI and the Go SDK speak.
    :9090/metrics (Prometheus), /health and /ready. If the port is taken, the node does not start.
    check it is up
    curl -s localhost:9090/ready
    {"ready":true,"started":"…","checks":[{"name":"tcp_listener","status":"healthy"},{"name":"data_dir","status":"healthy"}]}

    Authentication is on from the first start. With no keys configured, the node makes its own: a signing key in ./data/auth/issuer.key and an admin token in ./data/auth/admin.token, which it re-mints every 20 minutes while it runs. Every client below reads that file. The startup log names both paths.

    The data port listens on every interface. Anything that can reach port 8080 still needs a token, but traffic is plaintext until you turn on TLS. Step 6 covers narrower tokens and your own keys.
  3. Write some candles

    The CLI reads CSV from standard input, one bar per line: timestamp,open,high,low,close,volume. A timestamp is RFC 3339 or Unix nanoseconds. A stream is named exchange:symbol:timeframe.

    candles.csv
    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
    shell
    ./bin/cli ingest -stream binance:BTCUSDT:1m -token-file data/auth/admin.token < candles.csv
    ingested 3 candles into binance:BTCUSDT:1m in 1 batch(es)

    The command returns once the node has written the batch to its write-ahead log and fsynced it, so an acknowledged candle survives a crash.

  4. Read them back

    Every data command takes the token the same way. To skip the flag, set MIREXA_TOKEN once: export MIREXA_TOKEN=$(cat data/auth/admin.token). The token lasts an hour and the node re-mints it, so -token-file, which reads the current one, is the better habit: an exported copy goes stale.

    a time range
    ./bin/cli query -stream binance:BTCUSDT:1m -token-file data/auth/admin.token \
      -start 2026-10-20T09:30:00Z -end 2026-10-20T09:33:00Z
    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 and the end exclusive. Add -gaps to get the missing bars as rows too, marked gap; through the Go SDK each one also says whether the market was closed or the data is missing.

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

    -rollup builds bars of any length the rules allow from the stored ones (or, with -ticks, from trades) and stores nothing. To have the node store a derived timeframe as data arrives, declare it with ./bin/cli lineage set.

    history, then live
    ./bin/cli subscribe -stream binance:BTCUSDT:1m -backfill -token-file data/auth/admin.token

    Sends the stored history first, then every new bar as it is written. Stop it with Ctrl+C.

  5. Use it from Go

    shell
    go get github.com/AmiraliOmidvar/mirexa/client
    main.go
    package main
    
    import (
    	"context"
    	"fmt"
    	"log"
    	"os"
    	"strings"
    	"time"
    
    	"github.com/AmiraliOmidvar/mirexa/client"
    )
    
    func main() {
    	// The node's admin token. The client reads the file on every connect and
    	// renews the session over the open connection before the token 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")
    	start := time.Now().Truncate(time.Minute).Add(-3 * time.Minute)
    
    	// Three closed one-minute bars. DurabilityAcked returns once they are in
    	// the write-ahead log and the log is fsynced.
    	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},
    	}
    	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)
    	}
    	for _, p := range resp.Points {
    		fmt.Println(time.Unix(0, p.Candle.Timestamp).UTC().Format(time.RFC3339), p.Candle.Close)
    	}
    }

    The same package has a Batcher that groups records into batches for you, QueryCandlesRows for ranges too large for one response, QueryColumns to read only the columns you need (the closes of a long history, say) as slices, SubscribeStream for live data, ticks alongside candles, and a client that reconnects on its own (DialResilient). A shed write is retried for you; a write whose fate is unknown after a dropped connection is returned as ErrAmbiguous, never retried blindly. The Go client reference covers all of it, and there is a Python client with pandas and polars, whose query_columns does the same into NumPy arrays.

  6. Tokens and keys

    Access tokens are Ed25519-signed and checked offline: the node needs only a public key to trust. The admin token carries every permission. For anything else, mint a token with only what it needs, from the node’s own key:

    shell
    ./bin/cli token issue -key data/auth/issuer.key \
      -perms READ_CANDLES,LIST_STREAMS -validity 30m > token
    
    ./bin/cli streams -token-file token
    exchange,symbol,timeframe
    binance,BTCUSDT,1m
    1 stream(s)

    The node’s key is fine on a laptop, but it lives on the node, and it can mint any permission. For anything real, keep the signing key elsewhere and give the node only its public half. Once trusted_keys lists a key, the node generates nothing.

    make a signing key
    ./bin/cli token keygen -dir ./keys -name ops

    It prints the configuration to add. Put it in a file, say mirexa.yaml, and restart the node with it:

    mirexa.yaml
    storage:
      data_dir: ./data
    security:
      auth:
        trusted_keys:
          - name: ops
            public_key: "…the base64 line keygen printed…"
    shell
    ./bin/server -config mirexa.yaml
    
    ./bin/cli token issue -key keys/ops.key \
      -perms READ_CANDLES,WRITE_CANDLES,LIST_STREAMS -validity 30m > token
    • The data permissions are READ_CANDLES, WRITE_CANDLES, READ_TICKS, WRITE_TICKS and LIST_STREAMS; listing streams needs LIST_STREAMS. ADMIN_CLUSTER is for the control listener when control.admin_auth is on, and ADMIN_STREAM for changing stream settings from a client over the data port. Command line, Authentication lists what each command needs.
    • A token lives at most one hour. In Go, pass Options.TokenSource instead of Token: the client calls it to renew the session over the open connection before the token expires, and again on every reconnect, so a token file refreshed in time keeps a long-running program connected. The CLI does the same with -token-file.
    • Keep ops.key off the node: it can mint any permission. A single token cannot be revoked. To cut off a key's outstanding tokens early on a single node, take the key out of trusted_keys and restart; a cluster can revoke a key through its control API, and every node stops accepting its tokens within about a quarter of a second.
    • A cluster does not make its own key: every node must list the same trusted_keys, and a clustered node with authentication on and none listed refuses to start.
    • security.auth.enabled: false turns authentication off. A client is then accepted with no token, and the permissions it asks for are taken on trust, still capped by security.max_permissions. Do not expose such a node to an untrusted network.
  7. Configure it

    Every setting lives in one YAML file passed with -config; configs/example.yaml walks through the main sections. Any of them can also be set from the environment as MIREXA_<SECTION>_<FIELD>, for example MIREXA_NETWORK_ADDR=127.0.0.1:8080. The ones to know first:

    SettingDefaultWhat it does
    network.addr:8080Where the data port listens.
    observability.addr:9090Metrics, health and readiness.
    control.addr127.0.0.1:9091The control listener, with control.enabled: true: stream calendars and lineage (./bin/cli calendar, ./bin/cli lineage).
    wal.sync_policyalwaysAcknowledge a write only after an fsync. interval syncs on a timer instead: faster, but a crash can lose the last moments of acknowledged writes.
    storage.decoded_chunk_cache_bytes256 MiBMemory for recently read chunks, held compressed (about 12 bytes a candle).
    security.auth.enabledtrueRequire a signed token on the data port. With no trusted_keys, a single node makes its own key and admin token (step 6).
    security.tls_enabledfalseTLS 1.3 on the data port, with cert_file and key_file.

Where next