WebAPI is B2Broker's unified trading API, abstracting MT4, MT5, and cTrader behind a single gRPC interface. This article explains the architecture decisions that make cross-platform integration practical.
gRPC and Protocol Design
We chose gRPC for performance, streaming support, and strong typing. Trading operations require low latency; gRPC's binary protocol and HTTP/2 multiplexing reduce overhead compared to REST. Streaming is first-class: position updates, order fills, and account changes flow in real time without polling.
Service definitions follow domain boundaries: AccountService, OrderService, PositionService, SymbolService. Each platform implements these interfaces via adapters that translate between WebAPI's unified model and platform-specific APIs.
Unified Data Models
Volume normalization was critical. MT4 uses lots; MT5 and cTrader use different units. We standardized on 1/100000000 (one hundred millionth) as the base unit. All platforms convert to and from this scale in their adapters. Applications never see platform-specific volume formats.
Symbols are mapped to a canonical format. Each platform has its own naming (e.g., EURUSD vs. EUR/USD); WebAPI exposes a consistent symbol identifier. Adapters handle translation.
Real-Time Streaming
Position and order streams use gRPC server streaming. Clients subscribe to account updates and receive events as they occur. This enables copy trading, risk monitoring, and live dashboards without polling. The streaming layer handles reconnection and backpressure.
AWS Deployment
WebAPI runs on AWS with multi-AZ deployment for high availability. Platform adapters connect to trading servers over secure channels. The architecture scales horizontally; platform adapters can be scaled independently based on load.
Lessons Learned
Building a unified API requires upfront design for normalization and extensibility. New platforms are added by implementing the adapter interface—no changes to core services or client applications. This architecture has enabled B2Copy, B2Core, and other products to support multiple platforms with a single integration.