IbcAlpha / IBC

Automation of Interactive Brokers TWS. You can download the latest release here: https://github.com/ibcalpha/ibc/releases/latest
GNU General Public License v3.0
1.03k stars 181 forks source link

"Enable ActiveX and Sockets Clients" is not set in fresh install TWS 984 standalone linux version #120

Closed xerges-crypto closed 2 years ago

xerges-crypto commented 3 years ago

Dear Richard,

I was forced to use the latest version (984) standalone installer due long user names seems to disable "Login" button and TWs/GW doesn't login.

I manage to launch ''ibcstart.sh'' with this version to start TWS and everything seems to work fine, but I notice that checking "Enable ActiveX and Sockets Clients" is likely skipped somehow.

I notice that there is a EnableApiTask class designed for that, but I can not see in the log any activity, but others like ConfigureReadOnlyApiTask do their work with these settings.

I know that GW has no problem as this flag is missing (and set by default), but I would like to use TWS for manage the position in case anything is going wrong.

Do you mind to give any hint for solving this issue please?

Please, let me know anything from my side that I can do for helping in the solution.

Thanks in advance,

Trace:

root@33a3e4ef3c78:~# /opt/ibc/scripts/ibcstart.sh $APP_VERSION "--ibc-ini=/opt/ibc/config.ini" "--mode=$TRADING_MODE" "--user=$TWS_USER_ID" "--pw=$TWS_PASSWORD"

================================================================================

Starting IBC version  on 2021-05-18 at 05:12:32

Operating system: Linux 33a3e4ef3c78 5.11.0-17-generic #18-Ubuntu SMP Thu May 6 20:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Arguments:

TWS version = latest
Entry point = ibcalpha.ibc.IbcTws
--tws-path = 
--tws-settings-path = 
--ibc-path = 
--ibc-ini = /opt/ibc/config.ini
--mode = live
--java-path = 
--user = ***
--pw = ***

=================================
Generating the classpath
Classpath=/root/Jts/latest/jars/jts4launch-984.jar:/root/Jts/latest/jars/jxbrowser-7.14.jar:/root/Jts/latest/jars/jxbrowser-linux64-7.14.jar:/root/Jts/latest/jars/jxbrowser-swing-7.14.jar:/root/Jts/latest/jars/locales.jar:/root/Jts/latest/jars/log4j-api-2.12.0.jar:/root/Jts/latest/jars/log4j-core-2.12.0.jar:/root/Jts/latest/jars/total-2020.jar:/root/Jts/latest/jars/twslaunch-984.jar:/root/Jts/latest/jars/twslaunch-install4j-1.10.jar:/opt/ibc/IBC.jar

Generating the JAVA VM options
Java VM Options=-Xmx768m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70

Determining the location of java executable
Location of java executable=/opt/i4j_jres/1.8.0_152-tzdata2019c/bin

Starting TWS with this command:
"/opt/i4j_jres/1.8.0_152-tzdata2019c/bin/java" -cp "/root/Jts/latest/jars/jts4launch-984.jar:/root/Jts/latest/jars/jxbrowser-7.14.jar:/root/Jts/latest/jars/jxbrowser-linux64-7.14.jar:/root/Jts/latest/jars/jxbrowser-swing-7.14.jar:/root/Jts/latest/jars/locales.jar:/root/Jts/latest/jars/log4j-api-2.12.0.jar:/root/Jts/latest/jars/log4j-core-2.12.0.jar:/root/Jts/latest/jars/total-2020.jar:/root/Jts/latest/jars/twslaunch-984.jar:/root/Jts/latest/jars/twslaunch-install4j-1.10.jar:/opt/ibc/IBC.jar" -Xmx768m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70 ibcalpha.ibc.IbcTws "/opt/ibc/config.ini" *** *** live

