Skip to content

Refactor IB adapter #2647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2025
Merged

Refactor IB adapter #2647

merged 2 commits into from
Jun 7, 2025

Conversation

faysou
Copy link
Collaborator

@faysou faysou commented May 17, 2025

Pull Request

NautilusTrader prioritizes correctness and reliability, please follow existing patterns for validation and testing.

Summary

Refine IB adapter

  • Allow to use any venue or exchange when using IB as data and execution client (see example notebook)
  • Refactored instrument provider to work better, especially when converting exchanges to MIC venues or vice versa. The key idea is to always provide a venue or exchange as argument to related functions in order to avoid uncertainty on what to use.
  • Removed Databento symbology option, it works with IB simplified instead and convert_exchange_to_mic_venue in InteractiveBrokersInstrumentProviderConfig
instrument_provider = InteractiveBrokersInstrumentProviderConfig(
    symbology_method=SymbologyMethod.IB_SIMPLIFIED,
    convert_exchange_to_mic_venue=True,
)
  • Modified supported futures and options on futures symbols to be compatible with databento (single digit for years and space between underlying and option specification).
  • Moved set_specific_venue to cache instead of portfolio, so account_for_venue returns a consistent result throughout the system
  • Add support for priceMagnifier, the nautilus side is unmagnified, and the conversion to and from IB is handled in various places of the code
  • Fixed support for contfut for historical bars. Thanks to @FGU1 for additional ideas to make the solution more elegant.
  • added possibility to request ibcontract information (load_id) for all instruments already in the cache, loaded from a catalog for example. Possibility also to avoid an IB call if the IB contract details are already saved in the catalog and present in an already loaded instrument.

Related Issues/PRs

#2609
#2531

Type of change

  • Bug fix (non-breaking)

Breaking change details (if applicable)

Symbols for futures must now use single digits.

Release notes

  • I added a concise entry to RELEASES.md that follows the existing conventions (when applicable)

Testing

Ensure new or changed logic is covered by tests.

Updated IB tests
Added a test notebook

@faysou faysou force-pushed the ib_adapter_update branch 11 times, most recently from a167694 to 9723c3a Compare May 24, 2025 13:17
@faysou faysou force-pushed the ib_adapter_update branch 2 times, most recently from 279fe36 to 960727c Compare May 26, 2025 12:51
@faysou faysou force-pushed the ib_adapter_update branch 13 times, most recently from 3603915 to 8426a2d Compare June 2, 2025 09:35
@faysou faysou force-pushed the ib_adapter_update branch 3 times, most recently from 6f057f6 to c290949 Compare June 5, 2025 08:46
@faysou faysou force-pushed the ib_adapter_update branch 5 times, most recently from 32176f4 to 1ff3850 Compare June 5, 2025 15:55
@faysou faysou force-pushed the ib_adapter_update branch from 1ff3850 to c897f6a Compare June 6, 2025 10:36
@cjdsellers cjdsellers changed the title Refine IB adapter Refactor IB adapter Jun 6, 2025
@cjdsellers
Copy link
Member

Hi @faysou

Many thanks for all this work, I think this improves the quality of the adapter.

@cjdsellers cjdsellers merged commit eab9178 into develop Jun 7, 2025
13 checks passed
@cjdsellers cjdsellers deleted the ib_adapter_update branch June 7, 2025 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants