This is a fork of Richard King's IBC project, simplified, customized, and enhanced for QuantRocket. General users should utilize the source repository, not this one.
This fork utilizes Java Agent Mode, which was developed in another fork, @docker-tws/IBC. Many thanks to these upstream repositories.
IBC can run using the Java Instrumentation API. In this mode, the
tws.vmoptions
or ibgateway.vmoptions
file is updated to include a new
parameter. This parameter tells Java to load IBC early during the regular TWS
or Gateway startup process. With the .vmoptions
parameter present, any
attempt to start TWS or Gateway using normal entry points (.exe
program file
or desktop icons) will cause IBC to be transparently loaded.
The primary advantage of Agent mode is no changes are made to how TWS or Gateway is started, permitting its auto-restart functionality to operate correctly. With auto-restart, TWS automatically restarts itself each day rather than logging off, requiring manual two-factor authentication only once per week, on Sundays. This vastly increases the time between manual interventions for a 2FA-enabled account running under IBC.
-
Locate
tws.vmoptions
oribgateway.vmoptions
by following the Interactive Brokers documentation. -
Add the line:
-javaagent:/path/to/IBC.jar
(UNIX) or-javaagent:C:\\IBC\\IBC.jar
, using the complete path to the IBC jar included in the release download. -
You may specify space-separated IBC command line parameters, by placing an
=
(equals) sign after the Jar path, then writing the parameters.
-
No parameters
-
<iniFile> [<tradingMode>]
-
<iniFile> <apiUserName> <apiPassword> [<tradingMode>]
-
<iniFile> <fixUserName> <fixPassword> <apiUserName> <apiPassword> [<tradingMode>]
Where:
<iniFile> ::= NULL | path-and-filename-of-.ini-file
<tradingMode> ::= blank | live | paper
<apiUserName> ::= blank | username-for-TWS
<apiPassword> ::= blank | password-for-TWS
<fixUserName> ::= blank | username-for-FIX-CTCI-Gateway
<fixPassword> ::= blank | password-for-FIX-CTCI-Gateway
Load IBC from C:\IBC\IBC.jar
, and use C:\IBC\live.ini
for the INI file:
-javaagent:C:\\IBC\\IBC.jar=C:\\IBC\\live.ini
As above, but login with paper trading:
-javaagent:C:\\IBC\\IBC.jar=C:\\IBC\\live.ini PAPERTRADING
Environment variables ${...}
can be used to specify trading mode and api or FIX credentials:
-javaagent:/path/to/IBC.jar=/path/to/config.ini ${TWSUSERID} ${TWSPASSWORD} ${TRADING_MODE}
The command server reads newline-terminated requests and writes newline-terminated replies.
Valid requests:
EXIT
: gracefully terminate the connection to the command serverSTOP
: graefully terminate TWSENABLEAPI [enable-remote-connections] [disable-readonly-api]
: Enable the TWS API in TWS settings. Ifenable-remote-connections
is specified, disable requirement for API connections to come fromlocalhost
. Ifdisable-readonly-api
is specified, allow API clients to trade.RECONNECTDATA
: send CTRL-ALT-F key sequence to TWS, causing it to restart its connections to streaming data servers.RECONNECTACCOUNT
: send CTRL-ALT-R key sequence to TWS, causing it to restart its connections to the account server.SECURITYCODE <code>
: enter the two-factor authentication security code, if the dialog is visible.
Responses:
INFO ...
: some informational noticeOK ...
: the last request completed successfullyERROR ...
: the last request failed
IBC is licensed under the GNU General Public License version 3.