Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified resources/IBC.jar
Binary file not shown.
18 changes: 14 additions & 4 deletions resources/StartGateway.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ set TWS_MAJOR_VRSN=978
set CONFIG=%USERPROFILE%\Documents\IBC\config.ini
set TRADING_MODE=
set TWOFA_TIMEOUT_ACTION=exit
set IBC_PATH=%SYSTEMDRIVE%\IBC
set IBC_PATH=%~dp0.
set TWS_PATH=%SYSTEMDRIVE%\Jts
set TWS_SETTINGS_PATH=
set LOG_PATH=%IBC_PATH%\Logs
Expand All @@ -45,6 +45,7 @@ set FIXUSERID=
set FIXPASSWORD=
set JAVA_PATH=
set HIDE=
set PRESS_ANY_KEY_ON_ERROR=1


:: PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE !!
Expand Down Expand Up @@ -72,9 +73,9 @@ set HIDE=
:: This file should be in a folder in your personal filestore, so that
:: other users of your computer can't access it. This folder and its
:: contents should also be encrypted so that even users with administrator
:: privileges can't see the contents. Note that you can use the HOMEDRIVE and
:: HOMEPATH environment variables to address the root of your personal
:: filestore (they are set automatically by Windows).
:: privileges can't see the contents. Note that you can use the USERPROFILE
:: environment variable to address the root of your personal filestore
:: (they are set automatically by Windows).


:: TRADING_MODE
Expand Down Expand Up @@ -179,6 +180,15 @@ set HIDE=
:: this setting has no effect.)


:: PRESS_ANY_KEY_ON_ERROR
::
:: If set to 1, the diagnostic window will remain open and prompt user for
:: pressing any key in order to let them read error message. This behaviour
:: however is not desirable when the script runs in non-interactive mode
:: (e.g. when it is started by task scheduler). In such case please
:: set it to 0 or make it empty.


:: End of Notes:
::==============================================================================

Expand Down
18 changes: 14 additions & 4 deletions resources/StartTWS.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ set TWS_MAJOR_VRSN=978
set CONFIG=%USERPROFILE%\Documents\IBC\config.ini
set TRADING_MODE=
set TWOFA_TIMEOUT_ACTION=exit
set IBC_PATH=%SYSTEMDRIVE%\IBC
set IBC_PATH=%~dp0.
set TWS_PATH=%SYSTEMDRIVE%\Jts
set TWS_SETTINGS_PATH=
set LOG_PATH=%IBC_PATH%\Logs
set TWSUSERID=
set TWSPASSWORD=
set JAVA_PATH=
set HIDE=
set PRESS_ANY_KEY_ON_ERROR=1


:: PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE !!
Expand Down Expand Up @@ -60,9 +61,9 @@ set HIDE=
:: This file should be in a folder in your personal filestore, so that
:: other users of your computer can't access it. This folder and its
:: contents should also be encrypted so that even users with administrator
:: privileges can't see the contents. Note that you can use the HOMEDRIVE and
:: HOMEPATH environment variables to address the root of your personal
:: filestore (they are set automatically by Windows).
:: privileges can't see the contents. Note that you can use the USERPROFILE
:: environment variable to address the root of your personal filestore
:: (they are set automatically by Windows).


:: TRADING_MODE
Expand Down Expand Up @@ -157,6 +158,15 @@ set HIDE=
:: this setting has no effect.)


:: PRESS_ANY_KEY_ON_ERROR
::
:: If set to 1, the diagnostic window will remain open and prompt user for
:: pressing any key in order to let them read error message. This behaviour
:: however is not desirable when the script runs in non-interactive mode
:: (e.g. when it is started by task scheduler). In such case please
:: set it to 0 or make it empty.


:: End of Notes:
::==============================================================================

Expand Down
197 changes: 146 additions & 51 deletions resources/Stop.bat
Original file line number Diff line number Diff line change
@@ -1,51 +1,146 @@
@echo off

:: Sends a STOP command to the specified instance of IBC to cause it to
:: initiate a tidy closedown of TWS or Gateway.


:: You may need to change this line. Set it to the name or IP address of the
:: computer that is running IBC. Note that you can use the local loopback
:: address (127.0.0.1) if IBC is running on the current machine.

set ServerAddress=127.0.0.1


:: You may need to change this line. Make sure it's set to the value of the
:: CommandServerPort setting in config.ini:

set CommandServerPort=7462


:: You may need to change this line. Make sure it's set to the location of the
:: IBC files:

set IBC_PATH=%SYSTEMDRIVE%\IBC


:: IMPORTANT NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
:: ==============
::
:: The following uses the telnet utility, which is not enabled in
:: Windows 'out of the box'. To enable it, run the 'Programs and Features' applet in
:: Control Panel. Click the 'Turn Windows features on or off' link in the left hand
:: panel. Then locate the 'Telnet client' entry in the list of Windows features and
:: ensure the checkbox in the entry is ticked. Click 'OK' and Windows will
:: enable it. This command file should then run successfully.


:: You shouldn't need to change anything below this line.
::==============================================================================


:: open a telnet window with a session to IBC
set TITLE=Stop TWS or Gateway %RANDOM%%RANDOM%%RANDOM%
start "%TITLE%" telnet %ServerAddress% %CommandServerPort%

:: send the required command to IBC
cscript %IBC_PATH%\Scripts\SendStopCommand.vbs "%TITLE%"


