Search in sources :

Example 1 with CoinmateOrders

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;
}
Also used : CoinmateOrders(org.knowm.xchange.coinmate.dto.trade.CoinmateOrders)

Example 2 with CoinmateOrders

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;
}
Also used : StopOrder(org.knowm.xchange.dto.trade.StopOrder) Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) ArrayList(java.util.ArrayList) CoinmateOrders(org.knowm.xchange.coinmate.dto.trade.CoinmateOrders) IOException(java.io.IOException) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams)

Example 3 with CoinmateOrders

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);
}
Also used : Order(org.knowm.xchange.dto.Order) InputStream(java.io.InputStream) CoinmateOrders(org.knowm.xchange.coinmate.dto.trade.CoinmateOrders) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 4 with CoinmateOrders

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);
}
Also used : Order(org.knowm.xchange.dto.Order) InputStream(java.io.InputStream) CoinmateOrders(org.knowm.xchange.coinmate.dto.trade.CoinmateOrders) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

CoinmateOrders (org.knowm.xchange.coinmate.dto.trade.CoinmateOrders)4 Order (org.knowm.xchange.dto.Order)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InputStream (java.io.InputStream)2 BigDecimal (java.math.BigDecimal)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1 StopOrder (org.knowm.xchange.dto.trade.StopOrder)1 OrderQueryParams (org.knowm.xchange.service.trade.params.orders.OrderQueryParams)1