Search in sources :

Example 16 with TradeService

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

the class CoinbeneTradeDemo method generic.

public static void generic(Exchange exchange) throws IOException {
    CurrencyPair pair = CurrencyPair.BTC_USDT;
    TradeService tradeService = exchange.getTradeService();
    // Get open orders
    OpenOrders orders = tradeService.getOpenOrders(new DefaultOpenOrdersParamCurrencyPair(pair));
    LimitOrder order = orders.getOpenOrders().stream().collect(StreamUtils.singletonCollector());
    if (order != null) {
        System.out.println(order);
    }
}
Also used : CoinbeneTradeService(org.knowm.xchange.coinbene.service.CoinbeneTradeService) TradeService(org.knowm.xchange.service.trade.TradeService) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)

Example 17 with TradeService

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

the class CoindirectTradeDemo method main.

public static void main(String[] args) throws IOException {
    Exchange exchange = CoindirectDemoUtils.createExchange();
    /* create a data service from the exchange */
    TradeService tradeService = exchange.getTradeService();
    generic(exchange, tradeService);
    raw((CoindirectExchange) exchange, (CoindirectTradeService) tradeService);
}
Also used : Exchange(org.knowm.xchange.Exchange) CoindirectExchange(org.knowm.xchange.coindirect.CoindirectExchange) CoindirectTradeService(org.knowm.xchange.coindirect.service.CoindirectTradeService) TradeService(org.knowm.xchange.service.trade.TradeService)

Example 18 with TradeService

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

the class TradeServiceIntegrationTransactionsCreateOrder method getOrder.

// getOrder(String... orderIds)
// trades
private static void getOrder() throws IOException {
    String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
    String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
    Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
    ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
    exchangeSpecification.setApiKey(apiKey);
    exchangeSpecification.setSecretKey(secretKey);
    coinsuper.applySpecification(exchangeSpecification);
    TradeService tradeService = coinsuper.getTradeService();
    try {
        String orderNoList = "1608661340536594433,1608661662038384641";
        Collection<Order> openOrders = tradeService.getOrder(orderNoList);
        System.out.printf("Open Orders for %s: %s%n", orderNoList, openOrders);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CoinsuperExchange(org.knowm.xchange.coinsuper.CoinsuperExchange) Exchange(org.knowm.xchange.Exchange) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Order(org.knowm.xchange.dto.Order) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) IOException(java.io.IOException)

Example 19 with TradeService

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

the class TradeServiceIntegrationTransactionsCreateOrder method createMarketOrder.

private static void createMarketOrder() throws IOException {
    String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
    String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
    Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
    ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
    exchangeSpecification.setApiKey(apiKey);
    exchangeSpecification.setSecretKey(secretKey);
    coinsuper.applySpecification(exchangeSpecification);
    TradeService tradeService = coinsuper.getTradeService();
    try {
        // place a limit buy order
        MarketOrder marketOrder = new MarketOrder((OrderType.BID), new BigDecimal("30513299.8408"), CurrencyPair.XRP_BTC, null, null, null, null, null, null);
        String result = tradeService.placeMarketOrder(marketOrder);
        System.out.println("createMarketOrder return value: " + result);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CoinsuperExchange(org.knowm.xchange.coinsuper.CoinsuperExchange) Exchange(org.knowm.xchange.Exchange) TradeService(org.knowm.xchange.service.trade.TradeService) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) IOException(java.io.IOException) BigDecimal(java.math.BigDecimal)

Example 20 with TradeService

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

the class TradeServiceIntegrationTransactionsCreateOrder method cancelOrder.

private static void cancelOrder() throws IOException {
    String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
    String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
    Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
    ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
    exchangeSpecification.setApiKey(apiKey);
    exchangeSpecification.setSecretKey(secretKey);
    coinsuper.applySpecification(exchangeSpecification);
    TradeService tradeService = coinsuper.getTradeService();
    try {
        // Cancel the added order
        String orderId = "1608586238226747393";
        boolean cancelResult = tradeService.cancelOrder(orderId);
        System.out.println("Canceling returned " + cancelResult);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CoinsuperExchange(org.knowm.xchange.coinsuper.CoinsuperExchange) Exchange(org.knowm.xchange.Exchange) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) IOException(java.io.IOException)

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