erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 772 forks source link

Notebook cells are pending after connection to TWS #688

Closed enricoangelelli closed 9 months ago

enricoangelelli commented 9 months ago

This is a problem I have with any notebook using a ib_insync connection to TWS. I report a minimal example.

After executing cell

import ib_insync
ib_insync.util.startLoop()
ib = ib_insync.IB()
ib.connect('127.0.0.1', 7497, clientId=11)
contract = ib_insync.Stock('AMZN', 'SMART', 'USD')
ib.qualifyContracts(contract)
display(contract) 
ib.disconnect()

the next cell

print("Hello")

remains pending. I cannot even execute again the same cell.

Thank you in advance for any help.

Enrico

RGLDN commented 9 months ago

try replacing display(contract) with print(contract)

enricoangelelli commented 9 months ago

I tried, but unfortunately it does not work.

erdewit commented 9 months ago

You can try upgrading to the latest nest_asyncio.

enricoangelelli commented 9 months ago

Yeeeessss! It works. Thank you very much!