Skip to main content

Message schema

The messages the trading services exchange are defined once, as Protobuf, in apps/gateway/proto. The code that reads and writes them is generated from these definitions.

Files​

FileContent
events.protoEvent, the message of the trading events, with the state of a position, transaction, account or order it carries
live.protoValues that follow the market: Quote, QuotesBatch, PositionStatus, AccountBalance, and the progress and status of a prop challenge
commands.protoThe commands a trading app sends over the WebSocket of live-edge
replay.protoWhat the engine answers live-edge when it reads events from the engine

In events, amounts and prices are decimal strings and times are google.protobuf.Timestamp. A status, a side and similar values are strings with the values the REST API uses.

A command is sent as JSON: an object with the fields of its message and messageType set to the name of the message. live-edge only accepts the commands of commands.proto and answers any other with an error message. The fields of a command are not checked against the schema.

live-edge sends the messages of live.proto about an account as Protobuf. A client that sets format to json in its Login gets them as JSON instead, with messageType set to the name of the message.

Generated code​

Each service holds the generated code for the messages it uses. The generated code is committed.

ServiceDirectoryMessages
fix-positionsprotos/Event, the messages of replay.proto and the live values
signalsprotos/Quote
live-edgesrc/schema/All
historysrc/schema/Quote
Cashier backendsrc/schema/Event and PositionStatus
packages/wintrado-apisrc/schema/All

buf.gen.yaml lists which messages a service gets. The TypeScript code needs @bufbuild/protobuf at runtime, the Go code google.golang.org/protobuf.

Changing a message​

  1. Edit the .proto file.
  2. Run make schema in apps/gateway. It checks the definitions and generates the code. It needs Go and Node.js 22 or later.
  3. Commit the definitions together with the generated code.

The pipeline job Trading Schema generates the code again and fails if it differs from what is committed.

Services are deployed one after the other, and the event stream keeps messages for 7 days. A changed message therefore has to stay readable for code that has the previous definition. Add fields under new numbers. Do not change the number or the type of a field, and do not use the number of a removed field again.