-
Notifications
You must be signed in to change notification settings - Fork 115
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
v0.5.0 - development #147
Comments
Here are the logs from my first attempt at using strategy B:
|
After the maintenance interval:
|
Sadly, it looks like I'll have to abandon strategy B for now because it appears to be stuck in a loop.
|
@Voyz From my side, it has been running the whole day today, and I didn't observe any issues. I will leave it for the next few days and let you know if something goes wrong. |
@Voyz 👏 Strategy B worked well in my server last week, good job! 🥳
Let's observe it for more weeks. |
@migoohao Mine is going into a authentication loop for strategy B in our Debian GNU/Linux 11 (bullseye) Server. Can you please help with your server setup ? |
@Voyz 0.5 Strategy B version throws error (attached in the log below) during maintenance. Is this an expected behaviour ? Thanks Logs Set 1
2023-07-11 09:08:16,411|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 The above exception was the direct cause of the following exception: Traceback (most recent call last): <class 'selenium.common.exceptions.TimeoutException'> Message: timeout: Timed out receiving message from renderer: -0.004 2023-07-11 09:14:07,146|I| Cleaning up the resources. Display: <pyvirtualdisplay.display.Display object at 0x7fc29b43d310> | Driver: <selenium.webdriver.chrome.webdriver.WebDriver (session="a2875a07a08ed1eb674bfcb9b04d876a")> Logs Set 22023-07-11 15:24:16,280|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:25:15,779|I| Maintenance 2023-07-11 15:25:16,126|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:26:15,779|I| Maintenance 2023-07-11 15:26:16,597|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:27:15,779|I| Maintenance 2023-07-11 15:27:16,160|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:28:15,779|I| Maintenance 2023-07-11 15:28:16,168|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:29:15,779|I| Maintenance 2023-07-11 15:29:16,234|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:30:15,779|I| Maintenance 2023-07-11 15:30:16,166|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:31:15,779|I| Maintenance 2023-07-11 15:31:16,655|I| Gateway running and authenticated, session id: c1567fc89b630802a333c9d207c887fb, server name: JifH16040 2023-07-11 15:32:15,779|I| Maintenance 2023-07-11 15:32:16,242|E| Unrecognised HTTPError Traceback (most recent call last): File "/srv/ibeam/src/http_handler.py", line 119, in _request response = self.url_request(url, method=method) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/ibeam/src/http_handler.py", line 104, in url_request return urllib.request.urlopen(req, context=self.ssl_context, timeout=self.request_timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 216, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 525, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 634, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 563, in error return self._call_chain(*args) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 496, in _call_chain result = func(*args) ^^^^^^^^^^^ File "/usr/local/lib/python3.11/urllib/request.py", line 643, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 503: Service Unavailable The above exception was the direct cause of the following exception: Traceback (most recent call last): version: 485dc2d762781c4ff3954ac4fb66a9469a1405f7 Mon, 20 Mar 2023 14:39:35 -0400 This is the Client Portal Gateway https://www.interactivebrokers.com/api/doc.html Open https://localhost:5000 to login The above exception was the direct cause of the following exception: Traceback (most recent call last): |
@vlpraveen thanks for these logs. I believe the issues you're seeing are caused by IBKR server restarts. The 503 and 500 errors seem to indicate that. If you think these could have a different cause, I'd suggest you create a support ticket with IBKR and speak to them about this. Regarding the authentication loop, please see: #152 (comment) |
Hey friends, I've found time to do a proper revamp and handle the remaining tasks on my roadmap. This involved:
Breaking changes:
I'm pretty happy with the results. Most recent version |
Strategy B with 0.5.0-rc3 worked on the first try! 🎉
|
I have tried 0.5.0-rc3 and it works perfectly. Thanks! It should be the main strategy. With the default strategy from the stable version I had issues that 70% of the time I have being disconnected and reauthenticated. |
This thread helped me a lot! I am running the |
IBKR/Gateway runs into returning a 503 Service Unavailable error while placing the order: All other API endpoints work without any errors or issues. Facing the error only for Order API Did anyone else face this issue ? |
@vlpraveen there's been a separate issue for 503 Service Unavailable: #38. Also, it is being mentioned in other issues too. Seeing that this is only one endpoint, I'd address this with IBKR |
Hey guys, You can see full release notes here: https://github.com/Voyz/ibeam/releases/tag/v0.5.0 Big thanks to you for helping test this version out and reporting back 👏👏👏 |
Hey @Voyz et al. I've been trying to understand how to execute the login flow successfully and stumbled over this issue in search for answers to some of the unexpected behaviour I'm seeing. Would you say the following maps to your understanding & implementation of a successful login flow? |
@Voyz I had wanted to share that I'm occasionally seeing 503 when POSTing WhatIf orders. Your analysis in the previous issue thread was spot on and a simple log into my paper trading account to raise the compete flag works to get my automation out of its death spiral of failed message processing. I've set a monitor to let me know if my message processing is failing from 503s so it's something that I'm catching but I do think that there's some issue on IB's side with user sessions that seems to be causing the gateway to start failing with order placing. I'm using the latest Docker image in Azure containers. I have seen strategy 'B' in my logs so I assume I've ended up using that. |
@rbjorklin thanks for submitting your findings 👏 I'd suggest you start a different issue where we could discuss this |
Hold up hold up! Thanks for the credit, but I don't remember mentioning this and this is a great idea. Does doing so get you out of the authentication loop? Do I understand your solution correctly:
Could you comment more on this? |
@demansou could you please elaborate when you find a minute? |
Yes sorry I've been on vacation.
|
@demansou ahh gotcha you're referring to 503 not the auth loop. I just gave it a shot and indeed it seemed to have helped. I'll try it on the reauth loop too, let's see if it works. Thanks for sharing! 👏👏 Update: That also fixes timeout errors. Amazing! I'm gonna test it out on the authentication loop the next time I spot it. Fingers crossed 🤞 |
This issue is tracking the development of IBeam v0.5.0.
You can test the v0.5.0 by pulling the most recent
-rc*
tag, eg:voyz/ibeam:0.5.0-rc1
. Go to IBeam's Docker Hub and check what the most recent v0.5.0 tag is.Major changes:
IBEAM_AUTHENTICATION_STRATEGY
env var asA
orB
. It is possible that this is a temporary feature that will be removed once a clear winning strategy is found.reauthenticate
more than on full re-login. Many thanks for suggesting this logic flow @migoohao 👏 I also want to give kudos to any other users who mentioned usingreauthenticate
in the past.New strategy 'B' logic:
See https://github.com/Voyz/ibeam/blob/v0.5.0/ibeam/src/strategy_handler.py and look for
try_authenticating
and_authentication_strategy_B
Context:
Strategy 'B', just like strategy 'A', is run on every maintenance.
Note that the result of this logic can take one of the four forms:
✅ all good - the Gateway is running and authenticated
⚠️ something's wrong - there's been some issue so we stop this authentication attempt and wait until next maintenance
🔐 need auth - the Gateway is running but we need to authenticate
🚨 shutdown - there has been a critical error during login, so we shut IBeam down
The different authentication actions that can be taken are:
The logic is described below:
(this is subject to change)
tickle
endpoint that refreshes the session and provides us with a bunch of information on the Gateway, the current session and our authentication status. Note that Status now contains additional information (see source).authenticated
andnot competing
: ✅ all goodnot running
:Above steps are the exact same for strategy 'A' and strategy 'B'. The following is where strategy 'B' differs:
not session
: 🔐 need auth - there is a running Gateway but it has no active session, so we login using the web formnot connected
orcompeting
: 🔐 need auth - this is an indication of a conflicting session (eg. TWS or Web Portal) taking over the credentials. We logout, and then reauthenticate.Irrespectively of which of the three cases take place, we end up with carrying out the post authentication double-checks:
a) Check Status every second, up to
IBEAM_MAX_STATUS_CHECK_RETRIES
times (15 by default)b) If all Status checks finish and don't report successful authentication, call reauthenticate once again.
c) Repeat this whole process up to
IBEAM_MAX_REAUTHENTICATE_RETRIES
times (3 by default)not running
ornot session
ornot connected
orcompeting
ornot authenticated
:If you want to test this version:
IBEAM_AUTHENTICATION_STRATEGY
toB
in order to test the new strategyMinor changes:
There has been some tidying up of the
gateway_client.py
file:strategy_handler
http_handler
process_utils
secrets_handler
And minor fixes:
Status
class and handling of Gateway/authentication statussession_id
andserver_name
Roadmap:
If there is time, I'd want to look into theauthenticate.py
file and rework that logic there. It has grown from a small function into some nasty rotten spaghetti code and also deserves some love.Improve on OOP and testability by unifying all environment variable reading into one place, and pass arguments from then on.The text was updated successfully, but these errors were encountered: