public synchronized void updateCurrentMarket() { Price buyTopPrice = buySide.topOfBookPrice(); if (buyTopPrice == null) buyTopPrice = PriceFactory.makeLimitPrice((long) 0); Price sellTopPrice = sellSide.topOfBookPrice(); if (sellTopPrice == null) sellTopPrice = PriceFactory.makeLimitPrice((long) 0); String str = buyTopPrice.toString() + buySide.topOfBookVolume() + sellTopPrice.toString() + sellSide.topOfBookVolume(); if (!this.lastCurrentMarket.equals(str)) { MarketDataDTO mktDTO = new MarketDataDTO( this.productSymbol, buyTopPrice, buySide.topOfBookVolume(), sellTopPrice, sellSide.topOfBookVolume()); CurrentMarketPublisher.getInstance().publishCurrentMarket(mktDTO); lastCurrentMarket = str; } }
public synchronized MarketDataDTO getMarketData() { Price buyPrice = buySide.topOfBookPrice(); Price sellPrice = sellSide.topOfBookPrice(); if (buyPrice == null) buyPrice = PriceFactory.makeLimitPrice((long) 0.00); if (sellPrice == null) sellPrice = PriceFactory.makeLimitPrice((long) 0.00); int buyVolume = buySide.topOfBookVolume(); int sellVolume = sellSide.topOfBookVolume(); return new MarketDataDTO(this.productSymbol, buyPrice, buyVolume, sellPrice, sellVolume); }