Search in sources :

Example 11 with LimitOrder

use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.

the class KrakenLimitOrderDemo method generic.

private static void generic(Exchange krakenExchange) throws IOException {
    TradeService tradeService = 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);
    String orderID = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order ID: " + orderID);
}
Also used : OrderType(org.knowm.xchange.dto.Order.OrderType) TradeService(org.knowm.xchange.service.trade.TradeService) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal)

Example 12 with LimitOrder

use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.

the class LakeBTCBuyOrderDemo method raw.

private static void raw(Exchange lakeBtcExchange) throws IOException {
    LakeBTCTradeServiceRaw tradeService = (LakeBTCTradeServiceRaw) lakeBtcExchange.getTradeService();
    System.out.println("Open Orders: " + Arrays.toString(tradeService.getLakeBTCOrders()));
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((Order.OrderType.BID), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
    LakeBTCOrderResponse limitOrderReturnValue = tradeService.placeLakeBTCLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);
    // place a market buy order
    MarketOrder marketOrder = new MarketOrder((Order.OrderType.BID), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null);
    LakeBTCOrderResponse marketOrderReturnValue = tradeService.placeLakeBTCMarketOrder(marketOrder);
    System.out.println("Market Order return value: " + marketOrderReturnValue);
    System.out.println("Open Orders: " + Arrays.toString(tradeService.getLakeBTCOrders()));
}
Also used : LakeBTCTradeServiceRaw(org.knowm.xchange.lakebtc.service.LakeBTCTradeServiceRaw) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) LakeBTCOrderResponse(org.knowm.xchange.lakebtc.dto.trade.LakeBTCOrderResponse)

Example 13 with LimitOrder

use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.

the class LakeBTCBuyOrderDemo method generic.

private static void generic(Exchange lakebtcExchange) throws IOException {
    TradeService tradeService = lakebtcExchange.getTradeService();
    System.out.println("Open Orders: " + tradeService.getOpenOrders());
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((Order.OrderType.BID), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
    String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);
    // place a market buy order
    MarketOrder marketOrder = new MarketOrder((Order.OrderType.BID), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null);
    String marketOrderReturnValue = tradeService.placeMarketOrder(marketOrder);
    System.out.println("Limit Order return value: " + marketOrderReturnValue);
    System.out.println("Open Orders: " + tradeService.getOpenOrders().toString());
}
Also used : TradeService(org.knowm.xchange.service.trade.TradeService) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal)

Example 14 with LimitOrder

use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.

the class LakeBTCCancelOrderDemo method generic.

private static void generic(Exchange lakebtcExchange) throws IOException {
    TradeService tradeService = lakebtcExchange.getTradeService();
    System.out.println("Open Orders: " + tradeService.getOpenOrders());
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((Order.OrderType.ASK), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
    String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);
    System.out.println("Open Orders: " + tradeService.getOpenOrders().toString());
    // Cancel the added order
    boolean cancelResult = tradeService.cancelOrder(limitOrderReturnValue);
    System.out.println("Canceling returned " + cancelResult);
    System.out.println("Open Orders: " + tradeService.getOpenOrders().toString());
}
Also used : TradeService(org.knowm.xchange.service.trade.TradeService) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal)

Example 15 with LimitOrder

use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.

the class LakeBTCSellOrderDemo method raw.

private static void raw(Exchange lakeBtcExchange) throws IOException {
    LakeBTCTradeServiceRaw tradeService = (LakeBTCTradeServiceRaw) lakeBtcExchange.getTradeService();
    System.out.println("Open Orders: " + Arrays.toString(tradeService.getLakeBTCOrders()));
    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((Order.OrderType.ASK), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
    LakeBTCOrderResponse limitOrderReturnValue = tradeService.placeLakeBTCLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);
    System.out.println("Open Orders: " + Arrays.toString(tradeService.getLakeBTCOrders()));
}
Also used : LakeBTCTradeServiceRaw(org.knowm.xchange.lakebtc.service.LakeBTCTradeServiceRaw) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) LakeBTCOrderResponse(org.knowm.xchange.lakebtc.dto.trade.LakeBTCOrderResponse)

Aggregations

LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)337 BigDecimal (java.math.BigDecimal)188 Test (org.junit.Test)122 Date (java.util.Date)110 ArrayList (java.util.ArrayList)95 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)90 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)89 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)77 Order (org.knowm.xchange.dto.Order)50 OrderType (org.knowm.xchange.dto.Order.OrderType)39 Exchange (org.knowm.xchange.Exchange)31 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)29 List (java.util.List)28 TradeService (org.knowm.xchange.service.trade.TradeService)28 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)23 IOException (java.io.IOException)20 Collectors (java.util.stream.Collectors)20 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)17 InputStream (java.io.InputStream)15 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)15