Wiki Reference
Python SDK
The mirexa Python package — a separate repository speaking Mirexa's wire protocol natively, with sync and asyncio clients, pandas and polars, cluster redirects, token renewal and TLS.
mirexa is the Python client for Mirexa. It speaks the binary
wire protocol directly — no HTTP gateway in between — and follows the
same request rules as the Go SDK: what is retried, what is ambiguous, how
redirects are followed. It lives in its own repository, versioned separately from the
server: https://github.com/AmiraliOmidvar/mirexa-python. Its README is the full reference;
this page is a map of what the package offers and where it differs from the Go SDK.
Everything on this page was read from the Python repository at commit
07d4a40(package version0.1.0.dev0, development status alpha). The server repository does not contain that code, so none of it is checked by this repository's tests. Treat the client's own README and test suite as authoritative where they differ from this page.
Installing
pip install 'mirexa[pandas]'
pip install 'mirexa[polars]'
Python 3.10 or newer. The one required dependency is google-crc32c (a pure-Python fallback
exists). The pandas and polars extras add those libraries and NumPy.
| Package | Speaks | Talks to |
|---|---|---|
| 0.1.x | wire protocol v2 (mirexa.) |
any Mirexa server whose handshake is v2 |
A node answering in another protocol version raises UnsupportedVersionError and is not
retried.
Clients
| Name | What it is |
|---|---|
mirexa. |
A connected synchronous client. addr is one host: or a list of contact points. Usable as a context manager. |
mirexa. |
The asyncio client: the same constructor and methods, as coroutines. Use one per event loop. |
Client, AsyncClient |
The classes behind them. |
The two clients are one implementation of the request rules (_core.py) with two ways of
waiting; the package's test suite runs every behaviour test against both.
Connection options
| Option | Default | Meaning |
|---|---|---|
token |
none | A token from mirexa-. Never renewed: it has nothing newer to offer. |
token_ |
none | A file re-read on every connect, and before each renewal. |
token_ |
none | A callable returning a token, used like token_. |
permissions |
read/write candles and ticks, ADMIN_ |
What an unauthenticated client asks for; only a node with authentication off accepts it. |
tls |
False |
True for the system trust store, or an ssl.. |
server_ |
the address host | The name the node's certificate must carry. |
connect_, request_ |
10 s, 30 s | |
max_ |
16 MiB | Floor 4 KiB. |
retry_, retry_, retry_ |
1000, 5 ms, 250 ms | Re-sending a shed (Overloaded) request, as in the Go SDK. |
reconnect_, reconnect_, reconnect_ |
3, 100 ms, 5 s | Redialling a node. |
max_ |
3 | Hops one request may take. |
disable_ |
False |
Turns automatic token renewal off. |
Methods
| Method | Does |
|---|---|
ingest_ |
mode: "live" (new bars, and restates stored ones), "history" (bulk back-fill), "correction" (restates stored bars only). overwrite=True writes a derived stream. |
ingest_ |
Trades. |
ingest_ |
Candles from a pandas or polars frame, in batches of 5,000 by default. |
query_ |
CandleResult: ., ., ., ., ., ., .. |
query_ |
ColumnResult: the stamps and only the named columns as NumPy arrays. |
query_ |
TickResult. |
list_ |
Every node's streams, merged. Needs LIST_. |
nodes() |
The cluster's nodes (empty for a single node). |
list_ |
The gap index as ranges, with a summary. |
fill_ |
Ask the node to fill one open gap ("linear", "forward", "backward"). Never a market closure. |
accept_ |
Accept or put back a derived bar's INCOMPLETE mark. |
get_, set_, add_, remove_, set_, clear_ |
Stream metadata; every change needs ADMIN_. |
subscribe(stream, ticks=, backfill=, start=, resume=, follow_ |
An iterator of Event; sub. waits a bounded time. |
reauthenticate() |
Renew the token on every open connection now. |
Times may be Unix nanoseconds (int), datetime, ISO-8601 strings, pandas.Timestamp or
numpy.datetime64; a naive time is UTC. A float is refused, because seconds and
nanoseconds would be a guess.
pandas and polars
to_pandas() returns candles only, with a UTC DatetimeIndex; gaps are never NaN rows but a
separate frame from gaps_frame() with start, end, status, reason and fillable.
fillable comes from the node's own rule, so a market closure is never fillable. Polars has
no index, so time is a time column of type Datetime("ns", "UTC"). to_pandas(prices="decimal")
returns exact decimal.Decimal prices recovered from the stored fixed point.
Behaviour shared with the Go SDK
- An acknowledged write is in the node's write-ahead log, fsynced, when the call returns.
- Only
Overloadedis retried, and it promises nothing was stored. - A connection that fails while a write is on the wire raises
AmbiguousWriteError. Reconcile by reading the range back. The client never re-sends for you: a re-sent candle batch overwrites anything restated meanwhile, and a re-sent trade batch can store a trade twice. - A write that never left (the node had closed an idle connection) goes out fresh.
- Reads are retried on a new connection.
- Subscriptions report dropped batches; history and live overlap at the boundary, so dedupe by timestamp.
Where it differs from the Go SDK
| Topic | Python | Go public package |
|---|---|---|
| Redirects | Followed: give one or several contact points; routes are cached by partition and only move to a strictly newer epoch. An older epoch is asked again for about 1.3 s, then NodeBehindError; two nodes contradicting each other at one epoch raise RedirectLoopError. |
Returned as *RedirectError; not followed. |
| Fenced writes | A write carries the partition epoch it last learned. | Writes carry no epoch. |
| Subscriptions across moves | Follow a moved partition to its new primary, resuming past the last record. | ResumingSubscriber with FollowRedirects. |
| Listing | list_ asks every node and raises PartialListingError (with what the others returned) if one does not answer. |
One node per call. |
| Token renewal | With token_ or token_, at two-thirds of a token's life, over the open connection. |
With Options., the same. |
| Not available | No multi-query (QueryMultiAll); no automatic fallback to a copy when a primary is down; no spreading of reads over copies. allow_ lets a copy answer only if the request lands on one. A fire_ write cannot be redirected. |
— |
Errors
All errors derive from MirexaError.
| Error | Meaning |
|---|---|
RemoteError |
The node answered with an ERROR frame: ., ., ., . (true only for Overloaded). |
OverloadedError, UnauthorizedError, SlowConsumerError, PartitionUnavailableError, DerivedStreamError, HistoryRequiredError |
RemoteError subclasses by code. HistoryRequiredError: the bars are older than anything stored, or between stored chunks; nothing was stored, re-send with mode="history". |
ErrorCode |
The codes as an IntEnum, 0x0001–0x000B. See Error codes. |
RetriesExhaustedError |
Every attempt was shed; _ is the last one. |
TransportError, ClientClosedError, RequestTimeoutError |
The connection failed or is closed, or no answer came in time. |
AmbiguousWriteError |
A TransportError: the write's outcome is unknown. |
RedirectError |
Another node serves the stream: ., ., ., .. |
RedirectLoopError, NodeBehindError, PartialListingError |
Routing outcomes (above). |
QueryStatusError, StreamNotFoundError |
A query answered a non-OK status. |
WireFormatError and subclasses, including UnsupportedVersionError |
Bytes that do not decode; the connection is ended. |
MappingError |
A column mapping (parse_) that cannot be used. |
Conformance with the server
The repository carries a frozen conformance suite, tests/conformance/wire-v2.json: every
frame the client speaks as bytes beside their meaning, produced by the server's own Go codecs,
plus malformed frames with the reason the server refuses each. The Python tests decode and
re-encode every one. The same file is held in this repository at
/conformance/wire-v2.json and checked by the server's
internal/wire conformance tests (the client README still says the server repository
carries no copy; at this commit it does). The Python suite's server tests build mirexa-server
and mirexa-cli (whose token and certs commands they also use) from the directory named by
MIREXA_REPO, or use prebuilt binaries from MIREXA_SERVER_BIN and MIREXA_CLI_BIN, and skip
without them.
Performance
The client's README records one benchmark run (2026-10-22, client 2e9ecad, server
2fa192c, one node on a 12-core laptop under other load, so floors rather than figures):
reading 20 symbols × 1 year of 1-minute candles (10.5M rows) into pandas at 5.40M rows/s,
polars 5.48M, the asyncio client 6.55M, against 7.39M for the Go SDK on the same reads; bulk
loading by ingest_dataframe(mode="history") at 127K rows/s, bound mostly by the node's disk
syncs. See the README's Performance section for the method and caveats. Not re-measured
for this page.
References
Source
- Python client, separate repository: https://github.com/AmiraliOmidvar/mirexa-python —
README.md,src/mirexa/client.py,src/mirexa/aio.py,src/mirexa/_core.py,src/mirexa/errors.py. - /conformance/wire-v2.json — the frozen wire conformance suite both repositories check.
- /internal/wire — the server-side codecs the suite was produced by.
Tests
- In the Python repository:
tests/test_conformance.py,tests/test_routing.py,tests/test_cluster.py,tests/test_renewal.py,tests/test_tls.py,tests/test_async.py,tests/test_stale_reads.py(not run for this page). - In this repository:
TestConformance_TheCodecsAgreeWithTheFrozenFixturesandTestConformance_AMutatedFixtureIsReportedin /internal/wire/conformance_test.go.
Further reading
- Go SDK — the rules this client mirrors.
- Wire protocol, Error codes, Permissions
- Authentication and tokens, TLS and certificates
- Partitions and routing
External
- pandas documentation, pandas development team — https://pandas.pydata.org/docs/
- Polars user guide, Polars — https://docs.pola.rs/
- asyncio — Asynchronous I/O, Python Software Foundation — https://docs.python.org/3/library/asyncio.html