-
Notifications
You must be signed in to change notification settings - Fork 23
Ibkr Client
The IbkrClient
class provides an interface to the IBKR REST API.
It shares some basic configuration with the IbkrWsClient
. See IBind Configuration - Construction Parameters section for more.
Basic usage of IbkrClient
:
from ibind import IbkrClient
ibkr_client = IbkrClient()
ibkr_client.tickle()
See example "rest_01_basic" for a quick showcase of the basic REST setup.
The IbkrClient
class is a concrete implementation of the abstract RestClient
class.
The RestClient
provides a boilerplate support for common REST methods: GET
, POST
and DELETE
, and handles the request/response processing of all API methods declared in the IbkrClient
.
See API Reference - IbkrClient for more.
Almost all endpoints defined in the IBKR REST API are mapped to IbkrClient
methods. Currently, the endpoint sections that are still NOT mapped are:
- Alerts
- FA Allocation Management
- FYIs and Notifications
Note:
- IBKR endpoints are not documented in this documentation. Please refer to the official IBKR REST API reference for full documentation.
- Endpoints' API implementation is categorised into Python class mixins. See API Reference - IbkrClient for full list of mixins and their methods.
Almost all methods in the IbkrClient
return an instance of Result
object. It is a dataclass containing two fields:
-
data
- the data returned from the operation -
request
- details of the request that resulted in this data, usually containing the URL and arguments used in the REST request to IBKR
This interface gives you additional information as to how IbkrClient
communicated with the IBKR API. The request
field facilitates debugging and ensuring the client library operates according to our expectations.
What this implies, is that to access the returned data of the REST API calls, you need to use the .data
accessor:
authentication_data = IbkrClient.authentication_status().data
There are very few methods that do not return Result
. In all such cases it is explicitly stated in the documentation.
Majority of the IBKR endpoints' mapping is implemented by performing a simple REST request. For example:
class SessionMixin():
def authentication_status(self: 'IbkrClient') -> Result:
return self.post('iserver/auth/status')
...
In several cases, IbkrClient
implements additional logic to allow more sophisticated interaction with the IBKR endpoints. See Advanced REST page to learn about the advanced API concepts.
Learn about the Advanced REST concepts.
See any error on this page? Create an Issue and let us know.