Skip to content

Commit

Permalink
Rename project to ib_async and modernize layout
Browse files Browse the repository at this point in the history
Steps:

- Renamed ib_insync to ib_async everywhere
- Converted README.rst to README.md
- Updated IBKR API links to new ibkrcampus instead of old github docs
- Removed setup.{py,cfg} to use Poetry for installing, docs, packaging
- Converted links from /erdewit/ account to new /ib-api-reloaded/ org
- Removed helper scripts for packaging and building docs
- Removed docs-generated HTML from repository
- Auto-build docs and update docs site on every push
- Increase minimum Python version from 3.6 (2016) to 3.10 (2021)
- Remove dependencies for supporting Python versions less than 3.9

Remaining TODO:

- Need more of a history document about original development
- Need to create new pypi package
- Need to add the two missing IBKR API feature updates
- Start new code improvement cycle
  • Loading branch information
mattsta committed Mar 18, 2024
1 parent 2762a9a commit 81484fd
Show file tree
Hide file tree
Showing 105 changed files with 387 additions and 44,701 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Adapted from https://tomasfarias.dev/articles/sphinx-docs-with-poetry-and-github-pages/
name: docs
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: abatilo/actions-poetry@v2
- name: install
run: poetry install --with=docs
- name: Build documentation
run: |
mkdir html
touch html/.nojekyll
poetry run sphinx-build -b html docs html
- name: Deploy documentation
if: ${{ github.event_name == 'push' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: html
12 changes: 5 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: ib_insync
name: ib_async

on: [ push, pull_request ]

jobs:
build:
#runs-on: ubuntu-latest
runs-on: ubuntu-20.04
# https://github.com/actions/runner-images
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12" ]
python-version: [ "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
Expand All @@ -24,6 +24,4 @@ jobs:
- name: MyPy static code analysis
run: |
mypy -p ib_insync
mypy -p ib_async
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ib_insync/__pycache__
ib_async/__pycache__
dist
build
.vscode
Expand All @@ -9,7 +9,7 @@ build
.pydevproject
.mypy_cache
.eggs
docs/html/.buildinfo
docs/html/.doctrees
docs/doctrees
ib_insync.egg-info
html
doctrees
ib_async.egg-info
poetry.lock
17 changes: 0 additions & 17 deletions .readthedocs.yml

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
BSD 2-Clause License

Copyright (c) 2019 - 2023, Ewald de Wit
Copyright (c) 2024, Matt Stancliff
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
148 changes: 148 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
[![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_async/discussions) for recent history. Create new discussions or PRs or issues under 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
- stable: https://www.interactivebrokers.com/en/trading/ibgateway-stable.php
- latest: https://www.interactivebrokers.com/en/trading/ibgateway-latest.php
- 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.

## Building Manually

First, install poetry:

```
pip install poetry -U
```

### Installing Only Library

```
poetry install
```

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

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

## Generating Docs

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

## Build Packages

```
poetry build
```

## Upload Package

```
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.
137 changes: 0 additions & 137 deletions README.rst

This file was deleted.

Loading

0 comments on commit 81484fd

Please sign in to comment.