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

Does this work with on the apple silicon version of tws ? #204

Open
anarchy89 opened this issue Apr 5, 2023 · 17 comments
Open

Does this work with on the apple silicon version of tws ? #204

anarchy89 opened this issue Apr 5, 2023 · 17 comments

Comments

@anarchy89
Copy link

anarchy89 commented Apr 5, 2023

Does this work with on the apple silicon version of tws ? I tried the standalone version but it does not work.

I have installed the offline 10.19 version of both gateway and tws and i get this error,

Error: Offline TWS/Gateway version 1019 is not installed: can't find jars folder
       Make sure you install the offline version of TWS/Gateway
       IBC does not work with the auto-updating TWS/Gateway
@rlktradewright
Copy link
Member

Attach your IBC logfile.

@chungichien0923
Copy link

chungichien0923 commented Sep 22, 2023

I have a similar problem.
Here's my IBC logfiles.
ibc-3.18.0_GATEWAY-1019_週五.txt
ibc-3.18.0_TWS-1019_週五.txt

Is it still not working on apple silicon version of tws?

@rlktradewright
Copy link
Member

It has always worked with Apple silicon. It works anywhere that TWS/Gateway work.

But you do need to follow the instructions!

Look at the comment that describes the TWS_MAJOR_VRSN variable in twsstartmacos.sh and gatewaystartmacos.sh. Read it carefully and you'll see that this should be set to 10.19, not 1019.

@chungichien0923
Copy link

I don't understand the documentation completely...
I thought I shouldn't change anything of the .sh file.(I'm not familiar with terminal/cmd...
Thank you.

@chungichien0923
Copy link

After changing 1019 to 10.19, I can succesfully use ibc!
The weird thing is that I don't need to type my username and password, but I can still log in my own account?

@rlktradewright
Copy link
Member

@chungichien0923

The comments in the .sh files make it pretty clear which parts you may need to change, and which parts you shouldn't. The only script files where you may need to make changes are twsstartmacos.sh and gatewaystartmacos.sh. And if you install things in the recommended locations, the only thing you may have to change is TWS_MAJOR_VRSN, if it's not already correctly set. And of course you have to change config.ini.

I realised yesteday that the default setting for TWS_MAJOR_VRSN in twsstartmacos.sh and gatewaystartmacos.sh in the download zip is incorrect (1019 instead of 10.19), and this is certainly confusing. I've fixed these in the repository and I'll re-issue the download zip with correct files.

Why do you think it's weird that you 'don't need to type my username and password, but I can still log in my own account'? Logging in automatically is the main purpose of IBC. Perhaps I'm misunderstanding what you mean.

@chungichien0923
Copy link

Before I even try to type username and password in config.ini and twsstartmacos.sh/gatewaystartmacos.sh, I can login in my account rather than demo account, is it normal?
Sorry for my poor English..., after reading the documentation, I thought the only thing I should change is config.ini?
If I make sure tha path is correct?
(macOS)
IBKR TWS program files: /home//Applications
IBC program files: /opt/ibc
config.ini: /home//ibc

@rlktradewright
Copy link
Member

First, no need to apologise about your 'poor English': it seems pretty good to me! I don't speak a word of Chinese (or whatever your native language is)...

But I really don't understand what you're doing.

You mention 'demo account'. What do you mean by that? IBKR offer a free trial demo account, which you can use for a limited time to try out their service and see if you want to open a real account. Do you mean that? Or do you mean your paper-trading account? I don't know whether IBC will work with the free demo account, because I'm unable to test it. It certainly works with a paper-trading account.

Don't put your username and password in twsstartmacos.sh or gatewaystartmacos.sh, it's not a good idea. Just put it in config.ini.

If you run IBC without putting your username and password in config.ini (or the .sh files), then it will just give you the normal login dialog and wait for you to enter your username and password there, as if you were starting TWS manually. So make sure IBC/TWS are not running, put your username and password in config.ini, and then start IBC.

I don't know whether anything I've written here will clarify things for you. If not, please explain step-by -step what you are doing, and where you have a problem.

@chungichien0923
Copy link

chungichien0923 commented Sep 30, 2023

"If you run IBC without putting your username and password in config.ini (or the .sh files), then it will just give you the normal login dialog and wait for you to enter your username and password there, as if you were starting TWS manually."
The above is exactly what I expect. However, before I put my username and password in config.ini, it logged in(with the username and password I typed last time)!
The following content in config.ini(default content) is what I mentioned 'demo account' before:

IB API Authentication Settings

------------------------------

Your TWS username:

IbLoginId=edemo

Your TWS password:

IbPassword=demouser

(In .sh file, I only changed TWS_MAJOR_VRSN to 10.19 after I realized that I should plus a dot)

That's why I'm so confused...

@rlktradewright
Copy link
Member

When you run IBC, it uses whatever information is in config.ini at the time. Any changes you make to config.ini while IBC is running have no effect until next time you start it.

So just don't start IBC until after you've put youir correct username and password in config.ini. There's no reason at all to run it before then .

The Getting Started section of the User Guide says this:

  1. Edit the config.ini file,using a text editor such as Notepad, to set your username and password in the IbLoginId and IbPassword settings. It's advisable to use your paper-trading credentials at first to check things out, and for this you'll also need to set the TradingMode setting.
  1. Check that the correct major version number for TWS is set ...
  1. At this stage, everything is set up to run IBC with its default settings, which will start TWS and attempt to log it into your paper-trading user. It is worthwhile doing this to check that everything works before further customising it to suit your needs. To do this, run the relevant shell script (StartTWS.bat on Windows, twsstart.sh on Unix, twsstartmacos.sh on macOS) from the IBC installation folder. If everything is satisfactory, shut down IBC by closing TWS in the usual way.

So it doesn't tell you to start IBC until after you've done steps 7 and 8.

By the way, the edemo/demouser username and password relate to an old demo system that IB used to provide: it was shut down several years ago. config.ini contains these as defaults just because that what it's always had. Nothing else would make any more sense, so I've just left it like that.

@chungichien0923
Copy link

Actually, I run it without setting my username and password in the IbLoginId and IbPassword settings on purpose.
I want to see what would happen if I typed the wrong username and password.
Is "automatically use the username and password I typed manually last time(before I downloaded IBC)" normal for IBC?

@rlktradewright
Copy link
Member

IBC doesn't modify TWS's behaviour in any way. All it does is the same things the user might do, but it does them automatically so that the user doesn't have to do them.

So if you put the wrong user name and password in config.ini, what will happen is exactly the same as if you run TWS manually, (ie not using IBC)and then enter the wrong username and password. It's pointless wasting your time (and mine!) doing this sort of experimenting.

Why don't you just put the correct username and password in there, and then run it. You'll never need to touch it again unless you want to run with a different username/password.

@chungichien0923
Copy link

Okay... it just feels kind of weird that it can automatically use the username and password typed before😅
Thanks for your help🙏🙏

@rlktradewright
Copy link
Member

No, I sitll don't understand what you mean.

Let me try to explain what happens.

First, without IBC:

  • When you run TWS, it presents the login dialog, with the username and password fields blank.
  • TWS always expects to be given a username and password every time you start it. It interacts with IBKR's login server to establish an authenticated session, and this returns a cryptographically sealed session token to TWS, which it stores in memory.
  • If the username and/or password are invalid, TWS displays an error message and waits for the user to re-enter them.
  • TWS needs to be restarted once day (for various technical reasons). To avoid the user having to do a fulll login including 2FA, every time it restarts, TWS has an auto-restart mechanism which doesn't require the user to give a username and password. In this case it uses the cryptographicaly sealed session token that was generated by the previous login. This token is stored briefly in a file (called the autorestart file) just before the session that is being restarted shuts down, and TWS then starts a new instance of itself and shuts down. The new TWS instance reads the token from the autorestart file, deletes the autorestart file, and presents the token to IBKRs login server. This checks the validity of the token, and then allows the login to proceeed (and returns a new session token to TWS, the old one now being invalid).

Now consider what happens when running under IBC:

  • IBC reads the config.ini file and stores all the settings in memory. It never changes these in-memory settings in any way, nor does it ever write to config.ini.
  • It then does various things such as setting up timers, as specified in the settings.
  • It hooks into the low-level Java event-handling mechanism so that it will be informed when TWS does things like opening or closing a dialog.
  • Next it loads TWS into the same process as itself, and starts it running.
  • As far as TWS is concerned, it is running in exactly the same way as if it had been started manually. It has no idea that IBC is monitoring things.
  • TWS now goes through its normal login mechanism. If the autorestart file does not exist, TWS displays the login dialog in the usual way. IBC detects this and copies the values for username and password from the settings into the appropriate field, and then clicks the login button. If the autorestart file does exist when TWS starts, IBC doesn't do anything because TWS is automatically handling the relogin using the session token.
  • If 2FA is needed, then that all proceeds as normal. If login or auto-relogin succeeds, a session is started as usual. If it fails (for example because username or password is invalid), TWS displays its error message, and IBC does nothing: there is nothing sensible it can do, but the user (if present) can manually enter the username and password again and proceed with the login.

To summarise, when you are using IBC the only effect it has on login is to enter the values for username and password that it read from config.ini and click the login button. And TWS behaves exactly as if it were a physical user logging in (it doesn't know that it isn't!).

So when you say "it just feels kind of weird that it can automatically use the username and password typed before", that doesn't make any sense to me. IBC uses whatever is in config.ini. It's as simple as that.

@bug-or-feature
Copy link

@rlktradewright this is a really good explanation of what is going on, please add it to the docs

@chungichien0923
Copy link

chungichien0923 commented Oct 2, 2023

After I deleted all the files, redownload, and followed the instructions to set .ini and .sh again, all the problems were gone.
I still don't know why there were problems before, but I'm glad that now I can use it as I expected.😅

@rlktradewright
Copy link
Member

@bug-or-feature Thanks. I won't promise anything - these things take time, and spending time on IBC is something I rather begrudge. We'll see...

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

No branches or pull requests

4 participants