use of org.knowm.xchange.bithumb.dto.account.BithumbOrder in project XChange by knowm.
the class BithumbAdapters method adaptOrder.
public static LimitOrder adaptOrder(BithumbOrder order) {
final CurrencyPair currencyPair = adaptCurrencyPair(order.getOrderCurrency(), order.getPaymentCurrency());
final Order.OrderType orderType = adaptOrderType(order.getType());
Order.OrderStatus status = Order.OrderStatus.UNKNOWN;
if (order.getUnitsRemaining().compareTo(order.getUnits()) == 0) {
status = Order.OrderStatus.NEW;
} else if (order.getUnitsRemaining().compareTo(BigDecimal.ZERO) == 0) {
status = Order.OrderStatus.FILLED;
} else {
status = Order.OrderStatus.PARTIALLY_FILLED;
}
return new LimitOrder.Builder(orderType, currencyPair).id(String.valueOf(order.getOrderId())).limitPrice(order.getPrice()).originalAmount(order.getUnits()).remainingAmount(order.getUnitsRemaining()).orderStatus(status).timestamp(new Date(order.getOrderDate() / 1000L)).build();
}
use of org.knowm.xchange.bithumb.dto.account.BithumbOrder in project XChange by knowm.
the class BithumbAdaptersTest method testAdaptOpenOrder.
@Test
public void testAdaptOpenOrder() throws IOException {
// given
InputStream is = BithumbAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/bithumb/dto/account/example-order.json");
final BithumbResponse<List<BithumbOrder>> bithumbOrderResponse = mapper.readValue(is, new TypeReference<BithumbResponse<List<BithumbOrder>>>() {
});
// when
final LimitOrder limitOrder = BithumbAdapters.adaptOrder(bithumbOrderResponse.getData().stream().findFirst().get());
// then
assertThat(limitOrder.getLimitPrice()).isEqualTo(BigDecimal.valueOf(501000));
assertThat(limitOrder.getType()).isEqualTo(Order.OrderType.BID);
assertThat(limitOrder.getOriginalAmount()).isEqualTo(BigDecimal.valueOf(5.0));
assertThat(limitOrder.getCumulativeAmount()).isEqualTo(BigDecimal.valueOf(0.0));
assertThat(limitOrder.getAveragePrice()).isNull();
assertThat(limitOrder.getCurrencyPair()).isEqualTo(new CurrencyPair(Currency.BTC, Currency.KRW));
assertThat(limitOrder.getId()).isEqualTo("C0101000007408440032");
assertThat(limitOrder.getTimestamp()).isNotNull();
assertThat(limitOrder.getStatus()).isEqualTo(Order.OrderStatus.NEW);
}
Aggregations