Search in sources :

Example 1 with KrakenOpenPosition

use of org.knowm.xchange.kraken.dto.trade.KrakenOpenPosition 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)

Aggregations

BigDecimal (java.math.BigDecimal)1 Exchange (org.knowm.xchange.Exchange)1 KrakenOpenPosition (org.knowm.xchange.kraken.dto.trade.KrakenOpenPosition)1 KrakenOrder (org.knowm.xchange.kraken.dto.trade.KrakenOrder)1 KrakenOrderResponse (org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse)1 KrakenTrade (org.knowm.xchange.kraken.dto.trade.KrakenTrade)1 KrakenTradeServiceRaw (org.knowm.xchange.kraken.service.KrakenTradeServiceRaw)1