Streaming API
Real-time server-streaming feeds for external integrators (prop back office, PAMM/MAM, risk and reporting, bridges). A client opens one subscribe stream per feed, then receives a continuous flow of events until it disconnects. This document is the integration and operations layer on top of the streaming contract; the full .proto is in the appendix.
At a glance
Endpoint |
|
Protocol | gRPC-web (not native gRPC) over HTTPS |
Package |
|
Auth | partner key in the |
Scope |
|
Shape | one subscribe request per stream, then server-streamed events |
Keep-alive | a |
Why gRPC-web, not native gRPC
The gateway itself speaks native gRPC (HTTP/2), but it is not exposed directly. So the public endpoint is an Envoy proxy that speaks gRPC-web to the outside world and translates to native gRPC on the private network to the gateway.
What this means for you:
- Use a gRPC-web client:
@connectrpc/connect-web, the referencegrpc-webJS library, or any Connect / gRPC-web-capable stack. A Connect client configured with a gRPC-web transport works from both Node and the browser. - A native gRPC client (for example
@grpc/grpc-jspointed straight at the endpoint) will not work through the public proxy. Native gRPC only works if you are on the private network alongside the gateway. - Server streaming arrives as chunked responses, which the HTTP edge forwards fine. Long-lived streams have no server-side idle timeout.
Public TLS terminates at the platform edge, so you always connect over https://. There is no separate certificate to install.
Authentication
Every stream must carry a partner key in the authorization metadata header:
authorization: Bearer psk_<prefix>_<secret>
The gateway hashes the presented key and validates it (scope-checked and revocable; only the hash is ever stored). A missing, unknown, revoked, or out-of-scope key closes the stream with UNAUTHENTICATED. Everything you stream is automatically scoped to the organisation the key belongs to; there is no cross-tenant access.
Key validity is cached at the gateway for up to 60 seconds, so issuing or revoking a key takes effect on the next connect within that window.
Getting a key
Your VOID operator issues partner keys from the Partner keys page in the manager console, and hands you the plaintext value. The same page revokes them, and every issue and revoke is recorded in their audit trail.
The plaintext is shown only once at creation and cannot be recovered, so store it in your secret manager as soon as you receive it. If it is lost or you suspect it is compromised, ask your operator to revoke it and issue a replacement.
The key format is psk_<8 hex>_<48 hex>. The psk_<prefix> portion is non-secret and stays visible to your operator, so quote it if you need them to identify a specific key. The secret half is never recoverable.
The feeds
All streams live in package void.broker.v1. Each RPC takes one subscribe request and returns a server stream. Every stream message is a oneof of a data event OR heartbeat = true. All nine are live.
Service | RPC | Streams | Cadence |
|---|---|---|---|
|
| open positions (opened / modified / closed) | per event |
|
| pending orders (placed / filled / cancelled) | per event |
|
| alerts (stop-out, daily-loss, SL/TP hits) | per event |
|
| live account equity snapshots | up to 1/sec per account, only while it has open positions |
|
| live bid/ask with the org's markup applied | up to 5/sec per symbol |
|
| cash movements (deposits, withdrawals, payouts, fees) | per event |
|
| "catalog changed, re-pull via REST" signal | per change (coarse, see below) |
|
| "catalog changed, re-pull via REST" signal | per change (coarse, see below) |
|
| account lifecycle changes (created / updated / disabled / enabled / archived) | per event |
Two behaviours worth designing around:
- Equity is a sampled snapshot, not a per-tick feed. It flows only for accounts that currently hold open positions (the set whose equity moves between discrete events), coalesced to at most one snapshot per account per second. A flat account emits nothing; derive its equity from its balance via the REST API.
SymbolsandGroupsare the same coarse signal. Both are driven by one catalog-change notification, so a symbol change and a group change each fire both streams, and the id field is always empty. Read either as "something in the catalog changed, re-pull it", not as a precise per-symbol or per-group diff. Subscribing to one of the two is enough.
Subscribe filters:
- Most feeds take a
SubscribeRequest { repeated string logins }. Emptylogins= every account under your org; otherwise only those platform account ids. - Quotations takes
QuotesSubscribeRequest { repeated string symbols }. Emptysymbols= every symbol enabled for your org. Prices already have your org's per-symbol spread markup applied.
See the appendix for the complete .proto with the full field-level shape of every message.
Client example (Node, Connect + gRPC-web)
import { createGrpcWebTransport } from "@connectrpc/connect-web"
import { createClient } from "@connectrpc/connect"
// Generate these from the .proto in the appendix below,
// with buf / protoc-gen-connect-es.
import { OpenPositionsService } from "./gen/void_broker_v1_connect"
const PARTNER_KEY = process.env.VOID_PARTNER_KEY! // psk_...
const transport = createGrpcWebTransport({
baseUrl: "https://grpc.voidtrading.io",
})
const client = createClient(OpenPositionsService, transport)
async function main() {
const stream = client.getOpenPositionsStream(
{ logins: [] }, // empty = all accounts under the org
{ headers: { authorization: `Bearer ${PARTNER_KEY}` } },
)
for await (const event of stream) {
if (event.payload.case === "heartbeat") continue // idle keep-alive
const position = event.payload.value
console.log(position.login, position.symbol, position.profit)
}
}
main().catch((err) => {
// UNAUTHENTICATED here means a missing / unknown / revoked / out-of-
// scope key. Reconnect with backoff on transport-level drops.
console.error("stream closed:", err)
})
The same pattern applies to every service: create a client for the service, call its stream method with the subscribe request and the authorization header, and iterate. Skip messages whose payload case is heartbeat.
Operational notes
- Heartbeats. Expect a
heartbeat = trueroughly every 30s on an otherwise idle stream. It keeps the connection warm through proxies and load balancers; treat it as a liveness signal, not data. - Reconnects. Streams are long-lived but not guaranteed permanent (deploys, edge restarts). Reconnect with exponential backoff on any transport-level close. On reconnect you get the current live flow, not a replay; use the REST API for point-in-time snapshots.
- Re-sync signals. The
Symbols,Groups, andAccountInfostreams are low-frequency "something changed, re-pull via REST" notifications so you can keep local caches fresh without polling. An empty id (for symbols/groups) means "re-pull everything". - Scoping. Every feed is org-scoped by the partner key. You never see another tenant's data, and the
logins/symbolsfilters can only narrow within your own org.
Related contracts
- Streaming contract: the complete
.protois inlined in the appendix below. - REST APIs for snapshots and mutations live behind the manager OpenAPI spec (the REST reference in this portal).
Appendix: the full .proto contract
This is the complete streaming contract. To build a client, save it as void_broker_v1.proto and generate stubs with your gRPC-web toolchain (for example buf generate, or protoc with protoc-gen-connect-es / protoc-gen-grpc-web). It is self-contained: proto3, no imports.
syntax = "proto3";
package void.broker.v1;
// VOID Trader broker streaming API, v1.
//
// Server-streaming gRPC feeds for external integrators (prop back
// office, PAMM/MAM, risk/reporting, bridges).
// A client sends one subscribe request carrying filters, then receives a
// continuous stream of messages. Each stream message is
// a `oneof` of a data event OR a periodic `heartbeat = true` emitted
// when the stream is idle (~30s) so peers and load balancers keep the
// connection warm.
//
// All nine services below are implemented and served by the gateway.
// Eight are sourced from the internal execution-event bus; Quotations is
// sourced from the market-data tick bus with the org's spread markup
// applied.
//
// Note on SymbolsService / GroupsService: both ride the same coarse
// catalog-change signal, so either kind of change fires BOTH streams and
// the id is always empty, meaning "re-pull everything". Treat them as a
// single "catalog changed, re-sync" notification rather than a precise
// per-symbol or per-group diff.
message SubscribeRequest {
// Optional filter: stream only these account logins (platform account
// ids). Empty = every account under the authenticated partner's org.
repeated string logins = 1;
}
// ─── Open positions ──────────────────────────────────────────────────
enum PositionStatus {
POSITION_STATUS_UNSPECIFIED = 0;
OPENED = 1;
MODIFIED = 2;
CLOSED = 3;
}
message OpenPosition {
string position_id = 1; // user-visible position id
string login = 2; // platform account id
string symbol = 3;
string side = 4; // BUY | SELL
double volume = 5; // lots
double open_price = 6;
double current_price = 7;
optional double stop_loss = 8;
optional double take_profit = 9;
double swap = 10;
double commission = 11; // fees booked on the position
double profit = 12; // floating P&L (net P&L once CLOSED)
double margin = 13;
int64 open_time = 14; // epoch ms
PositionStatus status = 15;
optional double close_price = 16; // set on CLOSED
}
message OpenPositionEvent {
oneof payload {
OpenPosition position = 1;
bool heartbeat = 2;
}
}
// ─── Pending orders ──────────────────────────────────────────────────
enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
PLACED = 1;
FILLED = 2;
CANCELLED = 3;
}
message Order {
string order_id = 1;
string login = 2;
string symbol = 3;
string side = 4; // BUY | SELL
double volume = 5;
string pending_type = 6; // LIMIT | STOP
double activation_price = 7; // trigger price
optional double stop_loss = 8;
optional double take_profit = 9;
OrderStatus status = 10;
int64 event_time = 11; // epoch ms
}
message OrderEvent {
oneof payload {
Order order = 1;
bool heartbeat = 2;
}
}
// ─── Trading events (alerts) ─────────────────────────────────────────
enum TradingEventType {
TRADING_EVENT_TYPE_UNSPECIFIED = 0;
MARGIN_STOP_OUT = 1;
DAILY_LOSS_LIMIT = 2;
STOP_LOSS_HIT = 3;
TAKE_PROFIT_HIT = 4;
}
message TradingEvent {
TradingEventType type = 1;
string login = 2;
string symbol = 3;
string position_id = 4;
double price = 5; // close price the event fired at
double net_pnl = 6;
int64 timestamp = 7; // epoch ms
}
message TradingEventMessage {
oneof payload {
TradingEvent event = 1;
bool heartbeat = 2;
}
}
// ─── Account equity (live snapshots) ─────────────────────────────────
// Coalesced snapshot of an account's live equity. Produced by the risk
// evaluator on its per-tick stop-out path (throttled ~1/sec/account),
// so it only flows for accounts with open positions, the exact set
// whose equity moves between discrete events.
message AccountEquity {
string login = 1; // platform account id
double equity = 2; // balance + open P&L
double balance = 3;
double margin = 4;
double free_margin = 5;
double margin_level = 6; // (equity / margin) * 100; 0 when flat
double open_pnl = 7; // mark-to-market unrealised P&L
}
message AccountEquityEvent {
oneof payload {
AccountEquity equity = 1;
bool heartbeat = 2;
}
}
// ─── Quotations (live prices, with the org's markup applied) ─────────
// Real-time bid/ask for the partner's org, sourced from the Redis tick
// bus (one upstream provider connection for the whole platform) with the
// org's per-symbol spread markup applied (org_instruments.spread_type /
// spread_markup_pips). Throttled per symbol per subscription.
message QuotesSubscribeRequest {
// Symbols to stream. Empty = every symbol enabled for the org.
repeated string symbols = 1;
}
message Quotation {
string symbol = 1;
double bid = 2; // markup applied
double ask = 3; // markup applied
double spread = 4;
int64 timestamp = 5; // epoch ms
optional double day_high = 6;
optional double day_low = 7;
}
message QuotationEvent {
oneof payload {
Quotation quotation = 1;
bool heartbeat = 2;
}
}
// ─── Ledger (cash movements) ─────────────────────────────────────────
// Deposits, withdrawals, manual adjustments, payouts, and fees as they
// commit to account_transactions. Amount is always positive; the sign is
// implied by `kind`.
message LedgerEntry {
string id = 1;
string login = 2; // platform account id
string kind = 3; // deposit | withdrawal | payout | manual_credit | ...
double amount = 4; // always positive
string note = 5;
int64 created_at = 6; // epoch ms
}
message LedgerEntryEvent {
oneof payload {
LedgerEntry entry = 1;
bool heartbeat = 2;
}
}
// ─── Config-change notifications (re-sync signals) ───────────────────
// Low-frequency "something changed, re-pull via REST" signals so an
// integrator can keep local caches in sync. Symbol + group changes ride
// the platform's existing catalog_changed signal (coarse, an empty id
// means "re-pull all"); account changes carry the specific account +
// lifecycle transition.
message SymbolChange {
string symbol = 1; // empty = re-pull the whole symbol catalog
int64 changed_at = 2;
}
message SymbolChangeEvent {
oneof payload { SymbolChange change = 1; bool heartbeat = 2; }
}
message GroupChange {
string group_id = 1; // empty = re-pull all groups
int64 changed_at = 2;
}
message GroupChangeEvent {
oneof payload { GroupChange change = 1; bool heartbeat = 2; }
}
message AccountInfoChange {
string login = 1; // platform account id
string change = 2; // created | updated | disabled | enabled | archived
int64 changed_at = 3;
}
message AccountInfoChangeEvent {
oneof payload { AccountInfoChange change = 1; bool heartbeat = 2; }
}
// ─── Services ────────────────────────────────────────────────────────
service OpenPositionsService {
rpc GetOpenPositionsStream(SubscribeRequest) returns (stream OpenPositionEvent);
}
service OrdersService {
rpc GetOrdersUpdateStream(SubscribeRequest) returns (stream OrderEvent);
}
service TradingEventsService {
rpc GetTradingEventsStream(SubscribeRequest) returns (stream TradingEventMessage);
}
service EquityService {
rpc GetEquityStream(SubscribeRequest) returns (stream AccountEquityEvent);
}
service QuotationsService {
rpc GetQuotationsWithMarkupStream(QuotesSubscribeRequest) returns (stream QuotationEvent);
}
service LedgerService {
rpc GetLedgersStream(SubscribeRequest) returns (stream LedgerEntryEvent);
}
service SymbolsService {
rpc GetSymbolsChangedStream(SubscribeRequest) returns (stream SymbolChangeEvent);
}
service GroupsService {
rpc GetGroupChangesStream(SubscribeRequest) returns (stream GroupChangeEvent);
}
service AccountInfoService {
rpc GetTradingAccountInfoChangedStream(SubscribeRequest) returns (stream AccountInfoChangeEvent);
}
On this page
- Streaming API