nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
2.03k stars 465 forks source link

Include async-timeout package in Interactive Brokers extra dependencies #1295

Closed benjaminsingleton closed 11 months ago

benjaminsingleton commented 11 months ago

Bug Report

Expected Behavior

If you install the Interactive Brokers "ib" extras, you'd expect from nautilus_trader.adapters.interactive_brokers.historic.bar_data import BarDataDownloader to import without a ModuleNotFoundError.

This issue can be fixed by installing the missing package with $ pip install async-timeout or $ poetry add async-timeout. I think a better fix is updating the pyproject.toml with the following:

[tool.poetry.dependencies]
...
nautilus_ibapi = {version = "==1019.1", optional = true}  # Pinned for stability
async-timeout = "^4.0.3"

[tool.poetry.extras]
...
ib = ["nautilus_ibapi", "async-timeout"]

Actual Behavior

>> from nautilus_trader.adapters.interactive_brokers.historic.bar_data import BarDataDownloaderConfig
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/benjamin/Projects/nautilus-test/.venv/lib/python3.10/site-packages/nautilus_trader/adapters/interactive_brokers/historic/bar_data.py", line 22, in <module>
    from nautilus_trader.adapters.interactive_brokers.historic.async_actor import AsyncActor
  File "/Users/benjamin/Projects/nautilus-test/.venv/lib/python3.10/site-packages/nautilus_trader/adapters/interactive_brokers/historic/async_actor.py", line 24, in <module>
    import async_timeout
ModuleNotFoundError: No module named 'async_timeout'

Steps to Reproduce the Problem

$ mkdir nautilus-test
$ cd nautilus-test
$ poetry init --no-interaction
$ sed -i '' '/^python = /c\  
 python = ">=3.10,<3.12"' pyproject.toml
$ poetry add nautilus-trader -E ib
$ poetry shell
$ python

>> from nautilus_trader.adapters.interactive_brokers.historic.bar_data import BarDataDownloaderConfig
...
ModuleNotFoundError: No module named 'async_timeout'

Specifications

cjdsellers commented 11 months ago

Closed from #1302 .