It looks like you're new here. If you want to get involved, click one of these buttons!
public void tickerUsage(KiteConnect kiteConnect, final ArrayList<Long> tokens) throws IOException, WebSocketException, KiteException {
final KiteTicker tickerProvider = new KiteTicker(kiteConnect);
tickerProvider.setOnConnectedListener(new OnConnect() {
@Override
public void onConnected() {
try {
tickerProvider.subscribe(tokens);
tickerProvider.setMode(tokens, KiteTicker.modeFull);
} catch (IOException e) {
e.printStackTrace();
} catch (WebSocketException e) {
e.printStackTrace();
}catch (KiteException ke){
ke.printStackTrace();
}
}
});
tickerProvider.setOnTickerArrivalListener(new OnTick() {
@Override
public void onTick(ArrayList<Tick> ticks) {
//Parsing tick
for (Tick obj:ticks) {
System.out.println("TKN : "+obj.getToken()+"\tO:"+obj.getOpenPrice()+"\tH:"+obj. getHighPrice()+"\tL:"+obj.getLowPrice()+" \tC:"+obj.getClosePrice()+"\tLTP:"+obj.getLastTradedPrice()+"\tLTQ"+obj.getLastTradedQuantity()+"\tPRC_CHNG"+obj.getNetPriceChangeFromClosingPrice());
java.util.Map<java.lang.String,java.util.ArrayList<Depth>> d = obj.getMarketDepth();
String buy = "buy";
String sell = "sell";
int buy_d1 = d.get(buy).get(0).getOrders();
int buy_d2 = d.get(buy).get(1).getOrders();
int buy_d3 = d.get(buy).get(2).getOrders();
int buy_d4 = d.get(buy).get(3).getOrders();
int buy_d5 = d.get(buy).get(4).getOrders();
double buy_p1 = d.get(buy).get(0).getPrice();
double buy_p2 = d.get(buy).get(1).getPrice();
double buy_p3 = d.get(buy).get(2).getPrice();
double buy_p4 = d.get(buy).get(3).getPrice();
double buy_p5 = d.get(buy).get(4).getPrice();
int sell_d1 = d.get(sell).get(0).getOrders();
int sell_d2 = d.get(sell).get(1).getOrders();
int sell_d3 = d.get(sell).get(2).getOrders();
int sell_d4 = d.get(sell).get(3).getOrders();
int sell_d5 = d.get(sell).get(4).getOrders();
double sell_p1 = d.get(sell).get(0).getPrice();
double sell_p2 = d.get(sell).get(1).getPrice();
double sell_p3 = d.get(sell).get(2).getPrice();
double sell_p4 = d.get(sell).get(3).getPrice();
double sell_p5 = d.get(sell).get(4).getPrice();
System.out.println("BUY Depth : "+buy_d1+":"+buy_p1+","+buy_d2+":"+buy_p2+","+buy_d3+":"+buy_p3+","+buy_d4+":"+buy_p4+","+buy_d5+":"+buy_p5);
System.out.println("SELL Depth : "+sell_d1+":"+sell_p1+","+sell_d2+":"+sell_p2+","+sell_d3+":"+sell_p3+","+sell_d4+":"+sell_p4+","+sell_d5+":"+sell_p5);
}
}
});
tickerProvider.setTryReconnection(true);
tickerProvider.setTimeIntervalForReconnection(5);
tickerProvider.setMaxRetries(10);
tickerProvider.connect();
//boolean isConnected = tickerProvider.isConnectionOpen();
//System.out.println(isConnected);
tickerProvider.setMode(tokens, KiteTicker.modeFull);
//tickerProvider.unsubscribe(tokens);
//tickerProvider.disconnect();
}
last price 10384.5
open interest 14,336,025
day high OI 17,676,900
day low OI 14,324,325
change -0.081
tick timestamp Thu Feb 22 15:30:00 IST 2018
tick timestamp date Thu Feb 22 15:30:00 IST 2018
Looks like its pointing to a wrong price server ?
Please advise when you get a chance.
The token is for Feb NIFTY FUT contract..that's the reason for the timestamp.
Thanks for your help.