Search in sources :

Example 1 with KrakenOpenOrdersResult

use of org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult in project XChange by knowm.

the class KrakenAdaptersTest method testAdaptOpenOrders.

@Test
public void testAdaptOpenOrders() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = KrakenAdaptersTest.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);
    OpenOrders orders = KrakenAdapters.adaptOpenOrders(krakenResult.getResult().getOrders());
    // Verify that the example data was unmarshalled correctly
    assertThat(orders.getOpenOrders()).hasSize(6);
    assertThat(orders.getOpenOrders().get(0).getId()).isEqualTo("O767CW-TXHCL-FWZ5R2");
    assertThat(orders.getOpenOrders().get(0).getLimitPrice()).isEqualTo("0.00001000");
    assertThat(orders.getOpenOrders().get(0).getOriginalAmount()).isEqualTo("1000.00000000");
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().base).isEqualTo(Currency.XRP);
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().counter).isEqualTo(Currency.BTC);
    assertThat(orders.getOpenOrders().get(0).getType()).isEqualTo(OrderType.BID);
}
Also used : InputStream(java.io.InputStream) KrakenOpenOrdersResult(org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with KrakenOpenOrdersResult

use of org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult in project XChange by knowm.

the class KrakenAdaptersTest method testAdaptOpenOrdersInTransactionCurrency.

@Test
public void testAdaptOpenOrdersInTransactionCurrency() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = KrakenAdaptersTest.class.getResourceAsStream("/org/knowm/xchange/kraken/dto/trading/example-openorders-in-transaction-currency-data.json");
    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    KrakenOpenOrdersResult krakenResult = mapper.readValue(is, KrakenOpenOrdersResult.class);
    OpenOrders orders = KrakenAdapters.adaptOpenOrders(krakenResult.getResult().getOrders());
    // Verify that the example data was unmarshalled correctly
    assertThat(orders.getOpenOrders()).hasSize(1);
    assertThat(orders.getOpenOrders().get(0).getId()).isEqualTo("OR6QMM-BCKM4-Q6YHIN");
    assertThat(orders.getOpenOrders().get(0).getLimitPrice()).isEqualTo("500.00000");
    assertThat(orders.getOpenOrders().get(0).getOriginalAmount()).isEqualTo("1.00000000");
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().base).isEqualTo(Currency.BTC);
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().counter).isEqualTo(Currency.EUR);
    assertThat(orders.getOpenOrders().get(0).getType()).isEqualTo(OrderType.BID);
}
Also used : InputStream(java.io.InputStream) KrakenOpenOrdersResult(org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with KrakenOpenOrdersResult

use of org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult in project XChange by knowm.

the class KrakenUtilsTest method testFilterOpenOrdersByCurrencyPair.

@Test
public void testFilterOpenOrdersByCurrencyPair() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = KrakenAdaptersTest.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);
    Map<String, KrakenOrder> krakenOrders = KrakenUtils.filterOpenOrdersByCurrencyPair(krakenResult.getResult().getOrders(), CurrencyPair.BTC_EUR);
    OpenOrders orders = KrakenAdapters.adaptOpenOrders(krakenOrders);
    // Verify that the example data was unmarshalled correctly
    assertThat(orders.getOpenOrders()).hasSize(1);
    assertThat(orders.getOpenOrders().get(0).getId()).isEqualTo("OU5JPQ-OIDTK-QIGIGI");
    assertThat(orders.getOpenOrders().get(0).getLimitPrice()).isEqualTo("1000.000");
    assertThat(orders.getOpenOrders().get(0).getOriginalAmount()).isEqualTo("0.01000000");
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().base).isEqualTo(Currency.XBT);
    assertThat(orders.getOpenOrders().get(0).getCurrencyPair().counter).isEqualTo(Currency.EUR);
    assertThat(orders.getOpenOrders().get(0).getType()).isEqualTo(Order.OrderType.BID);
}
Also used : InputStream(java.io.InputStream) KrakenOpenOrdersResult(org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult) KrakenOrder(org.knowm.xchange.kraken.dto.trade.KrakenOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with KrakenOpenOrdersResult

use of org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult 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");
}
Also used : InputStream(java.io.InputStream) KrakenOpenOrdersResult(org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult) KrakenOrder(org.knowm.xchange.kraken.dto.trade.KrakenOrder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) KrakenOrderDescription(org.knowm.xchange.kraken.dto.trade.KrakenOrderDescription) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InputStream (java.io.InputStream)4 Test (org.junit.Test)4 KrakenOpenOrdersResult (org.knowm.xchange.kraken.dto.trade.results.KrakenOpenOrdersResult)4 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)3 KrakenOrder (org.knowm.xchange.kraken.dto.trade.KrakenOrder)2 KrakenOrderDescription (org.knowm.xchange.kraken.dto.trade.KrakenOrderDescription)1