Search in sources :

Example 6 with Exchange

use of org.knowm.xchange.Exchange in project XChange by knowm.

the class CoinfloorBalanceIntegration method fetchBalanceTest.

@Test
public void fetchBalanceTest() throws IOException {
    final ExchangeSpecification specification = new ExchangeSpecification(CoinfloorExchange.class);
    String username = System.getProperty("xchange.coinfloor.username");
    String password = System.getProperty("xchange.coinfloor.password");
    if (username == null || password == null) {
        return;
    }
    specification.setUserName(username);
    specification.setPassword(password);
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(specification);
    AccountService service = exchange.getAccountService();
    AccountInfo info = service.getAccountInfo();
    logger.info("{}", info);
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) AccountService(org.knowm.xchange.service.account.AccountService) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Test(org.junit.Test)

Example 7 with Exchange

use of org.knowm.xchange.Exchange in project XChange by knowm.

the class CoinfloorCancelOrderIntegration method cancelOpenOrdersTest.

@Test
public void cancelOpenOrdersTest() throws IOException {
    final ExchangeSpecification specification = new ExchangeSpecification(CoinfloorExchange.class);
    String username = System.getProperty("xchange.coinfloor.username");
    String password = System.getProperty("xchange.coinfloor.password");
    if (username == null || password == null) {
        return;
    }
    specification.setUserName(username);
    specification.setPassword(password);
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(specification);
    TradeService service = exchange.getTradeService();
    // fetch open orders
    CoinfloorOpenOrdersParams params = (CoinfloorOpenOrdersParams) service.createOpenOrdersParams();
    OpenOrders openOrders = service.getOpenOrders(params);
    // cancel one order
    if (openOrders.getOpenOrders().size() > 0) {
        LimitOrder order = openOrders.getOpenOrders().iterator().next();
        boolean success = service.cancelOrder(order.getId());
        logger.info("cancel of order={} success={}", order, success);
    }
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Test(org.junit.Test)

Example 8 with Exchange

use of org.knowm.xchange.Exchange in project XChange by knowm.

the class CoinfloorOrderBookIntegration method fetchOrderBookTest.

@Test
public void fetchOrderBookTest() throws IOException {
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinfloorExchange.class);
    MarketDataService service = exchange.getMarketDataService();
    OrderBook orderBook = service.getOrderBook(CurrencyPair.BTC_GBP);
    assertThat(orderBook.getBids()).isNotEmpty();
    assertThat(orderBook.getAsks()).isNotEmpty();
    LimitOrder order = orderBook.getBids().get(0);
    assertThat(order.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_GBP);
    assertThat(order.getOriginalAmount()).isGreaterThan(BigDecimal.ZERO);
    assertThat(order.getLimitPrice()).isGreaterThan(BigDecimal.ZERO);
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) OrderBook(org.knowm.xchange.dto.marketdata.OrderBook) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Test(org.junit.Test)

Example 9 with Exchange

use of org.knowm.xchange.Exchange in project XChange by knowm.

the class KucoinAccountDemo method main.

public static void main(String[] args) throws IOException {
    Exchange exchange = KucoinExamplesUtils.getExchange();
    AccountService accountService = exchange.getAccountService();
    generic(accountService);
    raw((KucoinAccountServiceRaw) accountService);
}
Also used : Exchange(org.knowm.xchange.Exchange) AccountService(org.knowm.xchange.service.account.AccountService)

Example 10 with Exchange

use of org.knowm.xchange.Exchange in project XChange by knowm.

the class KucoinTradeHistoryDemo method main.

public static void main(String[] args) throws Exception {
    Exchange exchange = KucoinExamplesUtils.getExchange();
    TradeService tradeService = exchange.getTradeService();
    getRecentTrades(tradeService);
    // getHistoricalTrades(tradeService);      // historical trades API endpoint not supported on
    // Sandbox
    getPagedTrades(tradeService);
}
Also used : Exchange(org.knowm.xchange.Exchange) TradeService(org.knowm.xchange.service.trade.TradeService)

Aggregations

Exchange (org.knowm.xchange.Exchange)416 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)155 Test (org.junit.Test)120 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)93 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)64 TradeService (org.knowm.xchange.service.trade.TradeService)62 Ticker (org.knowm.xchange.dto.marketdata.Ticker)50 AccountService (org.knowm.xchange.service.account.AccountService)38 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)31 IOException (java.io.IOException)28 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)27 BigDecimal (java.math.BigDecimal)25 Trades (org.knowm.xchange.dto.marketdata.Trades)22 CoinsuperExchange (org.knowm.xchange.coinsuper.CoinsuperExchange)15 KrakenExchange (org.knowm.xchange.kraken.KrakenExchange)15 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)12 MercadoBitcoinExchange (org.knowm.xchange.mercadobitcoin.MercadoBitcoinExchange)12 CoinmateExchange (org.knowm.xchange.coinmate.CoinmateExchange)10 UserTrades (org.knowm.xchange.dto.trade.UserTrades)10 ArrayList (java.util.ArrayList)9