Search in sources :

Example 6 with TradeService

use of org.knowm.xchange.service.trade.TradeService 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 7 with TradeService

use of org.knowm.xchange.service.trade.TradeService in project XChange by knowm.

the class KrakenOpenOrdersDemo method generic.

private static void generic(Exchange krakenExchange) throws IOException {
    // Interested in the private trading functionality (authentication)
    TradeService tradeService = krakenExchange.getTradeService();
    // Get the open orders
    OpenOrders openOrders = tradeService.getOpenOrders();
    System.out.println(openOrders.toString());
}
Also used : TradeService(org.knowm.xchange.service.trade.TradeService) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders)

Example 8 with TradeService

use of org.knowm.xchange.service.trade.TradeService in project XChange by knowm.

the class KrakenTradeHistoryDemo method generic.

private static void generic(Exchange krakenExchange) throws IOException {
    // Interested in the private trading functionality (authentication)
    TradeService tradeService = krakenExchange.getTradeService();
    // Get the trade history
    Trades trades = tradeService.getTradeHistory(tradeService.createTradeHistoryParams());
    System.out.println(trades.toString());
}
Also used : Trades(org.knowm.xchange.dto.marketdata.Trades) TradeService(org.knowm.xchange.service.trade.TradeService)

Example 9 with TradeService

use of org.knowm.xchange.service.trade.TradeService 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 10 with TradeService

use of org.knowm.xchange.service.trade.TradeService 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)

Aggregations

TradeService (org.knowm.xchange.service.trade.TradeService)98 Exchange (org.knowm.xchange.Exchange)65 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)29 BigDecimal (java.math.BigDecimal)28 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)22 Test (org.junit.Test)19 IOException (java.io.IOException)16 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)14 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)14 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)11 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)9 UserTrades (org.knowm.xchange.dto.trade.UserTrades)8 CoinsuperExchange (org.knowm.xchange.coinsuper.CoinsuperExchange)7 Order (org.knowm.xchange.dto.Order)7 Date (java.util.Date)6 OrderType (org.knowm.xchange.dto.Order.OrderType)5 Trades (org.knowm.xchange.dto.marketdata.Trades)5 DVChainExchange (org.knowm.xchange.dvchain.DVChainExchange)5 OpenOrdersParams (org.knowm.xchange.service.trade.params.orders.OpenOrdersParams)5 UserTrade (org.knowm.xchange.dto.trade.UserTrade)4