retrieve real-time data from JBloomberg API

244 views Asked by At

I want to retrieve the time and the real-time last Price as double instead of having an output like

DataChangeEvent{ESA Index,ASK_SIZE: 204==>192}

from the code below

DataChangeListener lst = new DataChangeListener() {
 @Override
 public void dataChanged(DataChangeEvent e) {
     System.out.println(e);
 }
};


SubscriptionBuilder builder = new SubscriptionBuilder()
     .addSecurity("ESA Index")
     .addField(RealtimeField.LAST_PRICE)
     .addField(RealtimeField.ASK)
     .addField(RealtimeField.ASK_SIZE)
     .addListener(lst);
session.subscribe(builder);


Thread.sleep(3000);
1

There are 1 answers

0
assylias On BEST ANSWER

Just saw your question so it's probably a little late - but here it is anyway. DataChangeEvent contains the ticker, the field, the new and old price:

DataChangeListener lst = new DataChangeListener() {
     @Override public void dataChanged(DataChangeEvent e) {
         String ticker = e.getSource();
         String field = e.getDataName();
         double oldValue = e.getOldValue().asDouble();
         double newValue = e.getNewValue().asDouble();
     }
};