Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void placeFuturesOrder() {
InteractiveBrokersClientInterface ibClient = InteractiveBrokersClient.getInstance("localhost", 7999, 1);
ibClient.connect();
//Create a crude oil futures ticker
FuturesTicker futuresTicker = new FuturesTicker();
futuresTicker.setSymbol("CL");
futuresTicker.setExpiryMonth(4);
futuresTicker.setExpiryYear(2016);
futuresTicker.setExchange(Exchange.NYMEX);
String orderId = ibClient.getNextOrderId();
int contracts = 5;
//Create the order and send to Interactive Brokers
TradeOrder order = new TradeOrder(orderId, futuresTicker, contracts, TradeDirection.BUY);
order.setType(TradeOrder.Type.LIMIT);
order.setLimitPrice(32.50);
ibClient.placeOrder(order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment