This release is a pre-release and may not be stable for production use.
IBind is an unofficial Python API client library for the Interactive Brokers Client Portal Web API. (also known as Web API 1.0 or CPAPI 1.0) It supports both REST and WebSocket APIs of the IBKR Web API 1.0. Now fully headless with OAuth 1.0a support.
Installation
pip install ibind
Authentication
IBind supports fully headless authentication using OAuth 1.0a. This means no longer needing to run any type software to communicate with IBKR API.
Alternatively, use IBeam along with this library for easier setup and maintenance of the CP Gateway.
See Authentication page to learn more.
Documentation
See full IBind documentation.
- Installation
- Authentication
- OAuth 1.0a
- IBind Configuration
- IbkrClient - REST Python client for IBKR REST API.
- IbkrWsClient - WebSocket Python client for IBKR WebSocket API.
- API Reference
Features:
- REST:
- WebSocket:
Overview
IBind's core functionality consists of two client classes:
-
IbkrClient- for IBKR REST APIUsing the
IbkrClientrequires constructing it with appropriate arguments, then calling the API methods. -
IbkrWsClient- for IBKR WebSocket APIUsing the
IbkrWsClientinvolves handling three areas:- Managing its lifecycle. It is asynchronous and runs on separate internal threads, hence we need to construct it, start it, and manage it from the originating thread.
- Subscribing and unsubscribing. It uses a typed subscription interface with idempotent semantics, allowing flexible subscription management.
- Consuming data. It uses a sink-based pattern supporting callbacks, queues, or custom implementations for flexible event consumption.
Their usage differs substantially. Users are encouraged to familiarise themselves with the IbkrClient class first.
Examples
See all examples.
Basic REST Example
from ibind import IbkrClient
# Construct the client
client = IbkrClient()
# Call some endpoints
print('\n#### check_health ####')
print(client.check_health())
print('\n\n#### tickle ####')
print(client.tickle().data)
print('\n\n#### get_accounts ####')
print(client.portfolio_accounts().data)
Basic WebSocket Example
from ibind import QueueSink, IbkrWsClient, events
from ibind.subscriptions import PnlSubscription
# Create a queue-based event sink
sink = QueueSink()
# Construct and start the client
ws_client = IbkrWsClient(account_id='[YOUR_ACCOUNT_ID]', sink=sink)
ws_client.start()
# Subscribe to PnL updates
ws_client.subscribe(PnlSubscription())
# Consume PnL events
while True:
while not sink.empty(events.Pnl):
event = sink.get(events.Pnl)
print(event)
ws_client.shutdown()
Licence
See LICENSE
Disclaimer
IBind is not built, maintained, or endorsed by the Interactive Brokers.
Use at own discretion. IBind and its authors give no guarantee of uninterrupted run of and access to the Interactive Brokers Client Portal Web API. You should prepare for breaks in connectivity to IBKR servers and should not depend on continuous uninterrupted connection and functionality. To partially reduce the potential risk use Paper Account credentials.
IBind is provided on an AS IS and AS AVAILABLE basis without any representation or endorsement made and without warranty of any kind whether express or implied, including but not limited to the implied warranties of satisfactory quality, fitness for a particular purpose, non-infringement, compatibility, security and accuracy. To the extent permitted by law, IBind's authors will not be liable for any indirect or consequential loss or damage whatever (including without limitation loss of business, opportunity, data, profits) arising out of or in connection with the use of IBind. IBind's authors make no warranty that the functionality of IBind will be uninterrupted or error free, that defects will be corrected or that IBind or the server that makes it available are free of viruses or anything else which may be harmful or destructive.
Acknowledgement
IBind has been enriched by incorporating work developed in collaboration with Kinetic and Grant Stenger, which now forms part of the initial open-source release. I appreciate their significant contribution to this community-driven initiative. Cheers Kinetic! 🍻
Built by Voy
Hi! Thanks for checking out and using this library.
If you are in need of some help with your project and would like to hire me, or just wanna chat about trading - I'm happy to talk.
You can contact me through: https://voyzan.com
Or if you'd just want to give something back, I've got a Buy Me A Coffee account:
Thanks and have an awesome day 👋
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ibind-0.2.1rc20.tar.gz.
File metadata
- Download URL: ibind-0.2.1rc20.tar.gz
- Upload date:
- Size: 152.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd3c75362e73fd4f6d3ccb55af7e8c7f6eafe261710a0b0472ec08da9827aa7
|
|
| MD5 |
15e9e409f8bd91279201f4daae92455e
|
|
| BLAKE2b-256 |
03a1118034539487f55051e99623fa376afa74ad31e46de9de3e1c4476aa7088
|