Trading Gateway

The Trading Gateway is an open-source trading proxy that normalises multiple broker APIs into a single REST + WebSocket interface. It implements the same Trading API protocol as the Tektii Engine, so your strategy code works identically in backtest and live modes — zero code changes.

Why Use the Gateway?

The Trading API defines a unified protocol. The Tektii Engine implements it for backtesting; the Trading Gateway implements it for paper and live trading. Your strategy connects to whichever runtime you choose:

RuntimePurposeProvider
Tektii EngineBacktesting against historical dataBuilt-in simulation
Trading GatewayPaper and live tradingAlpaca, Binance

Write your strategy once. Backtest it on the Engine. Deploy it to the Gateway. No code changes required.

Supported Providers

ProviderPaper TradingLive Trading
Alpacaalpaca-paperalpaca-live
Binancebinance-testnetbinance-live

Oanda and Saxo adapters are in the codebase but not yet documented. See the GitHub repository for the latest provider support.

Each Gateway instance serves exactly one provider, determined by which environment variables you configure. If you set credentials for multiple providers, the first provider detected at startup is used and the others are ignored.

Prerequisites

You need one of:

  • Docker (recommended) — no Rust toolchain required
  • Rust toolchain — version 1.91.0 or later

Installation

Docker (Recommended)

docker pull ghcr.io/tektii/trading-gateway:latest

Build from Source

git clone https://github.com/Tektii/trading-gateway.git
cd trading-gateway
cargo build --release

Provider Configuration

The Gateway uses environment variables for all configuration — no config files. Set the credentials for the provider you want to use.

Alpaca

VariableDescription
ALPACA_API_KEYYour Alpaca API key
ALPACA_API_SECRETYour Alpaca API secret
ALPACA_PAPERSet to true for paper trading

Get your API keys from the Alpaca Dashboard.

Binance

VariableDescription
BINANCE_API_KEYYour Binance API key
BINANCE_API_SECRETYour Binance API secret
BINANCE_TESTNETSet to true for testnet

Get your API keys from Binance API Management. For testnet, use the Binance Testnet.

Starting the Gateway

Docker

docker run -d \
  -p 8080:8080 \
  -e ALPACA_API_KEY=your-key \
  -e ALPACA_API_SECRET=your-secret \
  -e ALPACA_PAPER=true \
  ghcr.io/tektii/trading-gateway:latest

From Source

export ALPACA_API_KEY=your-key
export ALPACA_API_SECRET=your-secret
export ALPACA_PAPER=true
cargo run --release

Verify It's Running

All traffic runs on port 8080:

EndpointPurpose
http://localhost:8080REST API
ws://localhost:8080/v1/wsWebSocket event stream
http://localhost:8080/metricsPrometheus metrics

Check the metrics endpoint to verify the Gateway is running:

curl http://localhost:8080/metrics

Note: The Tektii Engine also uses port 8080 for its REST API. If you need to run both the Engine and Gateway on the same machine, use Docker port mapping (e.g., -p 9080:8080) to expose the Gateway on a different host port.

Next Steps

  • Setup — Feature-gated builds, verification, monitoring, and troubleshooting
  • Going Live — Connect your backtested strategy to the Gateway for paper and live trading
  • Connection Guide — Detailed WebSocket and REST connection patterns