IBC Settings:
    AcceptIncomingConnectionAction=accept
    AcceptNonBrokerageAccountWarning=yes
    AllowBlindTrading=yes
    BindAddress=
    ClosedownAt=
    CommandPrompt=
    ControlFrom=
    DismissNSEComplianceNotice=yes
    DismissPasswordExpiryWarning=yes
    ExistingSessionDetectedAction=secondary
    ExitAfterSecondFactorAuthenticationTimeout=yes
    FIX=no
    FIXLoginId=***
    FIXPassword=***
    IbAutoClosedown=no
    IbDir=
    IbLoginId=***
    IbPassword=***
    LogComponents=never
    LoginDialogDisplayTimeout=60
    MinimizeMainWindow=no
    OverrideTwsApiPort=4001
    ReadOnlyApi=no
    ReadOnlyLogin=no
    SaveTwsSettingsAt=
    SecondFactorAuthenticationExitInterval=
    ShowAllTrades=no
    StoreSettingsOnServer=no
    SuppressInfoMessages=yes
    TradingMode=live
End IBC Settings

2021-05-18 05:12:32:938 IBC: Version: 3.8.5
System Properties
------------------------------------------------------------
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /opt/i4j_jres/1.8.0_152-tzdata2019c/lib/amd64
java.vm.version = 25.152-b16
java.vm.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
path.separator = :
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg = sun.io
user.country = US
sun.java.launcher = SUN_STANDARD
sun.os.patch.level = unknown
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /root/Jts
java.runtime.version = 1.8.0_152-b16
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.endorsed.dirs = /opt/i4j_jres/1.8.0_152-tzdata2019c/lib/endorsed
os.arch = amd64
java.io.tmpdir = /tmp
line.separator = 

