1

我想检索时间和实时最后价格作为双倍而不是像这样的输出

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

从下面的代码

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);
4

1 回答 1

1

刚刚看到你的问题,所以可能有点晚了 - 但无论如何它都在这里。DataChangeEvent包含代码、字段、新旧价格:

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();
     }
};
于 2013-10-25T14:34:39.440 回答