Skip to main content

Drop-in FastAPI + SDK bridge for ib_async and ib_insync-style Interactive Brokers workflows

Project description

QX-IB Bridge Server

QuantX-IB Bridge Server

Python 3.10+ FastAPI WebSocket + HTTP License

One IB connection. Every script shares it. Zero clientId collisions.


QX-IB Bridge Server is a thin multiplexer for traders already using ib_async, ib_insync, or direct IB Gateway/TWS scripts who have hit the same scaling wall: too many strategies, too many direct broker connections, and too many clientId conflicts. It is a FastAPI + SDK wrapper around ib_async, not a reimplementation of the IB stack, so the wire protocol, order state machines, and ticker logic still come from the real ib_async.IB.

Instead of opening many separate broker API sessions, the bridge keeps one managed IB connection alive and lets the rest of your scripts share it through a local HTTP/WebSocket layer. In practice, that means one real IB connection, many strategies, and a near-drop-in migration path.

This is not a replacement for the Interactive Brokers Python ecosystem. It is an operational upgrade for people already in it.

Why it exists

Without a bridge With QuantX-IB Bridge
Every script connects directly to IB Gateway/TWS One bridge process owns the real IB connection
Every script consumes an API client slot Many scripts share a single connection
clientId collisions and contention No collisions — bridge manages the single client
Scaling means connection juggling and manual clientId discipline Scaling stays inside one shared bridge

Architecture at a glance

┌─────────────┐   ┌─────────────┐   ┌─────────────┐
│  Strategy 1 │   │  Strategy 2 │   │  Strategy N │
│  (SDK)      │   │  (SDK)      │   │  (SDK)      │
└──────┬──────┘   └──────┬──────┘   └──────┬──────┘
       │ HTTP/WS         │ HTTP/WS         │ HTTP/WS
       └─────────────────┼─────────────────┘
                         ▼
              ┌─────────────────────┐
              │  QX-IB Bridge       │
              │  FastAPI Server     │
              │  (single process)   │
              └──────────┬──────────┘
                         │ ib_async.IB
                         ▼
              ┌─────────────────────┐
              │  IB Gateway / TWS   │
              │  (1 connection)     │
              └─────────────────────┘

What ib_async does (you don't touch): wire protocol, serialization, order state machines, ticker price aggregation, event loop management.

What the bridge does: keeps one managed IB session open, exposes it over a local FastAPI + WebSocket server, and gives existing IB Python code a much cleaner way to scale.

What you keep

  • Familiar IB() / connect() / disconnect() usage
  • Familiar request patterns like reqHistoricalData(), placeOrder(), positions()
  • Your existing Python scripts and strategy layout

What changes

  • One import line: from qx_ibbridge import *
  • Your scripts point at the local bridge instead of the raw broker socket

Quick start

Install the package:

pip install qx_ibbridge

Start the IB Gateway:

  1. Download the latest IB Gateway from Interactive Brokers
  2. Install and launch IB Gateway
  3. Log in with your Interactive Brokers credentials
  4. Ensure it listens on localhost:4004 (default)

Start the bridge:

qx-server --ib-host localhost --ib-port 4004 --host 127.0.0.1 --port 4002

Default local model:

  • external IB Gateway/TWS API socket: localhost:4004
  • local QuantX bridge server: localhost:4002

Drop-in SDK workflow

The same pip install qx_ibbridge package gives you both:

  • the qx-server CLI for running the bridge server
  • the qx_ibbridge import for drop-in strategy scripts

Then change your script from:

from ib_async import *
# or
from ib_insync import *

to:

from qx_ibbridge import *

and keep the same shape:

ib = IB()
ib.connect(host="localhost", port=4002)
print(ib.managedAccounts())

The SDK defaults to the local bridge at localhost:4002.

For ib_async users, this is the intended drop-in path. For ib_insync users, the workflow is the same in spirit: keep your IB-style code, but route it through one local bridge instead of many direct broker sessions.

Use it your way

1. Python

qx-server --ib-host localhost --ib-port 4004 --host 127.0.0.1 --port 4002

2. Desktop app

QuantX IB Bridge Server Desktop App

Download the latest desktop app from GitHub Releases.

If you prefer to launch the desktop UI from Python instead of downloading the packaged app:

pip install "qx_ibbridge[desktop]"
qx-ib-bridge-server-desktop

The desktop app is optional. It is only a launcher for the same bridge server, for users who prefer clicking a UI over running qx-server. It does not bundle IB Gateway, and it does not change the underlying bridge or SDK behavior. The core product already works through pip install qx_ibbridge; the desktop app is only an add-on for server-launch convenience.

Examples

Project layout

Directory Purpose
server/ Canonical FastAPI implementation
ib_bridge_server/ Generic Python server package and CLI
qx_ibbridge/ Drop-in SDK package
qx_ib_bridge_server/ Desktop launcher

Behind this repo

QuantX Alpha Technologies

QX-IB Bridge Server is open-sourced by Alpha Technologies.

Across the broader ecosystem, the team builds investor education, quant research, and operating workflows around systematic, data-driven trading.

Acknowledgements

This project stands on the work of two open-source efforts:

  • ib_async — the actively maintained IB API library that this bridge wraps. The bridge server delegates all wire-protocol, order state machine, and ticker logic to ib_async.IB, and the SDK re-exports its contract and order types so existing scripts keep working without change.

  • ib_insync by Ewald de Wit — the original Python IB API library whose elegant synchronous-style API design this SDK is compatible with. ib_async is itself a maintained fork of ib_insync.

Disclaimer

This software is provided "as is" without warranty of any kind. It is not financial advice, a solicitation to trade, or a guarantee of profitability. You are solely responsible for any trades placed using this software. The authors and contributors are not liable for any financial losses incurred.

Notes

  • Not affiliated with Interactive Brokers
  • IB Gateway/TWS remains external and user-managed
  • This bridge solves clientId contention but does not remove IB pacing, market data, or broker-side account limits
  • Released under the Apache License 2.0; see LICENSE
  • Never commit IB credentials to this repository

See also:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qx_ibbridge-1.0.0.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qx_ibbridge-1.0.0-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

Details for the file qx_ibbridge-1.0.0.tar.gz.

File metadata

  • Download URL: qx_ibbridge-1.0.0.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qx_ibbridge-1.0.0.tar.gz
Algorithm Hash digest
SHA256 16d2aea7c19dca8d08d6f351a9c2b24b71116566a429782f583f1d02de677030
MD5 419ef29e84f1142b0fc8622efe506d16
BLAKE2b-256 471606c9f0ab72075ae1fbdedac0088ef682f5ae88e6ec2b6bf1f4f1736bcadb

See more details on using hashes here.

Provenance

The following attestation bundles were made for qx_ibbridge-1.0.0.tar.gz:

Publisher: release.yml on KVignesh122/qx-ib-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qx_ibbridge-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qx_ibbridge-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qx_ibbridge-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc24e0c03cc01ed830fbfbe758460d9d7d1c7b9bb7df8f46b9095ba648127caa
MD5 8578ac2a4dafa8ebfae41b112e95e7fe
BLAKE2b-256 c6cc148015d8f8c7d74c1fc84bc7bb3226c50764584a2e00d2c596af15b7ca06

See more details on using hashes here.

Provenance

The following attestation bundles were made for qx_ibbridge-1.0.0-py3-none-any.whl:

Publisher: release.yml on KVignesh122/qx-ib-bridge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page