Skip to content

Releases: ib-api-reloaded/ib_async

v2.0.1

22 Jun 16:58
Compare
Choose a tag to compare

First "proper release" in almost a year. Includes many bug fixes and new usability helpers.

Thanks to contributors, people who continue to provide ongoing donations, and thanks to @gnzsnz for his continual consistent rapid replies and feedback on support/development issues.

Changes

Commit Changelog: v1.0.3...v2.0.1

Code diff: v1.0.3...v2.0.1

Docs Changelog: https://ib-api-reloaded.github.io/ib_async/changelog.html#ib-async-changelog

New Feature Highlights

One large usability improvement in this release is now you can specify your own custom values for "no price" or "no size" or "no value available" situations. Previously, the library only passed through IBKR API default values of empty prices being -1 and empty sizes being 0 and unset values being nan. These defaults are actually somewhat dangerous because in some circumstances, negative prices are valid, so if you only consume prices without checking "is this -1 a real value or not?" you can end up with unexpected results.

Now, customizing your own empty/zero value defaults can greatly simplify your logic and improve code correctness instead of having to check for all combinations or price and size and unset possibilities everywhere.

Also, you can specify a default timezone for the objects to populate instead of UTC as well.

Here's a simple example of the new default setting mechanism, but you could also use custom objects for EmptyPrice or EmptySize or UnsetValue if you wanted.

USEastern: Final = pytz.timezone("US/Eastern")  

# Set custom values for unpopulated API values
ib_async.IB(defaults=IBDefaults(emptyPrice=None, emptySize=None, unset=None, timezone=USEastern))

# If you don't specify a `defaults` parameter, it just uses the original behavior of:
ib_async.IB(defaults=IBDefaults(emptyPrice=-1, emptySize=0, unset=float("nan"), timezone=datetime.timezone.utc))

Additionally, there are more bug fixes and quality of life enhancements:

  • Bag contracts (spreads) can now be hashed, so they can be used in more places
  • The greeks object now supports native math operations against the objects themselves, so you can generate spread greeks easily by just adding, subtracting, or multiplying greeks objects directly as whole entities
  • Bug fixes around orders being deleted incorrectly during "validation errors" which were just warnings but the orders were still live
  • OrderState objects (where all prices are just strings) now support conversion to direct numeric values instead.
  • a workaround bugfix for IBKR returning incorrect contract types if multiple exist on the same expiration (i.e. IBKR returns Event Contract results when trying to qualify only Futures Options, which is clearly a bug? So now we just workaround it more directly by rejecting alternative contract types than we requested directly)
  • Adds 5 new tick types we weren't processing before: volumeRate3Min, volumeRate5Min, volumeRate10Min, shortable
  • Added more logging to report if unknown data types are arriving from the API we need to start reading
  • Restructured the README a little. Feedback welcome for better ways to continue organizing it.