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:
| Runtime | Purpose | Provider |
|---|---|---|
| Tektii Engine | Backtesting against historical data | Built-in simulation |
| Trading Gateway | Paper and live trading | Alpaca, Binance |
Write your strategy once. Backtest it on the Engine. Deploy it to the Gateway. No code changes required.
Supported Providers
| Provider | Paper Trading | Live Trading |
|---|---|---|
| Alpaca | alpaca-paper | alpaca-live |
| Binance | binance-testnet | binance-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
| Variable | Description |
|---|---|
ALPACA_API_KEY | Your Alpaca API key |
ALPACA_API_SECRET | Your Alpaca API secret |
ALPACA_PAPER | Set to true for paper trading |
Get your API keys from the Alpaca Dashboard.
Binance
| Variable | Description |
|---|---|
BINANCE_API_KEY | Your Binance API key |
BINANCE_API_SECRET | Your Binance API secret |
BINANCE_TESTNET | Set 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:
| Endpoint | Purpose |
|---|---|
http://localhost:8080 | REST API |
ws://localhost:8080/v1/ws | WebSocket event stream |
http://localhost:8080/metrics | Prometheus 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