Search in sources :

Example 1 with KrakenTradeServiceRaw

use of org.knowm.xchange.kraken.service.KrakenTradeServiceRaw 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 KrakenTradeServiceRaw

use of org.knowm.xchange.kraken.service.KrakenTradeServiceRaw in project XChange by knowm.

the class KrakenLimitOrderDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
    OrderType orderType = (OrderType.ASK);
    BigDecimal tradeableAmount = new BigDecimal("0.01");
    BigDecimal price = new BigDecimal("65.25");
    LimitOrder limitOrder = new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_LTC, "", null, price);
    KrakenOrderResponse orderResponse = tradeService.placeKrakenLimitOrder(limitOrder);
    System.out.println("Limit Order response: " + orderResponse);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) KrakenTradeServiceRaw(org.knowm.xchange.kraken.service.KrakenTradeServiceRaw) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) KrakenOrderResponse(org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse) BigDecimal(java.math.BigDecimal)

Example 3 with KrakenTradeServiceRaw

use of org.knowm.xchange.kraken.service.KrakenTradeServiceRaw in project XChange by knowm.

the class KrakenOpenOrdersDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    // Interested in the private trading functionality (authentication)
    KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
    // Get the open orders
    Map<String, KrakenOrder> openOrders = tradeService.getKrakenOpenOrders();
    System.out.println(openOrders);
}
Also used : KrakenTradeServiceRaw(org.knowm.xchange.kraken.service.KrakenTradeServiceRaw) KrakenOrder(org.knowm.xchange.kraken.dto.trade.KrakenOrder)

Example 4 with KrakenTradeServiceRaw

use of org.knowm.xchange.kraken.service.KrakenTradeServiceRaw in project XChange by knowm.

the class KrakenTradeRawSpecificDemo method main.

public static void main(String[] args) throws IOException {
    Exchange krakenExchange = KrakenExampleUtils.createTestExchange();
    // Interested in the private trading functionality (authentication)
    KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
    // stop at -5% loss, take profit at +$10 price increase.
    KrakenStandardOrder order = KrakenStandardOrder.getLimitOrderBuilder(CurrencyPair.BTC_USD, KrakenType.BUY, "100.00", new BigDecimal("2.12345678")).withCloseOrder(KrakenOrderType.STOP_LOSS_PROFIT, "#5%", "#10").withValidateOnly(// validate only for demo purposes
    true).buildOrder();
    KrakenOrderResponse orderResponse = tradeService.placeKrakenOrder(order);
    System.out.println(orderResponse);
    Map<String, KrakenOrder> openOrders = tradeService.getKrakenOpenOrders();
    System.out.println(openOrders);
    limitRate();
    Map<String, KrakenOrder> closedOrders = tradeService.getKrakenClosedOrders();
    System.out.println(closedOrders);
    Set<String> closedOrderIds = closedOrders.keySet();
    System.out.println(tradeService.queryKrakenOrders(closedOrderIds.toArray(new String[closedOrderIds.size()])));
    Map<String, KrakenTrade> trades = tradeService.getKrakenTradeHistory().getTrades();
    System.out.println(trades);
    Set<String> tradeIds = trades.keySet();
    System.out.println(tradeService.queryKrakenTrades(tradeIds.toArray(new String[tradeIds.size()])));
    Map<String, KrakenOpenPosition> openPositions = tradeService.getKrakenOpenPositions();
    System.out.println(openPositions);
}
Also used : KrakenTrade(org.knowm.xchange.kraken.dto.trade.KrakenTrade) KrakenOrderResponse(org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse) KrakenOrder(org.knowm.xchange.kraken.dto.trade.KrakenOrder) BigDecimal(java.math.BigDecimal) Exchange(org.knowm.xchange.Exchange) KrakenOpenPosition(org.knowm.xchange.kraken.dto.trade.KrakenOpenPosition) KrakenTradeServiceRaw(org.knowm.xchange.kraken.service.KrakenTradeServiceRaw)

Example 5 with KrakenTradeServiceRaw

use of org.knowm.xchange.kraken.service.KrakenTradeServiceRaw in project XChange by knowm.

the class KrakenMarketOrderDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    // Interested in the private trading functionality (authentication)
    KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
    // place a marketOrder with volume 0.01
    OrderType orderType = (OrderType.BID);
    BigDecimal tradeableAmount = new BigDecimal("0.01");
    MarketOrder marketOrder = new MarketOrder(orderType, tradeableAmount, CurrencyPair.BTC_EUR);
    KrakenOrderResponse orderID = tradeService.placeKrakenMarketOrder(marketOrder);
    System.out.println("Market Order ID: " + orderID);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) KrakenTradeServiceRaw(org.knowm.xchange.kraken.service.KrakenTradeServiceRaw) KrakenOrderResponse(org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse) BigDecimal(java.math.BigDecimal)

Aggregations

KrakenTradeServiceRaw (org.knowm.xchange.kraken.service.KrakenTradeServiceRaw)6 BigDecimal (java.math.BigDecimal)4 KrakenOrderResponse (org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse)4 KrakenOrder (org.knowm.xchange.kraken.dto.trade.KrakenOrder)3 OrderType (org.knowm.xchange.dto.Order.OrderType)2 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)2 KrakenTrade (org.knowm.xchange.kraken.dto.trade.KrakenTrade)2 Exchange (org.knowm.xchange.Exchange)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1 KrakenOpenPosition (org.knowm.xchange.kraken.dto.trade.KrakenOpenPosition)1 KrakenCancelOrderResponse (org.knowm.xchange.kraken.dto.trade.results.KrakenCancelOrderResult.KrakenCancelOrderResponse)1