ib-api-reloaded / ib_async

Python sync/async framework for Interactive Brokers API (replaces ib_insync)
BSD 2-Clause "Simplified" License
223 stars 37 forks source link

Fix Error 'Contract can't be hashed' #5

Closed hcho3 closed 3 months ago

hcho3 commented 3 months ago

The set membership test in https://github.com/ib-api-reloaded/ib_async/blob/0ae43453b05345e3d21be518dcedb4dda6cb019f/ib_async/client.py#L255-L256

requires field to be hashable. When qualifyContracts is first called, a new contract object is passed in as field, and it is not yet hashable since the contract is not yet qualified.

The old ib_insync library did not have this issue as it used a tuple instead of a set.

Fix: Guard the membership test by first testing whether field is hashable.

Closes #4

ps. Thank you for continuing the work of ib_insync. It means a lot to me.

mattsta commented 3 months ago

Thanks for looking into this! I cleaned it up in a larger way which should hopefully be a little faster and more stable going forward.