ib_async


Nameib_async JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/ib-api-reloaded/ib_async
SummaryPython sync/async framework for Interactive Brokers API
upload_time2024-03-20 23:33:21
maintainerMatt Stancliff
docs_urlNone
authorEwald de Wit
requires_python>=3.10
licenseBSD
keywords ibapi tws asyncio jupyter interactive brokers async ib_insync
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build](https://github.com/ib-api-reloaded/ib_async/actions/workflows/test.yml/badge.svg?branch=next)](https://github.com/ib-api-reloaded/ib_async/actions) [![PyVersion](https://img.shields.io/badge/python-3.10+-blue.svg)](#) <!-- [![Status](https://img.shields.io/badge/status-beta-green.svg)](#) --> [![PyPiVersion](https://img.shields.io/pypi/v/ib_async.svg)](https://pypi.python.org/pypi/ib_async) [![License](https://img.shields.io/badge/license-BSD-blue.svg)](#) <!-- [![Downloads](https://static.pepy.tech/badge/ib-insync)](https://pepy.tech/project/ib-insync) --> [![Docs](https://img.shields.io/badge/Documentation-green.svg)](https://ib-api-reloaded.github.io/ib_async/)

# ib_async

## Update

Under new management. See [original discussions](https://github.com/mattsta/ib_insync/discussions) for recent history. Create new discussions or PRs or issues under [the new primary repo](https://github.com/ib-api-reloaded/ib_async) for ongoing updates.

New contributions welcome. We are open to adding more maintainers with commit access if your updates and understanding of IBKR/TWS and Python are all high quality.

This is a small project with a userbase of widely varying experience and knowledge, so if you open issues which are more about IBKR problems and less about client problems, we may not be able to assist you unless your problem is a direct client issue and not one of many IBKR API edge cases. Feel free to open [Discussion topics](https://github.com/ib-api-reloaded/ib_async/discussions) about anything if you are unsure about a problem being IBKR, our client, or your own code usage.

## Introduction

The goal of the `ib_async` library is to make working with the
[Trader Workstation API](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/)
from Interactive Brokers as easy as possible.

The main features are:

* An easy to use linear style of programming;
* An [IB component](https://ib-api-reloaded.github.io/ib_async/api.html#module-ib_async.ib)
  that automatically keeps in sync with the TWS or IB Gateway application;
* A fully asynchonous framework based on
  [asyncio](https://docs.python.org/3/library/asyncio.html)
  and
  [eventkit](https://github.com/erdewit/eventkit)
  for advanced users;
* Interactive operation with live data in Jupyter notebooks.

Be sure to take a look at the
[notebooks](https://ib-api-reloaded.github.io/ib_async/notebooks.html),
the [recipes](https://ib-api-reloaded.github.io/ib_async/recipes.html)
and the [API docs](https://ib-api-reloaded.github.io/ib_async/api.html).


## Installation

```
pip install ib_async
```

Requirements:

- Python 3.10 or higher
  - We plan to support Python releases [2 years back](https://devguide.python.org/versions/) which allows us to continue adding newer features and performance improvements over time.
- A running IB Gateway application (or TWS with API mode enabled)
    - [stable gateway](https://www.interactivebrokers.com/en/trading/ibgateway-stable.php) — updated every few months
    - [latest gateway](https://www.interactivebrokers.com/en/trading/ibgateway-latest.php) — updated weekly
- Make sure the [API port is enabled](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/#tws-download) and 'Download open orders on connection' is checked.
- You may also want to increase the Java memory usage under `Configure->Settings->Memory Allocation` to 4096 MB minimum to prevent gateway crashes when loading bulk data.

The ibapi package from IB is not needed. `ib_async` implements the full IBKR API protocol internally.

## Build Manually

First, install poetry:

```
pip install poetry -U
```

### Installing Only Library

```
poetry install
```

### Install Everything (enable docs + dev testing)

```
poetry install --with=docs,dev
```

## Generate Docs

```
poetry install --with=docs
poetry run sphinx-build -b html docs html
```

## Check Types

```
poetry run mypy ib_async
```

## Build Package

```
poetry build
```

## Upload Package (if maintaining)

```
poetry install
poetry config pypi-token.pypi your-api-token
poetry publish --build
```

## Example

This is a complete script to download historical data:

```python
from ib_async import *
# util.startLoop()  # uncomment this line when in a notebook

ib = IB()
ib.connect('127.0.0.1', 7497, clientId=1)

contract = Forex('EURUSD')
bars = ib.reqHistoricalData(
    contract, endDateTime='', durationStr='30 D',
    barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True)

# convert to pandas dataframe (pandas needs to be installed):
df = util.df(bars)
print(df)
```

Output:

```
                   date      open      high       low     close  volume
0   2019-11-19 23:15:00  1.107875  1.108050  1.107725  1.107825      -1
1   2019-11-20 00:00:00  1.107825  1.107925  1.107675  1.107825      -1
2   2019-11-20 01:00:00  1.107825  1.107975  1.107675  1.107875      -1
3   2019-11-20 02:00:00  1.107875  1.107975  1.107025  1.107225      -1
4   2019-11-20 03:00:00  1.107225  1.107725  1.107025  1.107525      -1
..                  ...       ...       ...       ...       ...     ...
705 2020-01-02 14:00:00  1.119325  1.119675  1.119075  1.119225      -1
```

## Documentation

The complete [API documentation](https://ib-api-reloaded.github.io/ib_async/api.html).

[Changelog](https://ib-api-reloaded.github.io/ib_async/changelog.html).

## Disclaimer

The software is provided on the conditions of the simplified BSD license.

This project is not affiliated with Interactive Brokers Group, Inc.

[Official Interactive Brokers API Docs](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/)

## History

This library was originally created by [Ewald de Wit](https://github.com/erdewit) as [`tws_async` in early-2017](https://github.com/erdewit/tws_async) then became the more prominent [`ib_insync` library in mid-2017](https://github.com/erdewit/ib_insync). He maintained and improved the library for the world to use for free until his unexpected passing in early 2024. Afterward, we decided to rename the project to `ib_async` under a new github organization since we lost access to modify anything in the original repos and packaging and docs infrastructure.

The library is currently maintained by [Matt Stancliff](https://github.com/mattsta) and we are open to adding more committers and org contributors if people show interest in helping out.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ib-api-reloaded/ib_async",
    "name": "ib_async",
    "maintainer": "Matt Stancliff",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "matt@matt.sh",
    "keywords": "ibapi, tws, asyncio, jupyter, interactive, brokers, async, ib_insync",
    "author": "Ewald de Wit",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/21/27/1de3d64571e97b093489ca9f5147d8068622860f3d2e5ca894f4e2cef1fe/ib_async-1.0.1.tar.gz",
    "platform": null,
    "description": "[![Build](https://github.com/ib-api-reloaded/ib_async/actions/workflows/test.yml/badge.svg?branch=next)](https://github.com/ib-api-reloaded/ib_async/actions) [![PyVersion](https://img.shields.io/badge/python-3.10+-blue.svg)](#) <!-- [![Status](https://img.shields.io/badge/status-beta-green.svg)](#) --> [![PyPiVersion](https://img.shields.io/pypi/v/ib_async.svg)](https://pypi.python.org/pypi/ib_async) [![License](https://img.shields.io/badge/license-BSD-blue.svg)](#) <!-- [![Downloads](https://static.pepy.tech/badge/ib-insync)](https://pepy.tech/project/ib-insync) --> [![Docs](https://img.shields.io/badge/Documentation-green.svg)](https://ib-api-reloaded.github.io/ib_async/)\n\n# ib_async\n\n## Update\n\nUnder new management. See [original discussions](https://github.com/mattsta/ib_insync/discussions) for recent history. Create new discussions or PRs or issues under [the new primary repo](https://github.com/ib-api-reloaded/ib_async) for ongoing updates.\n\nNew contributions welcome. We are open to adding more maintainers with commit access if your updates and understanding of IBKR/TWS and Python are all high quality.\n\nThis is a small project with a userbase of widely varying experience and knowledge, so if you open issues which are more about IBKR problems and less about client problems, we may not be able to assist you unless your problem is a direct client issue and not one of many IBKR API edge cases. Feel free to open [Discussion topics](https://github.com/ib-api-reloaded/ib_async/discussions) about anything if you are unsure about a problem being IBKR, our client, or your own code usage.\n\n## Introduction\n\nThe goal of the `ib_async` library is to make working with the\n[Trader Workstation API](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/)\nfrom Interactive Brokers as easy as possible.\n\nThe main features are:\n\n* An easy to use linear style of programming;\n* An [IB component](https://ib-api-reloaded.github.io/ib_async/api.html#module-ib_async.ib)\n  that automatically keeps in sync with the TWS or IB Gateway application;\n* A fully asynchonous framework based on\n  [asyncio](https://docs.python.org/3/library/asyncio.html)\n  and\n  [eventkit](https://github.com/erdewit/eventkit)\n  for advanced users;\n* Interactive operation with live data in Jupyter notebooks.\n\nBe sure to take a look at the\n[notebooks](https://ib-api-reloaded.github.io/ib_async/notebooks.html),\nthe [recipes](https://ib-api-reloaded.github.io/ib_async/recipes.html)\nand the [API docs](https://ib-api-reloaded.github.io/ib_async/api.html).\n\n\n## Installation\n\n```\npip install ib_async\n```\n\nRequirements:\n\n- Python 3.10 or higher\n  - We plan to support Python releases [2 years back](https://devguide.python.org/versions/) which allows us to continue adding newer features and performance improvements over time.\n- A running IB Gateway application (or TWS with API mode enabled)\n    - [stable gateway](https://www.interactivebrokers.com/en/trading/ibgateway-stable.php) \u2014 updated every few months\n    - [latest gateway](https://www.interactivebrokers.com/en/trading/ibgateway-latest.php) \u2014\u00a0updated weekly\n- Make sure the [API port is enabled](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/#tws-download) and 'Download open orders on connection' is checked.\n- You may also want to increase the Java memory usage under `Configure->Settings->Memory Allocation` to 4096 MB minimum to prevent gateway crashes when loading bulk data.\n\nThe ibapi package from IB is not needed. `ib_async` implements the full IBKR API protocol internally.\n\n## Build Manually\n\nFirst, install poetry:\n\n```\npip install poetry -U\n```\n\n### Installing Only Library\n\n```\npoetry install\n```\n\n### Install Everything (enable docs + dev testing)\n\n```\npoetry install --with=docs,dev\n```\n\n## Generate Docs\n\n```\npoetry install --with=docs\npoetry run sphinx-build -b html docs html\n```\n\n## Check Types\n\n```\npoetry run mypy ib_async\n```\n\n## Build Package\n\n```\npoetry build\n```\n\n## Upload Package (if maintaining)\n\n```\npoetry install\npoetry config pypi-token.pypi your-api-token\npoetry publish --build\n```\n\n## Example\n\nThis is a complete script to download historical data:\n\n```python\nfrom ib_async import *\n# util.startLoop()  # uncomment this line when in a notebook\n\nib = IB()\nib.connect('127.0.0.1', 7497, clientId=1)\n\ncontract = Forex('EURUSD')\nbars = ib.reqHistoricalData(\n    contract, endDateTime='', durationStr='30 D',\n    barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True)\n\n# convert to pandas dataframe (pandas needs to be installed):\ndf = util.df(bars)\nprint(df)\n```\n\nOutput:\n\n```\n                   date      open      high       low     close  volume\n0   2019-11-19 23:15:00  1.107875  1.108050  1.107725  1.107825      -1\n1   2019-11-20 00:00:00  1.107825  1.107925  1.107675  1.107825      -1\n2   2019-11-20 01:00:00  1.107825  1.107975  1.107675  1.107875      -1\n3   2019-11-20 02:00:00  1.107875  1.107975  1.107025  1.107225      -1\n4   2019-11-20 03:00:00  1.107225  1.107725  1.107025  1.107525      -1\n..                  ...       ...       ...       ...       ...     ...\n705 2020-01-02 14:00:00  1.119325  1.119675  1.119075  1.119225      -1\n```\n\n## Documentation\n\nThe complete [API documentation](https://ib-api-reloaded.github.io/ib_async/api.html).\n\n[Changelog](https://ib-api-reloaded.github.io/ib_async/changelog.html).\n\n## Disclaimer\n\nThe software is provided on the conditions of the simplified BSD license.\n\nThis project is not affiliated with Interactive Brokers Group, Inc.\n\n[Official Interactive Brokers API Docs](https://ibkrcampus.com/ibkr-api-page/twsapi-doc/)\n\n## History\n\nThis library was originally created by [Ewald de Wit](https://github.com/erdewit) as [`tws_async` in early-2017](https://github.com/erdewit/tws_async) then became the more prominent [`ib_insync` library in mid-2017](https://github.com/erdewit/ib_insync). He maintained and improved the library for the world to use for free until his unexpected passing in early 2024. Afterward, we decided to rename the project to `ib_async` under a new github organization since we lost access to modify anything in the original repos and packaging and docs infrastructure.\n\nThe library is currently maintained by [Matt Stancliff](https://github.com/mattsta) and we are open to adding more committers and org contributors if people show interest in helping out.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Python sync/async framework for Interactive Brokers API",
    "version": "1.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/ib-api-reloaded/ib_async/issues",
        "Homepage": "https://github.com/ib-api-reloaded/ib_async",
        "Repository": "https://github.com/ib-api-reloaded/ib_async"
    },
    "split_keywords": [
        "ibapi",
        " tws",
        " asyncio",
        " jupyter",
        " interactive",
        " brokers",
        " async",
        " ib_insync"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1de47739bb6a9379c82ab6c81d717aecd3f2fc9e43adb1369185acc9dd2cb785",
                "md5": "6e36059d1cd5b662005a0143e0ac5a11",
                "sha256": "7a726c5d4684e04a4ce82718473ac1d478c551bca4c8470f88b852dbb68bf8bd"
            },
            "downloads": -1,
            "filename": "ib_async-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e36059d1cd5b662005a0143e0ac5a11",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 75542,
            "upload_time": "2024-03-20T23:33:19",
            "upload_time_iso_8601": "2024-03-20T23:33:19.813755Z",
            "url": "https://files.pythonhosted.org/packages/1d/e4/7739bb6a9379c82ab6c81d717aecd3f2fc9e43adb1369185acc9dd2cb785/ib_async-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21271de3d64571e97b093489ca9f5147d8068622860f3d2e5ca894f4e2cef1fe",
                "md5": "4c5d205cfdf633af4efa00e0c52af54c",
                "sha256": "eeabe36ca877c7c90b5ab488b78825b2e686a73abed7b23e60ef2f52e486f4ec"
            },
            "downloads": -1,
            "filename": "ib_async-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4c5d205cfdf633af4efa00e0c52af54c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 72748,
            "upload_time": "2024-03-20T23:33:21",
            "upload_time_iso_8601": "2024-03-20T23:33:21.648391Z",
            "url": "https://files.pythonhosted.org/packages/21/27/1de3d64571e97b093489ca9f5147d8068622860f3d2e5ca894f4e2cef1fe/ib_async-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-20 23:33:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ib-api-reloaded",
    "github_project": "ib_async",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ib_async"
}
        
Elapsed time: 0.20683s