Search in sources :

Example 1 with Exchange

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

the class TickerFetchIntegration method tickerFetchTest.

@Test
public void tickerFetchTest() throws Exception {
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(BitsoExchange.class);
    exchange.remoteInit();
    MarketDataService marketDataService = exchange.getMarketDataService();
    Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_MXN);
    System.out.println(ticker.toString());
    assertThat(ticker).isNotNull();
}
Also used : Exchange(org.knowm.xchange.Exchange) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) Ticker(org.knowm.xchange.dto.marketdata.Ticker) Test(org.junit.Test)

Example 2 with Exchange

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

the class CoinfloorPlaceMarketOrderIntegration method placeMarketOrderTest.

@Test
public void placeMarketOrderTest() 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);
    CoinfloorTradeServiceRaw rawService = (CoinfloorTradeServiceRaw) exchange.getTradeService();
    CoinfloorMarketOrderResponse order = rawService.placeMarketOrder(CurrencyPair.BTC_EUR, OrderType.ASK, new BigDecimal("0.0001"));
    logger.info("placed market order with remainingQty={}", order.getRemaining());
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) CoinfloorMarketOrderResponse(org.knowm.xchange.coinfloor.dto.trade.CoinfloorMarketOrderResponse) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with Exchange

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

the class CoinfloorPublicTradesIntegration method fetchTransactionTest.

@Test
public void fetchTransactionTest() throws IOException {
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinfloorExchange.class);
    MarketDataService service = exchange.getMarketDataService();
    Trades trades = service.getTrades(CurrencyPair.BTC_GBP, CoinfloorInterval.HOUR);
    assertThat(trades.getTrades()).isNotEmpty();
    int tradeCount = trades.getTrades().size();
    Trade mostRecentTrade = trades.getTrades().get(tradeCount - 1);
    assertThat(mostRecentTrade.getPrice()).isGreaterThan(BigDecimal.ZERO);
    assertThat(mostRecentTrade.getOriginalAmount()).isGreaterThan(BigDecimal.ZERO);
    assertThat(trades.getlastID()).isEqualTo(Long.parseLong(mostRecentTrade.getId()));
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) Trade(org.knowm.xchange.dto.marketdata.Trade) Trades(org.knowm.xchange.dto.marketdata.Trades) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) Test(org.junit.Test)

Example 4 with Exchange

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

the class CoinfloorTickerIntegration method fetchTickerTest.

@Test
public void fetchTickerTest() throws IOException {
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinfloorExchange.class);
    MarketDataService service = exchange.getMarketDataService();
    Ticker ticker = service.getTicker(CurrencyPair.BTC_GBP);
    assertThat(ticker.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_GBP);
    assertThat(ticker.getLast()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getHigh()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getLow()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getVwap()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getVolume()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getBid()).isGreaterThan(BigDecimal.ZERO);
    assertThat(ticker.getAsk()).isGreaterThan(BigDecimal.ZERO);
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) Ticker(org.knowm.xchange.dto.marketdata.Ticker) Test(org.junit.Test)

Example 5 with Exchange

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

the class CoinfloorUserTradesIntegration method fetchUserTradesTest.

@Test
public void fetchUserTradesTest() 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();
    CoinfloorTradeHistoryParams params = (CoinfloorTradeHistoryParams) service.createTradeHistoryParams();
    UserTrades trades = service.getTradeHistory(params);
    logger.info("{}", trades);
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) UserTrades(org.knowm.xchange.dto.trade.UserTrades) TradeService(org.knowm.xchange.service.trade.TradeService) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) Test(org.junit.Test)

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