Drop-in FastAPI + SDK bridge for ib_async and ib_insync-style Interactive Brokers workflows
Project description
QuantX-IB Bridge Server
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:
- Download the latest IB Gateway from Interactive Brokers
- Install and launch IB Gateway
- Log in with your Interactive Brokers credentials
- 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-serverCLI for running the bridge server - the
qx_ibbridgeimport 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
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
- sample.py: direct
ib_asyncexample against raw IB Gateway/TWS - sample_copy.py: bridge example using
qx_ibbridge
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
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.
- superinvestor.io and alpha-techlab.com — QuantX hands-on learning, guided challenges, live market sessions, and practical quant-investing courses
- fund.alpha-techlab.com — Regulated fund management and investors entry point
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_asyncis itself a maintained fork ofib_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
clientIdcontention 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16d2aea7c19dca8d08d6f351a9c2b24b71116566a429782f583f1d02de677030
|
|
| MD5 |
419ef29e84f1142b0fc8622efe506d16
|
|
| BLAKE2b-256 |
471606c9f0ab72075ae1fbdedac0088ef682f5ae88e6ec2b6bf1f4f1736bcadb
|
Provenance
The following attestation bundles were made for qx_ibbridge-1.0.0.tar.gz:
Publisher:
release.yml on KVignesh122/qx-ib-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qx_ibbridge-1.0.0.tar.gz -
Subject digest:
16d2aea7c19dca8d08d6f351a9c2b24b71116566a429782f583f1d02de677030 - Sigstore transparency entry: 1623077555
- Sigstore integration time:
-
Permalink:
KVignesh122/qx-ib-bridge@84883243137268c9108ba777d87c394bad191ff6 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/KVignesh122
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@84883243137268c9108ba777d87c394bad191ff6 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc24e0c03cc01ed830fbfbe758460d9d7d1c7b9bb7df8f46b9095ba648127caa
|
|
| MD5 |
8578ac2a4dafa8ebfae41b112e95e7fe
|
|
| BLAKE2b-256 |
c6cc148015d8f8c7d74c1fc84bc7bb3226c50764584a2e00d2c596af15b7ca06
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qx_ibbridge-1.0.0-py3-none-any.whl -
Subject digest:
fc24e0c03cc01ed830fbfbe758460d9d7d1c7b9bb7df8f46b9095ba648127caa - Sigstore transparency entry: 1623077650
- Sigstore integration time:
-
Permalink:
KVignesh122/qx-ib-bridge@84883243137268c9108ba777d87c394bad191ff6 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/KVignesh122
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@84883243137268c9108ba777d87c394bad191ff6 -
Trigger Event:
push
-
Statement type: