if (args == null || args.length < 3) {
throw new RuntimeException("Bad arguments passed to main");
}
final Marketplace feed = new BarchartMarketplace(args[0], args[1]);
final MarketObserver<Market> observer = new MarketObserver<Market>() {
@Override
public void onNext(Market value) {
final StringBuilder sb = new StringBuilder(value.instrument().marketGUID())
.append(" ")
.append(" EventTime=")
.append(value.updated());
final Top top = value.book().top();
Entry entry = top.ask();
if (!entry.isNull()) {
sb.append(" ASK TOP").append(" price=")
.append(entry.price().asDouble())
.append(" qty=").append(entry.size().asDouble());
}
entry = top.bid();
if (!entry.isNull()) {
sb.append(" BID TOP").append(" price=")
.append(entry.price().asDouble())
.append(" qty=").append(entry.size().asDouble());
}
System.out.println(sb.toString());
}
};
feed.startup();
final Agent myAgent = feed.newAgent(Market.class, observer);
for(int i = 2; i < args.length; i++) {
myAgent.include(args[i]);
}
System.in.read();
feed.shutdown();
System.exit(0);
}