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

Using environment in config.ini #247

Open jackhui123 opened 9 months ago

jackhui123 commented 9 months ago

Can I use environment in config.ini like,

bLoginId=${IB_LOGIN_ID} IbPassword=${IB_LOGIN_PASSWORD} TradingMode=${IB_TRADING_MODE}

As I am building a docker container to run it, so DEV and PROD environments should be the same image. The config.ini should be the same.

rlktradewright commented 9 months ago

No, you can't do this.

I see no value in it, given the amount of work that would be required to develop it.

Also I fundamentally disagree that 'DEV and PROD environments should be the same image': that might be what you want, but there is reason to expect this to be generally true. My live and paper-trading setups are quite different.

I'm always open to being persuaded that a suggestion has significant merit, so feel free to try, but at this stage I'd say you're not likely to succeed.

jackhui123 commented 9 months ago

Thanks for the response. It seems the parameters can be passed into the script. I am now trying to resolve with .env file in compose.yaml

The script is calling like that,

/app/ibc/scripts/ibcstart.sh "${TWS_MAJOR_VRSN}" -g \ "--tws-path=${TWS_PATH}" \ "--ibc-path=${IBC_PATH}" "--ibc-ini=${IBC_INI}" \ "--user=${IB_LOGIN_ID}" "--pw=${IB_LOGIN_PASSWORD}" "--mode=${IB_TRADING_MODE}" \ "--on2fatimeout=${TWOFA_TIMEOUT_ACTION}"

However, now I have another issue with "autorestart file not found". Any idea?


compose.yaml.txt Dockerfile.txt

================================================================================ 2023-12-27 19:37:08 2023-12-27 19:37:08 Starting IBC version on 2023-12-27 at 11:37:08 2023-12-27 19:37:08 2023-12-27 19:37:08 Operating system: Linux aaee767ea3c3 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux 2023-12-27 19:37:08 2023-12-27 19:37:08 Arguments: 2023-12-27 19:37:08 2023-12-27 19:37:08 TWS version = 1019.2h 2023-12-27 19:37:08 Program = Gateway 2023-12-27 19:37:08 Entry point = ibcalpha.ibc.IbcGateway 2023-12-27 19:37:08 --tws-path = /app/Jts 2023-12-27 19:37:08 --tws-settings-path = 2023-12-27 19:37:08 --ibc-path = /app/ibc 2023-12-27 19:37:08 --ibc-ini = /app/ibc/config.ini 2023-12-27 19:37:08 --mode = paper 2023-12-27 19:37:08 --java-path = 2023-12-27 19:37:08 --user = 2023-12-27 19:37:08 --pw = 2023-12-27 19:37:08 --fix-user = 2023-12-27 19:37:08 --fix-pw = 2023-12-27 19:37:08 2023-12-27 19:37:08 ================================= 2023-12-27 19:37:08 Generating the classpath 2023-12-27 19:37:08 Classpath=/app/Jts/ibgateway/1019.2h/jars/jackson-core-2.12.3.jar:/app/Jts/ibgateway/1019.2h/jars/jts4launch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-linux64-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-swing-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/locales.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-api-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-core-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/total-2020.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-install4j-1.12.jar:/app/Jts/ibgateway/1019.2h/.install4j/i4jruntime.jar:/app/ibc/IBC.jar 2023-12-27 19:37:08 2023-12-27 19:37:08 Generating the JAVA VM options 2023-12-27 19:37:08 autorestart file not found 2023-12-27 19:37:08 -Dtwslaunch.autoupdate.serviceImpl=com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService -Dchannel=latest -Dexe4j.isInstall4j=true -Dinstall4jType=standalone -DjtsConfigDir=/app/Jts 2023-12-27 19:37:08 2023-12-27 19:37:08 Determining the location of java executable 2023-12-27 19:37:08 Location of java executable=/usr/local/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/bin 2023-12-27 19:37:08 2023-12-27 19:37:08 Renaming IB's TWS or Gateway start script to prevent restart without IBC 2023-12-27 19:37:08 2023-12-27 19:37:08 Starting Gateway with this command: 2023-12-27 19:37:08 "/usr/local/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/bin/java" -cp "/app/Jts/ibgateway/1019.2h/jars/jackson-core-2.12.3.jar:/app/Jts/ibgateway/1019.2h/jars/jts4launch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-linux64-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-swing-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/locales.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-api-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-core-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/total-2020.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-install4j-1.12.jar:/app/Jts -Dtwslaunch.autoupdate.serviceImpl=com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService -Dchannel=latest -Dexe4j.isInstall4j=true -Dinstall4jType=standalone -DjtsConfigDir=/app/Jts ibcalpha.ibc.IbcGateway "/app/ibc/config.ini" paper 2023-12-27 19:37:08 2023-12-27 19:37:08 IBC returned exit status 1 2023-12-27 19:37:08 autorestart file not found 2023-12-27 19:37:08 2023-12-27 19:37:08 Gateway finished 2023-12-27 19:37:08 2023-12-27 19:37:08 Error: Could not find or load main class

rlktradewright commented 9 months ago

[Please in future attach logiles rather than quoting them inline: it makes my life easier, and the post is then less cluttered.]

"autorestart file not found" is not an issue. It's a simple statement of fact. If it were found IBC would do somthing different, because it would mean that an auto-restart is in progress.

And if it were a problem then the logfile would make very plain that it's an error.

The actual problem is recorded in the last line of the logfile: it's not able to find the IBC main entrypoint. The classpath correctly specifies that it is at /app/ibc/IBC.jar

But the command shown after 'Starting Gateway with this command:' is incorrect. The classpath has been truncated and elided with the Java VM options.

Here's what it should say (I've bolded the bit that's missing):

2023-12-27 19:37:08 Starting Gateway with this command: 2023-12-27 19:37:08 "/usr/local/i4j_jres/Oda-jK0QgTEmVssfllLP/1.8.0_202/bin/java" -cp "/app/Jts/ibgateway/1019.2h/jars/jackson-core-2.12.3.jar:/app/Jts/ibgateway/1019.2h/jars/jts4launch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-linux64-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/jxbrowser-swing-7.26.jar:/app/Jts/ibgateway/1019.2h/jars/locales.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-api-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/log4j-core-2.17.1.jar:/app/Jts/ibgateway/1019.2h/jars/total-2020.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-1019.jar:/app/Jts/ibgateway/1019.2h/jars/twslaunch-install4j-1.12.jar:/app/Jts /ibgateway/1019.2h/.install4j/i4jruntime.jar:/app/ibc/IBC.jar" -Dtwslaunch.autoupdate.serviceImpl=com.ib.tws.twslaunch.install4j.Install4jAutoUpdateService -Dchannel=latest -Dexe4j.isInstall4j=true -Dinstall4jType=standalone -DjtsConfigDir=/app/Jts ibcalpha.ibc.IbcGateway "/app/ibc/config.ini" paper

This is not possible with the ibcstart.sh script in the IBC download zip. So have you modified this script for some reason?

jackhui123 commented 9 months ago

Thanks Richard,

It seems working now.

No, I haven't modified the IBC code, and even I haven't downloaded it, but just built into the container image with IB Gateway together.

I think the issue is in config.ini, I put ibDir=/app/Jts, so I changed it to /app/Jts/ibgateway. In ibgateway.vmoptions, I commented out the installer.uuid line, not sure what it is using for

-Dinstaller.uuid=dc71edfa-a1bb-4c1e-a0d9-9bac192054cd