java.vm.specification.vendor = Oracle Corporation
os.name = Linux
sun.jnu.encoding = ANSI_X3.4-1968
java.library.path = /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 5.11.0-17-generic
user.home = /root
user.timezone = GMT
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = ANSI_X3.4-1968
java.specification.version = 1.8
java.class.path = /root/Jts/latest/jars/jts4launch-984.jar:/root/Jts/latest/jars/jxbrowser-7.14.jar:/root/Jts/latest/jars/jxbrowser-linux64-7.14.jar:/root/Jts/latest/jars/jxbrowser-swing-7.14.jar:/root/Jts/latest/jars/locales.jar:/root/Jts/latest/jars/log4j-api-2.12.0.jar:/root/Jts/latest/jars/log4j-core-2.12.0.jar:/root/Jts/latest/jars/total-2020.jar:/root/Jts/latest/jars/twslaunch-984.jar:/root/Jts/latest/jars/twslaunch-install4j-1.10.jar:/opt/ibc/IBC.jar
user.name = root
java.vm.specification.version = 1.8
sun.java.command = ibcalpha.ibc.IbcTws /opt/ibc/config.ini maquino0078 jiec3ohXfaiFa8ak live
java.home = /opt/i4j_jres/1.8.0_152-tzdata2019c
sun.arch.data.model = 64
user.language = en
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.X11.XToolkit
java.vm.info = mixed mode
java.version = 1.8.0_152
java.ext.dirs = /opt/i4j_jres/1.8.0_152-tzdata2019c/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /opt/i4j_jres/1.8.0_152-tzdata2019c/lib/resources.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/rt.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/sunrsasign.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/jsse.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/jce.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/charsets.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/lib/jfr.jar:/opt/i4j_jres/1.8.0_152-tzdata2019c/classes
java.vendor = Oracle Corporation
file.separator = /
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.cpu.isalist = 
------------------------------------------------------------
2021-05-18 05:12:32:941 IBC: Using default settings provider: ini file is /opt/ibc/config.ini
2021-05-18 05:12:32:941 IBC: Using default login manager: getting username and password from args
2021-05-18 05:12:32:941 IBC: Using default main window manager: constructor parameter isGateway=false
2021-05-18 05:12:32:941 IBC: Using default trading mode manager: constructor parameter args: tradingMode=live
2021-05-18 05:12:32:942 IBC: Using default config dialog manager
2021-05-18 05:12:32:947 IBC: CommandServer is not started because the port is not configured
2021-05-18 05:12:33:037 IBC: TWS Settings directory is: /root/Jts
2021-05-18 05:12:33:041 IBC: Ensuring /root/Jts/jts.ini contains required minimal lines
2021-05-18 05:12:33:042 IBC: Found setting: [Logon]/s3store=true
2021-05-18 05:12:33:042 IBC: Found setting: [Logon]/Locale=en
2021-05-18 05:12:33:042 IBC: Found setting: [Logon]/displayedproxymsg=1
2021-05-18 05:12:33:042 IBC: Found setting: [IBGateway]/ApiOnly=true
2021-05-18 05:12:33:042 IBC: Confirmed /root/Jts/jts.ini contains required minimal lines
2021-05-18 05:12:33:042 IBC: Starting session: will exit if login dialog is not displayed within 30 seconds
2021-05-18 05:12:35:235 IBC: Getting config dialog
2021-05-18 05:12:35:235 IBC: Creating config dialog future
2021-05-18 05:12:35:236 IBC: Getting config dialog
2021-05-18 05:12:35:236 IBC: Waiting for config dialog future to complete
2021-05-18 05:12:35:236 IBC: Getting main window
2021-05-18 05:12:35:236 IBC: Creating main window future
2021-05-18 05:12:36:344 IBC: Detected frame entitled: Login; event=Activated
2021-05-18 05:12:36:346 IBC: Setting Trading mode = live
2021-05-18 05:12:36:421 IBC: Setting user name
2021-05-18 05:12:36:423 IBC: Setting password
2021-05-18 05:12:36:427 IBC: Detected frame entitled: Login; event=Focused
2021-05-18 05:12:36:431 IBC: Detected frame entitled: Login; event=Opened
2021-05-18 05:12:36:495 IBC: Use/store settings on server selected: false
2021-05-18 05:12:36:495 IBC: Click button: Log In
2021-05-18 05:12:38:561 IBC: Button now disabled: Log In
2021-05-18 05:12:39:051 IBC: Detected frame entitled: Login; event=Lost focus
2021-05-18 05:12:39:052 IBC: Detected frame entitled: Authenticating...; event=Opened
2021-05-18 05:12:39:061 IBC: Detected frame entitled: Authenticating...; event=Activated
2021-05-18 05:12:39:062 IBC: Detected frame entitled: Authenticating...; event=Focused
LogModuleConfigurator-Init: Log4j Ver2.x found on classpath
LogModuleConfigurator-Init: LogModuleConfigurator initialized with Log4j Verd.x
2021-05-18 05:12:52:310 IBC: Detected frame entitled: Starting application...; event=Lost focus
2021-05-18 05:12:52:311 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Activated
2021-05-18 05:12:52:321 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Focused
2021-05-18 05:12:52:322 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Opened
2021-05-18 05:12:52:322 IBC: Found TWS main window
2021-05-18 05:12:52:322 IBC: Login has completed
2021-05-18 05:12:52:322 IBC: Got main window from future
2021-05-18 05:12:52:448 IBC: Detected frame entitled: Starting application...; event=Closed
2021-05-18 05:12:59:281 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Opened
2021-05-18 05:12:59:282 IBC: Got config dialog from future
2021-05-18 05:12:59:282 IBC: Got config dialog from future
2021-05-18 05:12:59:291 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Opened
2021-05-18 05:12:59:486 IBC: Setting ReadOnlyApi
2021-05-18 05:12:59:555 IBC: Read-Only API checkbox is already set to: false
2021-05-18 05:12:59:555 IBC: Performing port configuration
2021-05-18 05:12:59:555 IBC: TWS API socket port is already set to 4001
2021-05-18 05:12:59:556 IBC: Click button: OK
2021-05-18 05:12:59:899 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Closed
2021-05-18 05:13:12:886 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Lost focus
2021-05-18 05:13:12:893 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Activated
2021-05-18 05:13:12:897 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Focused
2021-05-18 05:13:12:966 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Closing
2021-05-18 05:13:13:375 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Lost focus
2021-05-18 05:13:13:376 IBC: Detected frame entitled: Daily Lineup: Tuesday, May 18, 2021; event=Closed
2021-05-18 05:13:14:708 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Activated
2021-05-18 05:13:14:708 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Focused
2021-05-18 05:13:19:323 IBC: Detected frame entitled: Uxxxxxxx Interactive Brokers; event=Lost focus
2021-05-18 05:13:19:324 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Activated
2021-05-18 05:13:19:325 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Focused
2021-05-18 05:13:19:325 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Opened

