Skip to main content
Anthid provides generated Protocol Buffer definitions that can be used to build Python clients for the Streaming API. This guide demonstrates how to generate the Python gRPC client and subscribe to real-time trading events.

Prerequisites

Install the required Python packages.

Download the Protobuf Definitions

Clone the Anthid protobuf repository.

Generate Python Client Code

Generate Python classes from the protobuf definitions.
The generated output contains the protobuf message definitions and gRPC service stubs required to interact with Anthid services.

Authentication

Streaming requests are authenticated using an API key passed as gRPC metadata.

Subscribe to Events

The example below demonstrates connecting to the server-streaming endpoint and subscribing to broker order and position events.

Bidirectional Streaming

Backend and native applications may prefer the bidirectional StreamEvents endpoint. This endpoint allows subscriptions and unsubscriptions to be sent over an existing stream without creating a new connection.

Handling Disconnects

Applications should automatically reconnect when a stream is interrupted. After reconnecting:
  1. Establish a new stream.
  2. Re-authenticate using the API key.
  3. Re-subscribe to required trading accounts.
  4. Resume event processing.
  • Streaming Overview
  • Trading Accounts
  • Orders
  • Positions
  • Ledger
  • Intents