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
System requirements
- Python >= 3.5; Pervious versions are not supported (development is based on Python 3.7.7)
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)
A optional parameter timeout
is available for all APIs implemented in
IBBridge
. The timeout value is treated as X seconds, and the default timeout
time is set as 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)
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.
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
Hashes for ibpy_native-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a828a1f767a90716d2886a8b20e22b067e0f5934d76bc87fd0cec6388a3e39a1 |
|
MD5 | eada830b9a38536166bc8a843610a1c4 |
|
BLAKE2b-256 | 282f588fc4464f522f1ec6be853c37e72209e42586bbdda1bf98818ddcf723e8 |