Search in sources :

Example 21 with TradeService

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

the class TradeServiceIntegrationTransactionsCreateOrder method getTradeHistory.

private static void getTradeHistory() 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 = "1608755608149188609,1608755698308898817";
        CoinsuperTradeHistoryParams params = (CoinsuperTradeHistoryParams) tradeService.createTradeHistoryParams();
        params.setOrderNoList(orderNoList);
        Trades trades = tradeService.getTradeHistory(params);
        System.out.println(trades);
        System.out.printf("Open Orders for %s: %s%n", orderNoList, trades);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CoinsuperExchange(org.knowm.xchange.coinsuper.CoinsuperExchange) Exchange(org.knowm.xchange.Exchange) CoinsuperTradeHistoryParams(org.knowm.xchange.coinsuper.service.CoinsuperTradeHistoryParams) Trades(org.knowm.xchange.dto.marketdata.Trades) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) IOException(java.io.IOException)

Example 22 with TradeService

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

the class TradeServiceIntegrationTransactionsCreateOrder method createLimitOrder.

private static void createLimitOrder() 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
        LimitOrder limitOrder = new LimitOrder((OrderType.ASK), // qty
        new BigDecimal("1.5"), CurrencyPair.ETH_BTC, null, null, new BigDecimal("0.08000000"));
        String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
        System.out.println("======createLimitOrder======");
        System.out.println("Limit Order return order id: " + limitOrderReturnValue);
    } 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) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal)

Example 23 with TradeService

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

the class DVChainExchangeIntegration method testMarketOrder.

@Test
public void testMarketOrder() {
    final Exchange exchange = ExchangeFactory.INSTANCE.createExchange(DVChainExchange.class, secret, secret);
    ExchangeSpecification exchangeSpecification = exchange.getExchangeSpecification();
    exchangeSpecification.setSslUri("https://sandbox.trade.dvchain.co");
    exchangeSpecification.setHost("sandbox.trade.dvchain.co");
    exchange.applySpecification(exchangeSpecification);
    TradeService tradeService = exchange.getTradeService();
    try {
        String order = tradeService.placeMarketOrder(new MarketOrder(Order.OrderType.BID, new BigDecimal(1), new CurrencyPair("BTC", "USD")));
        assertNotNull(order);
    } catch (Exception exception) {
        System.out.println(exception.getMessage());
        assert (false);
    }
}
Also used : Exchange(org.knowm.xchange.Exchange) DVChainExchange(org.knowm.xchange.dvchain.DVChainExchange) TradeService(org.knowm.xchange.service.trade.TradeService) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 24 with TradeService

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

the class DVChainExchangeIntegration method testTrades.

@Test
public void testTrades() {
    final Exchange exchange = ExchangeFactory.INSTANCE.createExchange(DVChainExchange.class, secret, secret);
    ExchangeSpecification exchangeSpecification = exchange.getExchangeSpecification();
    exchangeSpecification.setSslUri("https://sandbox.trade.dvchain.co");
    exchangeSpecification.setHost("sandbox.trade.dvchain.co");
    exchange.applySpecification(exchangeSpecification);
    TradeService tradeService = exchange.getTradeService();
    try {
        UserTrades trades = tradeService.getTradeHistory(new TradeHistoryParamsZero());
        assertNotNull(trades);
    } catch (Exception exception) {
        System.out.println(exception.getMessage());
        assert (false);
    }
}
Also used : Exchange(org.knowm.xchange.Exchange) DVChainExchange(org.knowm.xchange.dvchain.DVChainExchange) TradeHistoryParamsZero(org.knowm.xchange.service.trade.params.TradeHistoryParamsZero) UserTrades(org.knowm.xchange.dto.trade.UserTrades) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Test(org.junit.Test)

Example 25 with TradeService

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

the class HuobiPrivateApiIntegration method getOrderTest.

@Test
public void getOrderTest() throws IOException {
    TradeService tradeService = exchange.getTradeService();
    Collection<Order> orders = tradeService.getOrder("2132866355");
    System.out.println(orders.toString());
    assertThat(orders).isNotNull();
}
Also used : 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) Test(org.junit.Test)

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