Capture last traded price when there is any change in last traded price ONLY

jkoracle23
jkoracle23 edited February 2019 in Java client
Hello,
My requirement is that I need to collect last traded price only when it changes.
I used ticker below but it tick.size>0 happens for other parameters as well like (
ticks.get(i).getMarketDepth().get("buy").get(j).getQuantity();
ticks.get(i).getMarketDepth().get("buy").get(j).getOrders();
) etc

Is there any way where I will get notification ONLY when last traded price changes and not because of other items change??
tickerProvider.setOnTickerArrivalListener(new OnTicks() {
@Override
public void onTicks(ArrayList<Tick> ticks) {
NumberFormat formatter = new DecimalFormat();
System.out.println("ticks size "+ticks.size());
if(ticks.size() > 0) {
System.out.println("last price "+ticks.get(0).getLastTradedPrice());
System.out.println("open interest "+formatter.format(ticks.get(0).getOi()));
System.out.println("day high OI "+formatter.format(ticks.get(0).getOpenInterestDayHigh()));
System.out.println("day low OI "+formatter.format(ticks.get(0).getOpenInterestDayLow()));
System.out.println("change "+formatter.format(ticks.get(0).getChange()));
System.out.println("tick timestamp "+ticks.get(0).getTickTimestamp());
System.out.println("tick timestamp date "+ticks.get(0).getTickTimestamp());
System.out.println("last traded time "+ticks.get(0).getLastTradedTime());
System.out.println(ticks.get(0).getMarketDepth().get("buy").size());
}
}
});
Tagged:
  • jkoracle23
    @sujith -Would be greatful if you could suggest any solution.
  • rakeshr
    @jkoracle23
    You can try storing previous ltp in local variable and then use condition to alert, if current feed last traded price is not equal to previous stored ltp, in the same loop you can keep swapping ltp local variable with the latest one.
  • sujith
    @jkoracle23,
    You may try setting mode to modeLTP.
  • sujith
    You will receive ticks only when there is an ltp change.
  • algobulls
    Dear sir

    We can help you out with your above query, It is very much possible in our platform with more customizable options

    Kindly contact: [email protected]
    Call : +91 8291474939/ +91 8879647666
    Website : www.algobulls.com

    Dear sir

    We can help you out with the Automatic Algorithm software with more customizable options also access set your own strategy and of our clients who are ready to share there strategy

    Kindly contact: [email protected]

    Call : +91 8291474939/ +91 8879647666
    Website : www.algobulls.com
  • jkoracle23
    Please close this thread . As suggested by Sujith , I used previous ltp for comparison.
This discussion has been closed.