Skip to main content

EasyIB: Python Wrapper for Interactive Brokers API

https://img.shields.io/pypi/v/easyib https://img.shields.io/pypi/pyversions/easyib https://img.shields.io/pypi/l/easyib Documentation Status

https://raw.githubusercontent.com/ashpipe/EasyIB/main/docs/logo.png

“Logo for ‘EasyIB’” according to Midjourney


EasyIB is an unofficial python wrapper for Interactive Brokers Client Portal Web API. The motivation for the project was to build a Python wrapper that can run on Linux/cloud environments. Thus, Client Portal API was preferred over Trader Workstation (TWS) API.

Please see https://easyib.readthedocs.io for the full documentation.

Features

Notable functionality includes:

  • Pull account info, portfolio, cash balance, the net value

  • Pull historical market data

  • Submit, modify, cancel orders

  • Get order status, list of live orders

  • Ping (tickle) server, get authentication status, re-authenticate

How to install

EasyIB assumes a gateway session is active and authenticated. Follow instructions at https://interactivebrokers.github.io/cpwebapi/ for authentication. A custom package such as Voyz/IBeam can also be used for setting up an active session. Part Time Larry has an excellent youtube tutorial on this topic: https://www.youtube.com/watch?v=O1OhiiCx6Ho.

EasyIB was developed under the Voyz/Ibeam docker image environment.

Once a gateway session is running, pip command can be used to install EasyIB:

pip install easyib

Quick start

Historical data

import easyib

ib = easyib.REST() # default parameters: url="https://localhost:5000", ssl=False

bars = ib.get_bars("AAPL", period="1w", bar="1d")
print(bars)

Submitting an order

list_of_orders = [
    {
        "conid": ib.get_conid("AAPL"),
        "orderType": "MKT",
        "side": "BUY",
        "quantity": 7,
        "tif": "GTC",
    }
]

order = ib.submit_orders(list_of_orders)
print(order)

Reference

For the complete reference, please visit https://easyib.readthedocs.io/en/latest/reference.html.

REST

By default, EasyIB assumes the gateway session is open at https://localhost:5000 without an SSL certificate. A custom URL and SSL certificate can be set by:

ib = easyib.REST(url="https://localhost:5000", ssl=False)

API REST Methods

Documentation of available functions is at https://easyib.readthedocs.io/en/latest/reference.html.

See the official documentation of the End Point at https://www.interactivebrokers.com/api/doc.html.

REST Method

End Point

Result

get_accounts()

Get portfolio/accounts

list

switch_account(accountId: str)

Post iserver/account/{accountId}

dict

get_cash()

Get portfolio/{accountId}/ledger

float

get_netvalue()

Get portfolio/{accountId}/ledger

float

get_conid(symbol: str, instrument_filters: Dict = None, contract_filters: Dict = {"isUS": True})

Get trsv/stocks

int

get_fut_conids(symbol: str)

Get trsv/futures

list

get_portfolio()

Get portfolio/{accountId}/positions/0

dict

reply_yes(id: str)

Post iserver/reply/{id}

dict

submit_orders(list_of_orders: list, reply_yes=True)

Post iserver/account/{acountId}/orders

dict

get_order(orderId: str)

Get iserver/account/order/satus/

dict

get_live_orders(filters=None)

Get iserver/account/orders

dict

cancel_order(orderId: str)

Delete iserver/account/{accountId}/order/{orderId}

dict

modify_order(orderId=None, order=None, reply_yes=True)

Post iserver/account/{accountId}/order/{orderId}

dict

get_bars(symbol: str, period="1w", bar="1d", outsideRth=False, conid="default")

Get iserver/marketdata/history

dict

ping_server()

Post tickle

dict

get_auth_status()

Post iserver/auth/status

dict

re_authenticate()

Post iserver/reauthenticate

None

log_out()

Post logout

None

Metadata

Release files for easyib 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easyib 0.2.5
File Size Uploaded Provenance Actions
easyib-0.2.5.tar.gz 8.4 kB Without provenance Details for easyib-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easyib 0.2.5
File Interpreter ABI Platform Actions
easyib-0.2.5-py3-none-any.whl Python 3 none any Details for easyib-0.2.5-py3-none-any.whl

Total release size: 15.8 kB

Release files / easyib-0.2.5.tar.gz

Download URL easyib-0.2.5.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2e0e831d0f556af8044d6a46c33a7bdcb869692201ae939d070922e534796fa4
BLAKE2b-256 checksum
How to use checksums
385bc551c9eac637c393d86df0bf642e99f744bf6e844debe48826cb1195a84b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / easyib-0.2.5-py3-none-any.whl

Download URL easyib-0.2.5-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d24101ecef4acf8fb1c48cc19c17103450bace1eb96a6721b968af8c34e5ed0c
BLAKE2b-256 checksum
How to use checksums
5e1fb5a6a1e45d0494036c25a34fb2a782e41796812959a1b3c73313f39e3105
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Security for easyib 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page