Broker Integrations

KlawTrade supports 6 brokers out of the box. Each broker is an optional dependency -- install only what you need. If no API keys are configured, KlawTrade falls back to its built-in simulation broker automatically.

# Install with all brokers
pip install klawtrade[all-brokers]

# Or install a specific broker
pip install klawtrade[ibkr]
pip install klawtrade[coinbase]
pip install klawtrade[binance]
pip install klawtrade[kraken]
pip install klawtrade[tradier]
BrokerMarketsPaper/SandboxConfig Value
AlpacaUS EquitiesYesalpaca
Interactive BrokersStocks, Options, Futures, ForexYesibkr
CoinbaseCryptocurrencyYescoinbase
BinanceCryptocurrencyYesbinance
KrakenCryptocurrencyYeskraken
TradierUS Equities, OptionsYestradier

Alpaca

US Equities

Commission-free US stock trading with a free paper trading environment. Recommended for getting started.

Sign up at alpaca.markets.

Install

pip install klawtrade

Configuration (settings.yaml)

broker:
  provider: alpaca
  paper: true

Environment Variables (.env)

ALPACA_API_KEY=PKxxxxxxxxxxxxxxxx
ALPACA_SECRET_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Paper trading is free and does not require identity verification. Generate keys from the Paper Trading section of your Alpaca dashboard.

Interactive Brokers

Stocks, Options, Futures, Forex

Professional-grade broker with access to 150+ markets worldwide. Requires TWS or IB Gateway running locally.

Sign up at interactivebrokers.com.

Install

pip install klawtrade[ibkr]

Configuration (settings.yaml)

broker:
  provider: ibkr
  paper: true

Environment Variables (.env)

IBKR_HOST=127.0.0.1
IBKR_PORT=7497
IBKR_CLIENT_ID=1

You must have TWS or IB Gateway running. Paper trading uses port 7497, live uses 7496. Enable API connections in TWS settings under Configuration > API > Settings.

Coinbase

Cryptocurrency

Trade crypto via Coinbase Advanced Trade API. Supports BTC, ETH, and hundreds of other pairs.

Sign up at coinbase.com.

Install

pip install klawtrade[coinbase]

Configuration (settings.yaml)

broker:
  provider: coinbase
  paper: true

Environment Variables (.env)

COINBASE_API_KEY=organizations/xxxxx/apiKeys/xxxxx
COINBASE_API_SECRET=-----BEGIN EC PRIVATE KEY-----\n...

Generate API keys from Coinbase Developer Platform. Set COINBASE_SANDBOX=true (default) for sandbox testing. Symbols are mapped automatically (e.g., BTC becomes BTC-USD).

Binance

Cryptocurrency

The world's largest crypto exchange by volume. Supports spot trading for hundreds of pairs.

Sign up at binance.com.

Install

pip install klawtrade[binance]

Configuration (settings.yaml)

broker:
  provider: binance
  paper: true

Environment Variables (.env)

BINANCE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BINANCE_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Set BINANCE_TESTNET=true (default) for testnet. Symbols are mapped automatically (e.g., BTC becomes BTCUSDT). Not available in the US; use Coinbase instead.

Kraken

Cryptocurrency

Established crypto exchange with strong security track record. Supports major crypto pairs.

Sign up at kraken.com.

Install

pip install klawtrade[kraken]

Configuration (settings.yaml)

broker:
  provider: kraken
  paper: true

Environment Variables (.env)

KRAKEN_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
KRAKEN_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Generate API keys from Settings > API in your Kraken account. Enable 'Create & modify orders' and 'Query open orders & trades' permissions.

Tradier

US Equities, Options

Commission-free stock and options trading with a developer-friendly REST API and free sandbox.

Sign up at tradier.com.

Install

pip install klawtrade[tradier]

Configuration (settings.yaml)

broker:
  provider: tradier
  paper: true

Environment Variables (.env)

TRADIER_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TRADIER_ACCOUNT_ID=xxxxxxxx

Set TRADIER_SANDBOX=true (default) for sandbox mode. Get sandbox credentials from developer.tradier.com.

Automatic Fallback

If your chosen broker's API keys are not configured or its optional dependency is not installed, KlawTrade automatically falls back to its built-in SimBroker. SimBroker executes trades in memory with simulated slippage, so you can develop and test strategies without any external accounts.