Skip to content
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

Added timeout from env variable to IB client requests #2012

Closed

Conversation

marcodambros
Copy link

Pull Request

This very small PR include two changes:

  1. It fixes a bug in IB data client logger, which always printed None instead of the instrument name
  2. For some requests to IB, instead of using a default timeout of 60, the timeout can be set with an environment variable, which if does not exist, will default to 60.

Type of change

Delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

How has this change been tested?

The code was tested locally by building nautilus and using it as a dependency in a project.

Fixed a small bug in logging when subscribing to bars in IB.
@CLAassistant
Copy link

CLAassistant commented Oct 17, 2024

CLA assistant check
All committers have signed the CLA.

@cjdsellers
Copy link
Member

Hi @marcodambros

Thanks for the contribution!

(1) Seems like a good change.
(2) We might want to make this more first-class and incorporate the timeout interval into the configuration, maybe @rsmb7z has some thoughts?

@rsmb7z
Copy link
Collaborator

rsmb7z commented Oct 18, 2024

Hi @cjdsellers @marcodambros
I think adding it to InteractiveBrokersDataClientConfig would be more consistent and easier to find configurable params.

@@ -390,7 +391,8 @@ async def get_historical_bars(
return []
self._log.debug(f"reqHistoricalData: {request.req_id=}, {contract=}")
request.handle()
return await self._await_request(request, timeout, default_value=[])
ib_timeout = int(os.environ.get("IB_REQUEST_TIMEOUT", timeout))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marcodambros

If you can remove these lines sourcing the timeout from an env var, we can then merge this and I'll add a config option for the timeout.

@cjdsellers
Copy link
Member

Hi @marcodambros

I've gone ahead and fixed the subscription logging per this PR (and credited you in the release notes).

For the timeout, that's actually exposed as a timeout parameter already on HistoricInteractiveBrokersClient.request_bars, so no need for additional config as far as I can see?

@cjdsellers cjdsellers closed this Oct 27, 2024
@cjdsellers
Copy link
Member

Fixed with commit 52c3ba9.

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.

4 participants