:: Acknowledgement: many thanks for the help contained in Mukul Goel's answer to this question at:
:: http://stackoverflow.com/questions/13197376/is-it-possible-to-use-a-batch-file-to-establish-a-telnet-session-send-a-command

@echo off
setlocal enableextensions enabledelayedexpansion


::=============================================================================+
:: +
:: Stops Interactive Brokers' IB Gateway or Trader Workstation (TWS). +
:: +
::=============================================================================+


set TWS_MAJOR_VRSN=978
set CONFIG=%USERPROFILE%\Documents\IBC\config.ini
set TRADING_MODE=
set TWOFA_TIMEOUT_ACTION=exit
set IBC_PATH=%~dp0.
set TWS_PATH=%SYSTEMDRIVE%\Jts
set TWS_SETTINGS_PATH=
set LOG_PATH=%IBC_PATH%\Logs
set TWSUSERID=
set TWSPASSWORD=
set FIXUSERID=
set FIXPASSWORD=
set JAVA_PATH=
set HIDE=
set PRESS_ANY_KEY_ON_ERROR=1


:: PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE !!
::==============================================================================

:: Notes:
::

:: TWS_MAJOR_VRSN
::
:: Specifies the major version number of Gateway to be run. If you are
:: unsure of which version number to use, run the Gateway manually from the
:: icon on the desktop, then click Help > About IB Gateway. In the
:: displayed information you'll see a line similar to this:
::
:: Build 954.2a, Oct 30, 2015 4:07:54 PM
::
:: Here the major version number is 954. Do not include the rest of the
:: version number in this setting.


:: CONFIG
::
:: This is the location and filename of the IBC configuration file.
:: This file should be in a folder in your personal filestore, so that
:: other users of your computer can't access it. This folder and its
:: contents should also be encrypted so that even users with administrator
:: privileges can't see the contents. Note that you can use the USERPROFILE
:: environment variable to address the root of your personal filestore
:: (they are set automatically by Windows).


:: IBC_PATH
::
:: The folder containing the IBC files.


:: TWS_PATH
::
:: The folder where TWS is installed. The TWS installer always installs to
:: C:\Jts. Note that even if you have installed from a Gateway download
:: rather than a TWS download, you should still use this default setting.
:: It is possible to move the TWS installation to a different folder, but
:: there are virtually no good reasons for doing so.


:: TWS_SETTINGS_PATH
::
:: The folder where TWS is to store its settings. This setting is ignored
:: if the IbDir setting in the configuration file is specified. If no value
:: is specified in either place, the settings are stored in the TWS_PATH
:: folder.


:: LOG_PATH
::
:: Specifies the folder where diagnostic information is to be logged while
:: this command file is running. This information is very valuable when
:: troubleshooting problems, so it is advisable to always have this set to
:: a valid location, especially when setting up IBC. You must
:: have write access to the specified folder.
::
:: Once everything runs properly, you can prevent further logging by
:: removing the value as show below (but this is not recommended):
::
:: set LOG_PATH=


:: JAVA_PATH
::
:: IB's installer for TWS/Gateway includes a hidden version of Java which
:: IB have used to develop and test that particular version. This means that
:: it is not necessary to separately install Java. If there is a separate
:: Java installation, that does not matter: it won't be used by IBC
:: or TWS/Gateway unless you set the path to it here. You should not do this
:: without a very good reason.


:: HIDE
::
:: If set to YES or TRUE, the diagnostic window that contains information
:: about the running TWS, and where to find the log file, will be minimized
:: to the taskbar. If not set, or set to any other value, the window will be
:: displayed. Values are not case-sensitive so for example yEs and yes will
:: be interpeted as YES. (Note that when the /INLINE argument is supplied,
:: this setting has no effect.)


:: PRESS_ANY_KEY_ON_ERROR
::
:: If set to 1, the diagnostic window will remain open and prompt user for
:: pressing any key in order to let them read error message. This behaviour
:: however is not desirable when the script runs in non-interactive mode
:: (e.g. when it is started by task scheduler). In such case please
:: set it to 0 or make it empty.


:: End of Notes:
::==============================================================================

set APP=STOP
set TITLE=IBC (%APP% %TWS_MAJOR_VRSN%)
if /I "%HIDE%" == "YES" (
set MIN=/Min
) else if /I "%HIDE%" == "TRUE" (
set MIN=/Min
) else (
set MIN=
)

id /

if /I "%~1" == "/INLINE" (
set INLINE=1
"%IBC_PATH%\scripts\DisplayBannerAndLaunch.bat" %~2
) else (
set INLINE=0
start "%TITLE%" %MIN% "%IBC_PATH%\scripts\DisplayBannerAndLaunch.bat" %~1
)
exit /B
7 changes: 5 additions & 2 deletions resources/scripts/DisplayBannerAndLaunch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ echo +

set GW_FLAG=
if /I "%APP%" == "GATEWAY" set GW_FLAG=/G
if /I "%APP%" == "STOP" set GW_FLAG=/STOP

set PHASE=Running StartIBC.bat
set ERROR_MESSAGE=
Expand Down Expand Up @@ -147,8 +148,10 @@ if defined LOG_FILE (
echo +
echo +==============================================================================
echo +
echo + Press any key to close this window
pause > NUL
if "%PRESS_ANY_KEY_ON_ERROR%" == "1" (
echo + Press any key to close this window
pause > NUL
)
echo +
if "%INLINE%" == "1" exit /B
exit
Expand Down
20 changes: 0 additions & 20 deletions resources/scripts/SendStopCommand.vbs

This file was deleted.

Loading