Skip to content

IBind Configuration

voyz edited this page Apr 25, 2024 · 8 revisions

IBind can be configured through two manners:

Constructor Parameters

IbkrClient and IbkrWsClient have three common settings that can be configured through their constructor parameters:

  • Account ID
  • URL
  • CAcerts

Account ID configuration

Many of the IBKR API endpoints require an account ID to be specified.

In most cases this value will be the constant for a particular user, hence both the IbkrClient and IbkrWsClient allow to store the account ID by specifying the account_id parameter upon construction.

IbkrClient(account_id='DU12345678')

Note:

  • This value can be set as an environment variable IBIND_ACCOUNT_ID, which will be read automatically upon construction.
  • All API methods that require the account ID to be specified provide an optional account_id parameter allowing you to override this class field on case-by-case basis.

URL configuration

The client classes require a URL to the Client Portal Gateway. There are two ways of specifying it:

1. Provide the full URL through the url parameter, eg.:

IbkrClient(url='https://mydomain:6060/v1/api/')
IbkrWsClient(url='wss://mydomain:6060/v1/api/ws')

Note:

  • This value can be set as an environment variable IBIND_REST_URL, which will be read automatically upon construction.

2. Provide the host, port and/or base_route parameters.

These then get combined as follows:

  • https://{host}:{port}{base_route} for IbkrClient
  • wss://{host}:{port}{base_route} for IbkrWsClient

Eg.:

IbkrClient(port=6060)

The default values are:

host = 'localhost'
port = '5000'
base_route = '/v1/api/' # for IbkrClient
base_route = '/v1/api/ws' # for IbkrWsClient

Note:

  • The host, port and base_route parameters are ignored if the url parameter is provided.

CAcert configuration

The Client Portal Gateway can be set up to use custom CAcerts. To communicate with it, the API client will need to use the same certificates.

The cacert parameter allows you to specify a path to the cacert.pem certificate, eg.:

IbkrClient(cacert='/some/path/to/my/cacert.pem')

Note:

  • This value can be set as an environment variable IBIND_CACERT, which will be read automatically upon construction.
  • You can set this value to False which will avoid using certificates and verified HTTPS.

Environment variables