Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Inconsistent closure of events upon disconnection #413

Closed
dmoklaf opened this issue Nov 24, 2021 · 2 comments
Closed

Inconsistent closure of events upon disconnection #413

dmoklaf opened this issue Nov 24, 2021 · 2 comments

Comments

@dmoklaf
Copy link

dmoklaf commented Nov 24, 2021

When an ib_insync connection is closed, the events (e.g., the often used Ticker.updateEvent, Trade.statusEvent and Trade.fillEvent) are not set as "done" by the ib_insync machinery. This forces client code to track at the same time both these events and the global disconnection event to stop listening to the former once a disconnection occurs and trigger the right exceptions.

However looking deeper into ib_insync code, it does set as done some events in some situations: if the protocol version is incorrect, Ticker.updateEvents are properly set as done

ticker.updateEvent.set_done()

This irregularity is not documented and not generalized elsewhere. It seems simpler to simplify this: the API should either guarantee that all events are set as done, or none of them (in such case we could get rid of that code in the library that brings no benefit anyway).

PS: if a choice is made, the former alternative would make client code much easier, as we are currently forced to double-track events and the disconnection everywhere as the "done" state is in most cases never triggered by a disconnection.

@erdewit
Copy link
Owner

erdewit commented Nov 25, 2021

Thanks for your insightful bug report. All events that belong to objects that get destroyed after a disconnect should be set as done (*). Currently this is not done after a regular disconnect, and also not for trade events. This will be fixed.

(*) Note that this does not apply to the IB.xxxEvent events, they can start emitting again after a new connection is made.

@dmoklaf
Copy link
Author

dmoklaf commented Nov 26, 2021

Outstanding ! Thanks for the excellent work

flepied pushed a commit to flepied/ib_insync that referenced this issue Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants