auto login for IB TWS under linux

Adamus

Experienced member
Messages
1,898
Likes
97
Can anyone think of a way to auto start and login to IB TWS java app in linux?

I know a windows app exists to do it, but I'm thinking of running it totally automatically in background under the control of the app I wrote to input orders from TradeStation.

If it sounds clunky it's probably because it is, but it works - up to this point where I have to be there to launch the IB app every day.
 
Are you ok with java?

I can send you the code, its one java file, which you would need to compile up, although its quite easy to find on the internet.

Then you would need to setup a scheduled job, probably a 'cron' job, although i am not a Linux expert and there maybe something more user friendly.

I also recommend lots of auto monitoring aswell to make sure everything is ok, emails and sound alerts if things go wrong!!
 
Last edited:
A CRON job is simple to set up. You specify the application, the file to run and the times you want it done in one text file. Type crontab -e to edit the file.

e.g this runs cronjob.php using the php app. every hour (to load today's Outlook calendar into my Facebook ... I know, sad)

# m h dom mon dow command
0 * * * * /usr/bin/php /var/www/facebook/lookout/cronjob.php

m = minute
h = hour
dom = day of month
mon = month
dow = day of week
* = all of them

At the risk of repeating all the fine references available here's a link What is a cronjob, and how do I use it?.
 
Sure, java is my bread and butter. But I can't see how you do it, in fact I only posted on the off-chance that I'd missed something.

I didn't find anything on the net when I searched - including the IB forum.

Does this need to run in a GUI window manager on linux or does it work without ?

I guess I'd appreciate the code - or a link to it somewhere!

Thanks
 
Sure, java is my bread and butter. But I can't see how you do it, in fact I only posted on the off-chance that I'd missed something.

I didn't find anything on the net when I searched - including the IB forum.

Does this need to run in a GUI window manager on linux or does it work without ?

I guess I'd appreciate the code - or a link to it somewhere!

Thanks

One way to do it is to use Jemmy in Netbeans. It should be cross platform and definitely works on Linux. Jemmy is for writing test harnesses and lets you fill inJTextFields etc automatically. Here is some sample code that starts TWS and logs you in automatically:

Code:
import org.netbeans.jemmy.*;
import org.netbeans.jemmy.operators.*;

public class TWSSupervisor
{
    public TWSSupervisor ()
    {
        try
        {
            String [] params = new String [1];
            params [0] = "~/IBJts";   // Directory where TWS is installed
            new ClassReference("jclient.LoginFrame").startApplication(params);

            JFrameOperator loginFrame = new JFrameOperator("Login");
            JTextFieldOperator userNameField = new org.netbeans.jemmy.operators.JTextFieldOperator (loginFrame);
            JPasswordFieldOperator passwordField = new org.netbeans.jemmy.operators.JPasswordFieldOperator (loginFrame);

            JButtonOperator loginButton = new JButtonOperator (loginFrame, "Login");

            loginFrame.requestFocus ();
            userNameField.requestFocus ();
            userNameField.typeText ("MYUSERNAME");
            passwordField.requestFocus ();
            passwordField.typeText ("MYPASSWORD");
            loginButton.requestFocus ();
            loginButton.push ();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
    public static void main(String[] argv)
    {
        new TWSSupervisor ();
    }
}
 
Nice, but it won't work on my account since I activated the additional card security. Guess I should have thought twice about that one.

Thanks anyway.
 
You can opt-out for the security card. Contact IB's helpdesk for that.

Hello all -- Is this really the only way to auto-start TWS (to start the process and do and simulate someone typing (i.e. SendKeys))? Do they allow us to pass the username and password on the command line? Any other solution?

Thanks!
 
Trudeo

I'm not sure what's happened in the last year but you should check out IBController - you'll have to google for it, I don't use it.
 
Top