use of org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse 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());
}
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse 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);
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse in project XChange by knowm.
the class KrakenTradeJsonTest method testAddOrderResponseUnmarshal.
@Test
public void testAddOrderResponseUnmarshal() throws IOException {
// Read in the JSON from the example resources
InputStream is = KrakenTradeJsonTest.class.getResourceAsStream("/org/knowm/xchange/kraken/dto/trading/example-addorder-response-data.json");
// Use Jackson to parse it
ObjectMapper mapper = new ObjectMapper();
KrakenOrderResult krakenResult = mapper.readValue(is, KrakenOrderResult.class);
KrakenOrderResponse orderResponse = krakenResult.getResult();
assertThat(orderResponse.getDescription().getOrderDescription()).isEqualTo("sell 0.01000000 XBTLTC @ limit 45.25000");
assertThat(orderResponse.getTransactionIds().get(0)).isEqualTo("OWQJ5O-ZWYC7-5R7POQ");
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse 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);
}
use of org.knowm.xchange.kraken.dto.trade.KrakenOrderResponse 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);
}
Aggregations