Implementation of the native python version of IB API
Project description
IbPy Native - Interactive Brokers Native Python API
Installation
Install from PyPI
pip install ibpy-native
Alternatively, install from source. Execute setup.py from the root directory.
python setup.py install
Usage
import ibpy_native
import pytz
# Set the timezone to match the timezone specified in TWS or IB Gateway when login
# Default timezone - 'America/New_York'
ibpy_native.IBBridge.set_timezone(pytz.timezone('America/New_York'))
# Connect to a running TWS or IB Gateway instance
bridge = ibpy_native.IBBridge(host='127.0.0.1', port=4001, client_id=1, auto_conn=True)
An optional parameter timeout is available for all APIs implemented in
IBBridge. The timeout value is treated as X seconds, and the default timeout
time has been set to 10 seconds.
# Search the US stock contract of Apple Inc.
aapl = bridge.get_us_stock_contract(symbol='AAPL')
# Ask for the earliest available data point of AAPL
head_time = bridge.get_earliest_data_point(contract=aapl, data_type='TRADES')
# Get all historical ticks of AAPL
#
# It's better to set the timeout value a bit long (e.g. 30~100s) as this API
# loops to request around 1000 historical ticks for each IB API request due to
# IB's limitation. IB will slow down the response time after the first 10~20
# requests, thus the default 10s timeout is likely to be insufficient to wait
# for the following API responses from IB.
ticks = bridge.get_historical_ticks(contract=aapl, data_type='TRADES', timeout=100)
System requirements
- Python >= 3.5; Pervious versions are not supported (development is based on Python 3.7.7)
- Included IB API version -
9.79.01
Known issues
- Function
IBBridge.get_historical_ticksmay raise an error with error code200-No security definition has been found for the requestif the connection between IB and the TWS/IB Gateway instance has been dropped unexpectedly while requesting the data. It doesn't matter if the connection is restored shortly after the disconnection.
Development status (a.k.a. Words from developers)
Although the project is under the stage of active development, up until now (ver. 0.1.1) it focuses on retrieving historical ticks for stock & future contracts from IB. Other security types (e.g. options) may work but those are not yet tested.
Other features like retrieving account details, place & modify orders are planned to be implemented in the future, but there is no estimated timeline for those atm, as the project is being developed alongside Devtography internal algo-trading program. For now, the features will be developed and released when needed.
Contributions
Contributions via pull requests are welcome and encouraged. If there's any feature you think is missing, please don't hesitate to implement yourself and make a pull request :)
License
Modules included in ibpy_native, except ibapi is licensed under the
Apache License, Version 2.0.
The ibapi is 100% developed & owned by Interactive Brokers LLC ("IB"). By
using this package (ibpy-native), you are assumed that you agreed the
TWS API Non-Commercial License.
Remarks
ibpy_native is not a product of Interactive Brokers, nor is this project
affiliated with IB. If you'd like to use ibpy_native in any commercial
application/product, you must contact Interactive Brokers LLC for permission
of using IB API commercially.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ibpy-native-0.1.1.tar.gz.
File metadata
- Download URL: ibpy-native-0.1.1.tar.gz
- Upload date:
- Size: 67.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f2a319224ea3eedc2640164915eb2327f4b6c649e9cdcf4bf0d2f5da37428bb
|
|
| MD5 |
44d233bb1fa17aa7d93d59af24619e93
|
|
| BLAKE2b-256 |
32f29cd5d13f914b29923bbb16d6fb297cd389e9a0163e90594510d852d2a46c
|
File details
Details for the file ibpy_native-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ibpy_native-0.1.1-py3-none-any.whl
- Upload date:
- Size: 79.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a36e367eace3bee97a3ef1cf00b752a91cb745125c084dd9465cd90a3e10e64
|
|
| MD5 |
00b8a19ed93eed0d1dfb82b5dea35e72
|
|
| BLAKE2b-256 |
44de278876072e20f20b214f69ffbc7b296ca0639584d088d0b0c3e0b4ba0110
|