Skip to main content
Anthid provides Protocol Buffer definitions that can be used to generate Rust clients with Tonic. This guide demonstrates connecting to the Streaming API and receiving real-time broker order and position updates.

Prerequisites

Add the required dependencies.

Generate Rust Types

Generate Rust code from the Anthid protobuf definitions.
Example build.rs:
Example Cargo.toml build dependency:

Authentication

Anthid authenticates streaming requests using the x-api-key metadata header.

Subscribe to Events

The SubscribeEvents endpoint provides a server-streaming interface suitable for most applications.

Handling Events

Each TradingEvent contains a single event variant.

Bidirectional Streaming

Backend and native applications may use StreamEvents when subscriptions need to be modified over an existing connection.

Handling Disconnects

Applications should automatically reconnect when a stream closes unexpectedly. After reconnecting:
  1. Create a new stream.
  2. Authenticate using the API key.
  3. Re-subscribe to required trading accounts.
  4. Resume event processing.
  • Streaming Overview
  • Python Guide
  • Trading Accounts
  • Orders
  • Positions
  • Ledger
  • Intents