I'm getting a list of data from Binance that returns a response, how do I access the values of the response body?
private Closeable candleStick(){
BinanceApiWebSocketClient client = BinanceApiClientFactory.newInstance().newWebSocketClient();
return client.onCandlestickEvent("btcusdt", CandlestickInterval.FIVE_MINUTES, new BinanceApiCallback<com.binance.api.client.domain.event.CandlestickEvent>() {
@Override
public void onResponse(com.binance.api.client.domain.event.CandlestickEvent response) {
System.out.println(response);
}
});
}
The response has values like response.getHigh(), response.getLow(), etc. How do I access these values in another method. It
private String show() throws IOException {
Double high = candleStick().getHigh() //didn't work as the method returns a closeable object.
}
It's a callback based API, so instead of your System.out.println(...) you should update some data structure in your app to add/show the new values.
Just a simple example:
So somewhere else in your app where you want to get access to the data:
and then whenever you want to see the data