null(javax.swing.JRootPane){Object.Component.Container.JComponent.JRootPane}
|   null.glassPane(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   null.layeredPane(javax.swing.JLayeredPane){Object.Component.Container.JComponent.JLayeredPane}
|   |   null.contentPane(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   |   |   null(javax.swing.JToolTip){Object.Component.Container.JComponent.JToolTip}

2021-05-18 05:13:34:526 IBC: Detected window: type=javax.swing.Popup$HeavyWeightWindow; event=Opened

null(javax.swing.JRootPane){Object.Component.Container.JComponent.JRootPane}
|   null.glassPane(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   null.layeredPane(javax.swing.JLayeredPane){Object.Component.Container.JComponent.JLayeredPane}
|   |   null.contentPane(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   |   |   null(feature.ui.aJ){Object.Component.Container.JComponent.JToolTip.aJ}
|   |   |   |   null(feature.ui.aw){Object.Component.Container.JComponent.JPanel.au.av.aw}
|   |   |   |   |   null(javax.swing.JTextPane){Object.Component.Container.JComponent.JTextComponent.JEditorPane.JTextPane}
|   |   |   |   |   null(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   |   |   |   |   |   null(javax.swing.Box$Filler){Object.Component.Container.JComponent.Filler}
|   |   |   |   |   |   null(javax.swing.JPanel){Object.Component.Container.JComponent.JPanel}
|   |   |   |   |   |   |   null(trader.common.tag.m){JCheckBox: Do not show column description tooltips again.(unselected)}
|   |   |   |   |   |   |   null(javax.swing.Box$Filler){Object.Component.Container.JComponent.Filler}

2021-05-18 05:13:38:618 IBC: Detected window: type=javax.swing.Popup$HeavyWeightWindow; event=Opened
2021-05-18 05:13:39:710 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Closing
2021-05-18 05:13:39:833 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Lost focus
2021-05-18 05:13:39:834 IBC: Detected window: type=javax.swing.Popup$HeavyWeightWindow; event=Closed
2021-05-18 05:13:39:835 IBC: Detected dialog entitled: Uxxxxxxx Trader Workstation Configuration; event=Closed
18/05/2021 05:14:36 idle keyboard:   turning X autorepeat back on.
rlktradewright commented 3 years ago

You should configure the settings you require in TWS manually. You only need to do it once.

It is not IBC's function to be a general-purpose TWS configuration mechanism. There are simply too many settings.

xerges-crypto commented 3 years ago

You should configure the settings you require in TWS manually. You only need to do it once.

Your are right If we choose to store setting in server side, so this setting and others will be preserved for next relaunch of TWS/GW.

It is not IBC's function to be a general-purpose TWS configuration mechanism. There are simply too many settings.

Ok, Maybe I miss the point. I guess using TWS controlled by a supervisor (like IBC) was primary intended for algorithmic trading, so I was surprised this setting was missing, mainly because the code looks like it was the intention in some point in the past.

Finally, using TWS with containers suggest the container itself should be disposable and can restart a fresh new one in some other point in the infrastructure asap, so all needed parameters would be set when the docker will respawn, or configured at docker building/starting time.

I think others users will found useful to have the Socket API option and continue using IBC.

At this point I have some solutions:

  1. Modify your code to include setting Socket API.
  2. Using a local tws.xml with all parameters pre-configured: socket, ports, etc with useRemoteSettings=false in jts.ini and update file before launching TWS.

Option 2 works but the only thing I would miss is the ability of controlling when an existing session is detect (ExistingSessionDetectedAction IBC's parameter) but on the other hand is faster and less resource consuming.

Thanks for your time.

xerges-crypto commented 3 years ago

Dear Richard,

I have found that you try to set this configuration when you try to set the ApiPort, that have sense, but ONLY try to activate the ""Enable ActiveX and Socket Clients"" check-button when TWS (server config) and IBC config don't match.

ConfigureTwsApiPortTask.java

Maybe you may consider to try to set this check-button every time a port is specified or designed by a new option in ibc.ini

Best regards.

rlktradewright commented 3 years ago

You don't need to 'store settings on server' for the settings to be preserved between sessions. The local tws.xml file always contains the current settings: storing on the server simply uploads this file to the IB account server when TWS exits.

The primary purpose of IBC is to automate various things that are inconvenient for a user who is not sitting in front of a TWS display, in other words to get TWS up and running and deal with various conditions with no user intervention. Whether the user is running an automated trading system is of no concern to IBC.

I run an automated system using IBC all day every trading day. There is nothing in IBC that prevents me doing that. I configured TWS in the way I need it years ago, and only very rarely have to change anything manually: usually because I need to connect a client program from a DHCP device that is not currently in the Trusted IPs list.

If you want to run it in Docker, you need to make provision in the Docker build to include the pre-configured TWS settings in the image, as you have observed in your post. If you want any changes in TWS during the Docker session to be preserved across Docker instantiations, then you'll need to make sure that the TWS settings directory is on some sort of persistent storage such as a bind- or volume-mount If you also store settings on the server, then any changes made during the TWS session in Docker - such as adding market data lines or charts - will be restored if you subsequently need to run TWS locally to create a new baseline configuration .

Why do you think that running in Docker prevents the use of ExistingSessionDetectedAction? It makes no difference to IBC whether it is running on a physical machine, in a virtual machine, or in Docker - if TWS displays the Existing Session Detected dialog, IBC will respond to it in accordance with the ExistingSessionDetectedAction setting.

I'm not going to change the way the OverrideTwsApiPort setting is implemented: it's called 'override' rather than 'set' because it's based on the assumption that you already have a properly configured and working TWS but (for some reason) you want to use a different API port for the current session.

rlktradewright commented 2 years ago

Closed due to lack of further input.

grantrosse commented 11 months ago

"If you want to run it in Docker, you need to make provision in the Docker build to include the pre-configured TWS settings in the image, as you have observed in your post. If you want any changes in TWS during the Docker session to be preserved across Docker instantiations, then you'll need to make sure that the TWS settings directory is on some sort of persistent storage such as a bind- or volume-mount If you also store settings on the server, then any changes made during the TWS session in Docker - such as adding market data lines or charts - will be restored if you subsequently need to run TWS locally to create a new baseline configuration." ^saved me, but I had to figure out which is the settings folder. Come to find out it's defined in the /root/Jts/jts.ini file.

paying it forward- here is the docker command I'm running: sudo docker run -d -v /ibc/ccgpgldepbhgmoncipijhphmkiaclafiofagjeaj:/root/Jts/ccgpgldepbhgmoncipijhphmkiaclafiofagjeaj:rw --restart unless-stopped -p 8080:8080 -p 5900:5900 -p 80:80 -p 7497:7497 tws

rlktradewright commented 11 months ago

@grantrosse

You need to be a bit careful here.

jts.ini doesn't always contain this information. For example if you shut down TWS/Gateway, then delete jts.ini and run IBC again, it will all work perfectly, and the newly created jts.ini won't contain it. I don't know offhand at what point TWS updates jts.ini to include it.

grantrosse commented 11 months ago

@rlktradewright understood- thanks for the heads up- will keep in mind if we try to automate grabbing the settings folder.