Skip to content

Client

ibc.client.InteractiveBrokersClient

Python client for the Interactive Brokers API.

account_number property

The User's Interactive Brokers Account Number.

Returns

str: The account number.

Usage

>>> ibc_client = InteractiveBrokersClient(
    account_number=account_number,
)
>>> ibc_client.account_number

client_portal property

Initializes the ClientPortalGateway object.

Returns

ClientPortalGateway: The Interactive Brokers Client Portal Gateway, which is used to download the required files needed to access the API.

Usage

>>> ibc_client = InteractiveBrokersClient(
    account_number=account_number,
)
>>> ibc_client.authentication.login()
>>> ibc_client_portal = ibc_client.client_portal

session property

Initializes the InteractiveBrokersSession object.

Returns

InteractiveBrokersSession: Handles all the requests made during your session with the Interactive Brokers API.

Usage

>>> ibc_client = InteractiveBrokersClient(
    account_number=account_number,
)
>>> ibc_client.authentication.login()
>>> ibc_session = ibc_client.session

authentication property

Initializes the InteractiveBrokersAuthentication object.

Returns

InteractiveBrokersAuthentication: Handles authenticating the User so that they can make requests to the Interactive Brokers API.

Usage

>>> ibc_client = InteractiveBrokersClient(
    account_number=account_number,
)
>>> ibc_client.authentication.login()
>>> authentication_service = ibc_client.authentication

customers cached property

The :class:Customer service for customer information.

portfolio_analysis cached property

The :class:PortfolioAnalysis service for portfolio analytics.

accounts cached property

The :class:Accounts service for managing IB accounts.

market_data cached property

The :class:MarketData service for quotes and historical prices.

pnl cached property

The :class:PnL service for account PnL information.

alerts cached property

The :class:Alerts service for managing alerts.

contracts cached property

The :class:Contracts service for contract information.

scanners cached property

The :class:Scanners service for market scanners.

trades cached property

The :class:Trades service for querying active trades.

portfolio_accounts cached property

The :class:PortfolioAccounts service for portfolio data.

orders cached property

The :class:Orders service for order management.

data_services cached property

The :class:Data service for instrument data.

fyi cached property

The :class:FYI service for notifications and disclaimers.

__init__(account_number, verify_ssl=False)

Initializes the InteractiveBrokersClient object.

Parameters

account_number (str): The User's account number they wish to use during the session. Can be either their paper trading account or their regular account.

bool | str (optional, Default=False)

Whether to verify SSL certificates. Pass True to verify using the default CA bundle, or a string path to a custom CA certificate file or directory. Defaults to False because the IB Client Portal Gateway uses a self-signed certificate on localhost.

Usage

>>> ibc_client = InteractiveBrokersClient(
    account_number=account_number,
)