Docs / Developer tools

The gateway

Run the open-source gateway on your own hardware so your exchange API keys never reach the platform — the self-custody alternative to Direct connection.

The gateway solves one problem: keeping your exchange API keys off the platform's servers. It is an open-source program you run on your own machine (a laptop, a home server, a VPS). Your keys live there and nowhere else — the platform sends it trade instructions, the gateway executes them locally against your exchange, and returns the result.

If you connect an exchange Directly, the platform stores your key (encrypted) and trades for you — simplest, and fine for most people. The gateway is for when key custody is a hard requirement.

How self-custody works#

The platform sends trade instructions over a WebSocket to your gateway, which holds your keys locally and executes on your exchange; the keys never cross to the platform riskmanaged.io strategy engine · no keys keys never cross → instructions Your gateway holds your keys executes locally trades Your exchange — on your machine —
The platform never sees your key. It sends trade instructions over an authenticated WebSocket; your gateway holds the key, executes the order on your exchange, and sends the fill back. Everything right of the dashed line runs on hardware you control.

Direct vs the gateway#

DirectGateway
SetupEnter API keys in the UI — doneInstall the gateway on your machine or VPS
Where the key livesEncrypted on the platform's serversOn your machine only
Self-custodyNo — the key is entrusted to the platformYes — the key never leaves your hardware
LatencyLower (server → exchange)Slightly higher (signal → gateway → exchange)
Open sourceYes — on GitHub
ExchangesAll supportedAll supported

Installing the remote gateway#

# 1. Install
curl -sSL https://riskmanaged.io/gateway/install.sh | bash

# 2. Authorize — opens this site in your browser, no token to copy
riskmanaged-gateway login

# 3. Add an exchange (your keys are verified before they are saved)
riskmanaged-gateway add-exchange

# 4. Start it
riskmanaged-gateway

Or install from source:

git clone https://github.com/riskmanaged/riskmanaged-gateway.git
cd riskmanaged-gateway
pip install -e .
riskmanaged-gateway bootstrap

Gateway commands#

CommandDescription
riskmanaged-gatewayStart the gateway
riskmanaged-gateway loginAuthorize via the browser and store an API token
riskmanaged-gateway bootstrapGuided first-time setup
riskmanaged-gateway add-exchangeAdd an exchange with API keys
riskmanaged-gateway list-exchangesShow configured exchanges
riskmanaged-gateway remove-exchange <label>Remove an exchange
riskmanaged-gateway test [label]Re-check your credentials against the exchange
riskmanaged-gateway statusShow local configuration

Headless and Docker#

Every setting can come from the environment, so the gateway can be provisioned without prompts. Containers have no browser, so use a token from your profile page instead of login.

export RISKMANAGED_API_KEY=your-token
riskmanaged-gateway bootstrap --yes
riskmanaged-gateway add-exchange --exchange binance --label binance-main \
  --api-key "$KEY" --api-secret "$SECRET"

# Or with Docker
echo "RISKMANAGED_API_KEY=your-token" > .env
docker compose up -d

Where your keys are stored#

Exchange secrets go into your operating system's keyring when one is available, falling back to 0600 files under ~/.riskmanaged/exchanges/ on headless servers and in containers. riskmanaged-gateway status shows which is in use. The gateway will only ever execute nine CCXT methods on your behalf — trading, balance and leverage. No withdrawal or transfer method is permitted, so the platform cannot move your funds.

Running as a service#

For 24/7 operation, install the gateway as a systemd service (offered during bootstrap):

# Enable and start
systemctl --user enable --now riskmanaged-gateway

# Check status
systemctl --user status riskmanaged-gateway

# View logs
journalctl --user -u riskmanaged-gateway -f
TIP

Multi-exchange support: A single gateway instance can manage multiple exchanges simultaneously. Each exchange is configured as a separate YAML file in ~/.riskmanaged/exchanges/.

Was this page helpful?