Search in sources :

Example 1 with KrakenCancelOrderResponse

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

the class KrakenCancelOrderDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
    System.out.println("Open Orders: " + tradeService.getKrakenOpenOrders());
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((OrderType.ASK), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
    KrakenOrderResponse limitOrderReturnValue = tradeService.placeKrakenLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);
    Map<String, KrakenOrder> openOrders = tradeService.getKrakenOpenOrders();
    System.out.println("Open Orders: " + openOrders);
    // Cancel the added order
    List<String> transactionIds = limitOrderReturnValue.getTransactionIds();
    if (transactionIds != null && !transactionIds.isEmpty()) {
        KrakenCancelOrderResponse cancelResult = tradeService.cancelKrakenOrder(transactionIds.get(0));
        System.out.println("Canceling returned " + cancelResult);
        System.out.println("Open Orders: " + tradeService.getKrakenOpenOrders());
    }
}
Also used : KrakenTradeServiceRaw(org.knowm.xchange.kraken.service.KrakenTradeServiceRaw) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) KrakenOrderResponse(org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse) KrakenOrder(org.knowm.xchange.kraken.dto.trade.KrakenOrder) KrakenCancelOrderResponse(org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult.KrakenCancelOrderResponse) BigDecimal(java.math.BigDecimal)

Example 2 with KrakenCancelOrderResponse

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

the class KrakenTradeJsonTest method testCancelOrderUnmarshal.

@Test
public void testCancelOrderUnmarshal() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = KrakenTradeJsonTest.class.getResourceAsStream("/org/knowm/xchange/kraken/dto/trading/example-cancelorder-data.json");
    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    KrakenCancelOrderResult krakenResult = mapper.readValue(is, KrakenCancelOrderResult.class);
    KrakenCancelOrderResponse cancelOrderResponse = krakenResult.getResult();
    assertThat(cancelOrderResponse.getCount()).isEqualTo(1);
    assertFalse(cancelOrderResponse.isPending());
}
Also used : KrakenCancelOrderResult(org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult) InputStream(java.io.InputStream) KrakenCancelOrderResponse(org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult.KrakenCancelOrderResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

KrakenCancelOrderResponse (org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult.KrakenCancelOrderResponse)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStream (java.io.InputStream)1 BigDecimal (java.math.BigDecimal)1 Test (org.junit.Test)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 KrakenOrder (org.knowm.xchange.kraken.dto.trade.KrakenOrder)1 KrakenOrderResponse (org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse)1 KrakenCancelOrderResult (org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult)1 KrakenTradeServiceRaw (org.knowm.xchange.kraken.service.KrakenTradeServiceRaw)1