I tried by adding token for BankNifty like below: But when I executed a trade in Terminal, it didn't reflect in the orderUpdateBlock:
ArrayList tokens = new ArrayList(); tokens.add(26009L);
KiteTicker tickerProvider = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey()); tickerProvider.setOnConnectedListener(new OnConnect() { @Override public void onConnected() { /** Subscribe ticks for token. * By default, all tokens are subscribed for modeQuote. * */ tickerProvider.subscribe(tokens); tickerProvider.setMode(tokens, KiteTicker.modeFull); } });
/** Set listener to get order updates.*/ tickerProvider.setOnOrderUpdateListener(new OnOrderUpdate() { @Override public void onOrderUpdate(Order order) { System.out.println("Yes !!!!!!!! order Details"); System.out.println("order Id "+order.orderId); System.out.println("order filled qty "+order.filledQuantity); System.out.println("order qty "+order.quantity); System.out.println("order price "+order.price); System.out.println("order trading symbol "+order.tradingSymbol); } });
You will not get order update for placing an order. It is only sent when there is a partial fill or it is modified or trigger is hit or when it gets executed.
ArrayList tokens = new ArrayList();
tokens.add(26009L);
KiteTicker tickerProvider = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey());
tickerProvider.setOnConnectedListener(new OnConnect() {
@Override
public void onConnected() {
/** Subscribe ticks for token.
* By default, all tokens are subscribed for modeQuote.
* */
tickerProvider.subscribe(tokens);
tickerProvider.setMode(tokens, KiteTicker.modeFull);
}
});
/** Set listener to get order updates.*/
tickerProvider.setOnOrderUpdateListener(new OnOrderUpdate() {
@Override
public void onOrderUpdate(Order order) {
System.out.println("Yes !!!!!!!! order Details");
System.out.println("order Id "+order.orderId);
System.out.println("order filled qty "+order.filledQuantity);
System.out.println("order qty "+order.quantity);
System.out.println("order price "+order.price);
System.out.println("order trading symbol "+order.tradingSymbol);
}
});