printOpenOrdersRaw();
// place a limit buy order
LimitOrder limitOrder = new LimitOrder((OrderType.BID), BigDecimal.ONE, CurrencyPair.BTC_CNY, "", null, new BigDecimal("0.01"));
BTCChinaIntegerResponse limitOrderReturnValue = ((BTCChinaTradeServiceRaw) tradeService).buy(new BigDecimal("0.01"), BigDecimal.ONE, "BTCCNY");
System.out.println("Limit Order return value: " + limitOrderReturnValue);
Thread.sleep(1500);
BTCChinaResponse<BTCChinaOrders> openOrders = printOpenOrdersRaw();
long result = -1;
for (int i = 0; i < openOrders.getResult().getOrders().size(); i++) {
BTCChinaOrder order = openOrders.getResult().getOrders().get(i);
int orderId = order.getId();
if (order.getType().equals(limitOrder.getType().toString()) && order.getPrice().compareTo(limitOrder.getLimitPrice()) == 0 && orderId > result) {
result = orderId;
}
}
// Cancel the added order
BTCChinaBooleanResponse cancelResult = ((BTCChinaTradeServiceRaw) tradeService).cancelBTCChinaOrder(limitOrderReturnValue.getResult().intValue());
System.out.println("Canceling returned " + cancelResult);
printOpenOrders();
}