use of org.knowm.xchange.coinmate.dto.trade.CoinmateOrders in project XChange by knowm.
the class CoinmateTradeServiceRaw method getCoinmateOrderById.
public CoinmateOrders getCoinmateOrderById(String orderId) throws IOException {
CoinmateOrders response = coinmateAuthenticated.getOrderById(exchange.getExchangeSpecification().getApiKey(), exchange.getExchangeSpecification().getUserName(), signatureCreator, exchange.getNonceFactory(), orderId);
throwExceptionIfError(response);
return response;
}
use of org.knowm.xchange.coinmate.dto.trade.CoinmateOrders in project XChange by knowm.
the class CoinmateTradeService method getOrder.
@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
ArrayList<Order> result = new ArrayList<>(orderQueryParams.length);
for (OrderQueryParams orderQueryParam : orderQueryParams) {
CoinmateOrders response = this.getCoinmateOrderById(orderQueryParam.getOrderId());
Order order = CoinmateAdapters.adaptOrder(response.getData(), orderId -> {
try {
return this.getCoinmateOrderById(orderId).getData();
} catch (IOException ex) {
return null;
}
});
result.add(order);
}
return result;
}
use of org.knowm.xchange.coinmate.dto.trade.CoinmateOrders in project XChange by knowm.
the class CoinmateAdapterTest method testOrderAdapter_nullPrice.
@Test
public void testOrderAdapter_nullPrice() throws IOException {
// Read in the JSON from the example resources
InputStream is = CoinmateAdapterTest.class.getResourceAsStream("/org/knowm/xchange/coinmate/dto/trade/example-order1.json");
assertNotNull(is);
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
CoinmateOrders coinmateOrders = mapper.readValue(is, CoinmateOrders.class);
Order order = CoinmateAdapters.adaptOrder(coinmateOrders.getData(), id -> null);
assertThat(order.getType() == Order.OrderType.ASK);
assertThat(order.getId().equals("1"));
assertThat(order.getAveragePrice().equals(new BigDecimal("996740")));
assertThat(order.getTimestamp().equals(1631188240000L));
assertNull(order.getOriginalAmount());
assertNull(order.getCumulativeAmount());
assertThat(order.getStatus() == Order.OrderStatus.FILLED);
}
use of org.knowm.xchange.coinmate.dto.trade.CoinmateOrders in project XChange by knowm.
the class CoinmateAdapterTest method testOrderAdapter_notNullPrice.
@Test
public void testOrderAdapter_notNullPrice() throws IOException {
// Read in the JSON from the example resources
InputStream is = CoinmateAdapterTest.class.getResourceAsStream("/org/knowm/xchange/coinmate/dto/trade/example-order2.json");
assertNotNull(is);
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
CoinmateOrders coinmateOrders = mapper.readValue(is, CoinmateOrders.class);
Order order = CoinmateAdapters.adaptOrder(coinmateOrders.getData(), id -> null);
assertThat(order.getType() == Order.OrderType.ASK);
assertThat(order.getId().equals("2"));
assertThat(order.getAveragePrice().equals(new BigDecimal("997850")));
assertThat(order.getTimestamp().equals(16311882400001L));
assertThat(order.getOriginalAmount().compareTo(new BigDecimal("0.0002")) == 0);
assertThat(order.getCumulativeAmount().compareTo(new BigDecimal("0.0002")) == 0);
assertThat(order.getRemainingAmount().compareTo(BigDecimal.ZERO) == 0);
assertThat(order.getStatus() == Order.OrderStatus.FILLED);
}
Aggregations