EasyIB: Python Wrapper for Interactive Brokers API
“Logo for ‘EasyIB’” according to Midjourney
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 |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|