My TBG-Quant Strategy now connects to IB, but I dont think I'm successfully getting data.
Because its the weekend I created a test strategy to just get realtime EUR data and see if it triggers the onEvent method.
If I use the IB Java Test Client I am able to get EUR data. I press the Req Mkt Data Button and then in the Contract Sub Panel I fill in Symbol = EUR, security type = CASH, Exchange = IDEALPRO, and Currency = USD. I then hit OK and I gte real time data displaying in the Market and Historical Data Window.
Now if I go to my Strategy I create a Security with the same values, and when I run the STrategy it connects to IB but I do not get the onEvent method to trigger.
The Class code is below for your reference. Am I doing something wrong? Thanks for your help.
public class EURStrategyTest extends TradingSystem implements IStrategy {
/**
* Sets Account
*/
private final IBAccount account = new IBAccount();
{
account.setAccountID("Paper Account");
account.setAccountCurrency(Currency.USD);
}
private final InteractiveBrokersAdapter interactiveBrokersAdapter = new InteractiveBrokersAdapter();
{
// settings for IB Gateway/TWS Connection
interactiveBrokersAdapter.setTWS_PORT(7496); // TWS Client
//interactiveBrokersAdapter.setTWS_PORT(4001); // IBGateway
interactiveBrokersAdapter.setTWS_HOST("127.0.0.1");
}
private final IBroker broker = new IBBroker(account, interactiveBrokersAdapter);
/**
* Sets the marketDataFeeder
*/
private final IBMarketDataFeed marketDataFeed = new IBMarketDataFeed(interactiveBrokersAdapter);
{
marketDataFeed.setDebug(true);
marketDataFeed.connectToMarketFeed();
}
/**
* Setting the report service, by default prints report to the output.
*/
private final IReportService reportService = new TextReportService();
/**
* Sets the VXX security
*/
private final Security securityEUR = new Security();
{
securityEUR.setSecurityType(SecurityType.CASH);
securityEUR.setExchange("IDEALPRO");
securityEUR.setCurrency(Currency.USD);
}
/**
* Sets the System and services
*/
public EURStrategyTest() {
setTradingSystemName("EUR Strategy");
setBroker(broker);
setMarketDataFeed(marketDataFeed);
setReportService(reportService);
this.subscribeSecurity(securityEUR);
setReportService(reportService);
}
@Override
public void onStart() {
}
@Override
public void onStop() {
}
@Override
public void onEvent(Object event) {
log.info("onEvent(): "+event.toString());
}
@Override
public void onError(Messages msg) {
log.error(msg.toString());
}
/**
* Start it up!
*/
public static void main(String[] args) {
new EURStrategyTest().start();
}
}