}
@Override
public OpenOrders getOpenOrders() throws IOException {
MyOpenOrders myOpenOrders = getCampBXOpenOrders();
logger.debug("myOpenOrders = {}", myOpenOrders);
if (!myOpenOrders.isError()) {
// TODO move to adapter class
List<LimitOrder> orders = new ArrayList<LimitOrder>();
for (CampBXOrder cbo : myOpenOrders.getBuy()) {
if (cbo.isError() || cbo.isInfo()) {
logger.debug("Skipping non-order in Buy: " + cbo);
}
else {
String id = composeOrderId(CampBX.OrderType.Buy, cbo.getOrderID());
BigDecimal price = cbo.getPrice();
orders.add(new LimitOrder(Order.OrderType.BID, cbo.getQuantity(), CurrencyPair.BTC_USD, id, cbo.getOrderEntered(), price));
}
}
for (CampBXOrder cbo : myOpenOrders.getSell()) {
if (cbo.isError() || cbo.isInfo()) {
logger.debug("Skipping non-order in Sell: " + cbo);
}
else {
String id = composeOrderId(CampBX.OrderType.Sell, cbo.getOrderID());
BigDecimal price = cbo.getPrice();
orders.add(new LimitOrder(Order.OrderType.ASK, cbo.getQuantity(), CurrencyPair.BTC_USD, id, cbo.getOrderEntered(), price));
}
}
return new OpenOrders(orders);
}
else {
throw new ExchangeException("Error calling getOpenOrders(): " + myOpenOrders.getError());
}
}