@When("select * from Trade") private void watchTrade(Trade t) { Market market = t.getMarket(); if (watching(market.getListing())) { out.println(String.format("trade: %s\t%s (%s)", market, t.getPrice(), t.getVolume())); out.flush(); } }
@When("select * from Book") private void watchBook(Book b) { Market market = b.getMarket(); if (watching(market.getListing())) { out.println( String.format( "book: %s\t%s (%s) - %s (%s)", market, b.getBidPrice(), b.getBidVolume(), b.getAskPrice(), b.getAskVolume())); out.flush(); } }
@Override @Transient public Collection<SpecificOrder> getPendingOrders(Market market, Portfolio portfolio) { com.xeiam.xchange.Exchange exchange = XchangeUtil.getExchangeForMarket(market.getExchange()); PollingTradeService tradeService = exchange.getPollingTradeService(); Collection<SpecificOrder> pendingOrders = new ConcurrentLinkedQueue<SpecificOrder>(); SpecificOrder specificOrder; try { OpenOrders openOrders = tradeService.getOpenOrders(); for (LimitOrder xchangeOrder : openOrders.getOpenOrders()) { for (org.cryptocoinpartners.schema.Order cointraderOrder : orderStateMap.keySet()) { if (cointraderOrder instanceof SpecificOrder) { specificOrder = (SpecificOrder) cointraderOrder; if (xchangeOrder.getId().equals(specificOrder.getRemoteKey()) && specificOrder.getMarket().equals(market)) { specificOrder.update(xchangeOrder); updateOrderState(specificOrder, OrderState.PLACED, false); pendingOrders.add(specificOrder); break; } else { Date time = (xchangeOrder.getTimestamp() != null) ? xchangeOrder.getTimestamp() : new Date(); specificOrder = new SpecificOrder(xchangeOrder, exchange, portfolio, time); updateOrderState(specificOrder, OrderState.PLACED, false); pendingOrders.add(specificOrder); break; } } } Date time = (xchangeOrder.getTimestamp() != null) ? xchangeOrder.getTimestamp() : new Date(); specificOrder = new SpecificOrder(xchangeOrder, exchange, portfolio, time); updateOrderState(specificOrder, OrderState.PLACED, false); pendingOrders.add(specificOrder); log.debug("completed itteration of orders"); } } catch (IOException e) { log.error("Threw a Execption, full stack trace follows:", e); e.printStackTrace(); } return pendingOrders; }