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
git clone https://github.com/AmiraliOmidvar/mirexa.git
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/ |
the storage node | mirexa- (its name in the Docker image) |
bin/ |
every operator command: ingest, query, subscribe, bulk load, calendars, lineage, cluster, and the offline token and certs |
mirexa- |
bin/ |
the web dashboard's API | — |
2. Start a node
./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 |
|---|---|
: |
the data port: Mirexa's binary protocol, spoken by the CLI and the SDKs |
: |
/ (Prometheus), / and / |
Check it is up:
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:
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
./bin/cli ingest -token-file ./data/auth/admin.token -stream binance:BTCUSDT:1m < candles.csv
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
./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
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:
./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
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:
./bin/cli streams -token-file ./data/auth/admin.token
5. Subscribe
./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
go get github.com/AmiraliOmidvar/mirexa/client
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:
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:
storage:
data_dir: ./data
control:
enabled: true
addr: 127.0.0.1:9091
./bin/server -config mirexa.yaml
Set
control.addrexplicitly. 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-controlflag defaults to127.0.0.1:9090too, so pass the address you chose.[6]
./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
- Writing data and Reading data — the full write and read surface.
- Bulk loading files — load CSV or Parquet history.
- Running a node and the configuration reference.
- mirexa-cli and Go SDK references.
References
Source
- /Makefile — the
buildtarget. configFromFlags,buildConfig—-config,-data-dir, defaults and validation.config.Default— ports and defaults.- /internal/observability/server.go —
/metrics,/health,/ready. - /cmd/cli/main.go — the CSV formats and subcommands.
- /client/client.go, /client/example_test.go
Tests
Examplein /client/example_test.go — connect, write, read back.TestServerBinary_ANodeWithNoAuthConfigIssuesItsOwnAdminTokenin /tests/server_binary_default_auth_test.go — a node started with no auth configuration refuses a tokenless client, and a client reading its admin token writes and reads back.TestServer_AckedCandleIngestIsInWALBeforeAckin /tests/ack_durability_test.goTestRegisterStream_ImplicitOnFirstWriteUsesDefaultsin /internal/ingestion/registration_test.goTestCLI_CalendarChangesRefileAStreamsGapsin /tests/cli_calendar_test.go — drives the built CLI against a node.
Further reading
/Makefile
build; the Docker image renamesservertomirexa-server(/Dockerfile). ↩︎buildConfigin /cmd/server/main.go refuses to start without a data directory. ↩︎provisionLocalIssuerandlocalIssuer.startin /cmd/server/local_issuer.go. ↩︎parseCandleRowandparseTimein /cmd/cli/main.go; the reader expects exactly six fields per row. ↩︎Example,Example_rows,Example_subscribeand the others in /client/example_test.go. ↩︎Control.AddrandObservability.Addrinconfig.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 twonet.Listencalls). ↩︎