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
14 changes: 10 additions & 4 deletions src/ibcalpha/ibc/AbstractLoginHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JToggleButton;

public abstract class AbstractLoginHandler implements WindowHandler {

Expand Down Expand Up @@ -157,6 +158,7 @@ private JButton findLoginButton(final Window window) {
JButton b = SwingUtils.findButton(window, "Login");
if (b == null) b = SwingUtils.findButton(window, "Log In");
if (b == null) b = SwingUtils.findButton(window, "Paper Log In");
if (b == null) b = SwingUtils.findButton(window, "Paper-Login"); // Gateway 1037+ (hyphenated)
return b;
}

Expand All @@ -174,14 +176,18 @@ protected final void setCredential(final Window window,
protected final boolean setTradingMode(final Window window) {
String tradingMode = TradingModeManager.tradingModeManager().getTradingMode();

if (SwingUtils.findToggleButton(window, "Live Trading") != null &&
SwingUtils.findToggleButton(window, "Paper Trading") != null) {
// Gateway 1037+ uses hyphenated names; older Gateway/TWS uses space-separated.
JToggleButton liveBtn = SwingUtils.findToggleButton(window, "Live Trading");
if (liveBtn == null) liveBtn = SwingUtils.findToggleButton(window, "Live-Trading");
JToggleButton paperBtn = SwingUtils.findToggleButton(window, "Paper Trading");
if (paperBtn == null) paperBtn = SwingUtils.findToggleButton(window, "Paper-Trading");
if (liveBtn != null && paperBtn != null) {
// TWS 974 onwards uses toggle buttons rather than a combo box
Utils.logToConsole("Setting Trading mode = " + tradingMode);
if (tradingMode.equalsIgnoreCase(TradingModeManager.TRADING_MODE_LIVE)) {
SwingUtils.findToggleButton(window, "Live Trading").doClick();
liveBtn.doClick();
} else {
SwingUtils.findToggleButton(window, "Paper Trading").doClick();
paperBtn.doClick();
}
return true;
} else {
Expand Down
7 changes: 5 additions & 2 deletions src/ibcalpha/ibc/GatewayLoginFrameHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public boolean recogniseWindow(Window window) {
if (! (window instanceof JFrame)) return false;

return ((SwingUtils.titleContains(window, "IBKR Gateway") ||
SwingUtils.titleContains(window, "IB Gateway") ||
SwingUtils.titleContains(window, "IBKR-Gateway") || // Gateway 1037+
SwingUtils.titleContains(window, "IB Gateway") ||
SwingUtils.titleContains(window, "Interactive Brokers Gateway")) &&
(SwingUtils.findButton(window, "Login") != null ||
SwingUtils.findButton(window, "Log In") != null || // TWS 974+
SwingUtils.findButton(window, "Paper Log In") != null)); // TWS 974+
SwingUtils.findButton(window, "Paper Log In") != null || // TWS 974+
SwingUtils.findButton(window, "Paper-Login") != null)); // Gateway 1037+ (hyphenated)
}

@Override
Expand Down Expand Up @@ -119,6 +121,7 @@ private void selectGatewayMode(Window window) throws IbcException {

private void switchToFIX(Window window) throws IbcException {
JToggleButton button = SwingUtils.findToggleButton(window, "FIX CTCI");
if (button == null) button = SwingUtils.findToggleButton(window, "FIX-CTCI"); // Gateway 1037+
if (button == null) throw new IbcException("FIX CTCI selector");

if (! button.isSelected()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public void handleWindow(Window window, int eventID) {
public boolean recogniseWindow(Window window) {
if (! (window instanceof JDialog)) return false;

return ((SwingUtils.titleContains(window, "IBKR Trader Workstation")
return ((SwingUtils.titleContains(window, "IBKR Trader Workstation")
||
SwingUtils.titleContains(window, "IBKR Gateway"))
&&
SwingUtils.titleContains(window, "IBKR Gateway")
||
SwingUtils.titleContains(window, "IBKR-Gateway")) // Gateway 1037+
&&
(SwingUtils.findLabel(window, "Are you sure you want to execute \"simulate") != null)
);
}
Expand Down