Please go through the code and understand what you are trying to implement. You need to look into the ticker usage code. These examples are meant to demonstrate usage, not just copy-paste.
Thanks sujit, I am trying to get Nifty updates from ticker have seen that the Instrument token is 256265
this is the listener that I am expecting to call back @RequestMapping(path = "/monitor", produces = "application/json; charset=UTF-8", method = RequestMethod.GET) @ResponseBody public void monitorCondor() throws WebSocketException, IOException, KiteException { KiteConnect kiteConnect = new KiteConnect("xxxx"); kiteConnect.setAccessToken("xxxx"); kiteConnect.setPublicToken("xxxx"); ArrayList tokens = new ArrayList<>(); tokens.add(Long.parseLong("256265")); tickerUsage(kiteConnect, tokens);
We are expecting this listener to be invoked for every updates ... We are calling this API in 1 minute interval time to get 1-minute updates. Please let me know is that right?
These examples are meant to demonstrate usage, not just copy-paste.
this is the listener that I am expecting to call back
@RequestMapping(path = "/monitor", produces = "application/json; charset=UTF-8", method = RequestMethod.GET)
@ResponseBody
public void monitorCondor() throws WebSocketException, IOException, KiteException {
KiteConnect kiteConnect = new KiteConnect("xxxx");
kiteConnect.setAccessToken("xxxx");
kiteConnect.setPublicToken("xxxx");
ArrayList tokens = new ArrayList<>();
tokens.add(Long.parseLong("256265"));
tickerUsage(kiteConnect, tokens);
}
public void tickerUsage(KiteConnect kiteConnect, ArrayList tokens) throws IOException, WebSocketException, KiteException {
tickerProvider.setOnTickerArrivalListener(new OnTicks() {
@Override
public void onTicks(ArrayList ticks) {
NumberFormat formatter = new DecimalFormat();
System.out.println("ticks size "+ticks.size());
if(ticks.size() > 0) {
System.out.println("open::"+ticks.get(0).getOpenPrice());
System.out.println("close::"+ticks.get(0).getClosePrice());
System.out.println("high::"+ticks.get(0).getHighPrice());
System.out.println("low::"+ticks.get(0).getLowPrice());
}
}
});
}
We are expecting this listener to be invoked for every updates ...
We are calling this API in 1 minute interval time to get 1-minute updates. Please let me know is that right?
// Unsubscribe for a token.
tickerProvider.unsubscribe(tokens);
// After using com.zerodhatech.com.zerodhatech.ticker, close websocket connection.
tickerProvider.disconnect();
these 2 lines are the ones ... anyways thanks for looking into it.