How IbkrClient and IbkrWsClient work together
masterIBind provides two primary client classes for interacting with the Interactive Brokers Client Portal Web API 1.0. Their usage patterns differ significantly:
IbkrClient (REST API)
Used for synchronous-style request/response interactions. You construct the client with appropriate arguments and call API methods directly. It includes features like automated question/answer handling, parallel requests, and rate limiting.
IbkrWsClient (WebSocket API)
Used for real-time data streaming. It is asynchronous and runs on a separate thread. Using it requires managing three distinct areas:
- Lifecycle: You must construct it, start it, and manage its lifecycle on the originating thread.
- Subscriptions: It is subscription-based; you must specify channels to subscribe to and remember to unsubscribe later.
- Data Consumption: It uses a queue system where you access and consume data from specific channel queues.
Users are encouraged to start with IbkrClient before moving to the more complex IbkrWsClient.
from ibind import IbkrClient, IbkrWsClient