use of org.knowm.xchange.kraken.dto.trade.KrakenOrderDescription in project XChange by knowm.
the class KrakenTradeJsonTest method testOrderUnmarshall.
@Test
public void testOrderUnmarshall() throws IOException {
// Read in the JSON from the example resources
InputStream is = KrakenTradeJsonTest.class.getResourceAsStream("/org/knowm/xchange/kraken/dto/trading/example-openorders-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
KrakenOpenOrdersResult krakenResult = mapper.readValue(is, KrakenOpenOrdersResult.class);
Entry<String, KrakenOrder> openOrderEntry = krakenResult.getResult().getOrders().entrySet().iterator().next();
KrakenOrder order = openOrderEntry.getValue();
// Verify that the example data was unmarshalled correctly
assertThat(openOrderEntry.getKey()).isEqualTo("O767CW-TXHCL-FWZ5R2");
assertThat(order.getOpenTimestamp()).isEqualTo(1499872460.2572);
assertThat(order.getPrice()).isEqualTo("0.000000000");
assertThat(order.getVolume()).isEqualTo("1000.00000000");
assertThat(order.getVolumeExecuted()).isEqualTo("0.00000000");
assertThat(order.getStatus()).isEqualTo(KrakenOrderStatus.OPEN);
KrakenOrderDescription orderDescription = order.getOrderDescription();
assertThat(orderDescription.getAssetPair()).isEqualTo("XRPXBT");
assertThat(orderDescription.getLeverage()).isEqualTo("none");
assertThat(orderDescription.getOrderDescription()).isEqualTo("buy 1000.00000000 XRPXBT @ limit 0.00001000");
assertThat(orderDescription.getOrderType()).isEqualTo(KrakenOrderType.LIMIT);
assertThat(orderDescription.getType()).isEqualTo(KrakenType.BUY);
assertThat(orderDescription.getPrice()).isEqualTo("0.00001000");
assertThat(orderDescription.getSecondaryPrice()).isEqualTo("0");
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderDescription in project XChange by knowm.
the class KrakenAdapters method adaptOpenOrders.
public static OpenOrders adaptOpenOrders(Map<String, KrakenOrder> krakenOrders) {
List<LimitOrder> limitOrders = new ArrayList<>();
for (Entry<String, KrakenOrder> krakenOrderEntry : krakenOrders.entrySet()) {
KrakenOrder krakenOrder = krakenOrderEntry.getValue();
KrakenOrderDescription orderDescription = krakenOrder.getOrderDescription();
if (!"limit".equals(orderDescription.getOrderType().toString())) {
// ignore anything but a plain limit order for now
continue;
}
limitOrders.add((LimitOrder) adaptOrder(krakenOrderEntry.getKey(), krakenOrder));
}
return new OpenOrders(limitOrders);
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderDescription in project XChange by knowm.
the class KrakenUtils method filterOpenOrdersByCurrencyPair.
public static Map<String, KrakenOrder> filterOpenOrdersByCurrencyPair(Map<String, KrakenOrder> krakenOrders, CurrencyPair currencyPair) {
Map<String, KrakenOrder> filteredKrakenOrders = new HashMap<>();
for (Map.Entry<String, KrakenOrder> krakenOrderEntry : krakenOrders.entrySet()) {
KrakenOrder krakenOrder = krakenOrderEntry.getValue();
KrakenOrderDescription orderDescription = krakenOrder.getOrderDescription();
if (currencyPair != null && currencyPair.equals(KrakenAdapters.adaptCurrencyPair(orderDescription.getAssetPair()))) {
filteredKrakenOrders.put(krakenOrderEntry.getKey(), krakenOrder);
}
}
return filteredKrakenOrders;
}
Aggregations