Search in sources :

Example 1 with MarketDataService

use of org.knowm.xchange.service.marketdata.MarketDataService 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 MarketDataService

use of org.knowm.xchange.service.marketdata.MarketDataService 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 3 with MarketDataService

use of org.knowm.xchange.service.marketdata.MarketDataService 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 4 with MarketDataService

use of org.knowm.xchange.service.marketdata.MarketDataService 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 5 with MarketDataService

use of org.knowm.xchange.service.marketdata.MarketDataService in project XChange by knowm.

the class KucoinMarketDataDemo method main.

public static void main(String[] args) throws IOException {
    exchange = ExchangeFactory.INSTANCE.createExchange(KucoinExchange.class);
    MarketDataService marketDataService = exchange.getMarketDataService();
    System.out.println(Arrays.toString(exchange.getExchangeSymbols().toArray()));
    generic(marketDataService);
    raw((KucoinMarketDataService) marketDataService);
}
Also used : MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) KucoinMarketDataService(org.knowm.xchange.kucoin.KucoinMarketDataService) KucoinExchange(org.knowm.xchange.kucoin.KucoinExchange)

Aggregations

MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)210 Exchange (org.knowm.xchange.Exchange)155 Test (org.junit.Test)84 Ticker (org.knowm.xchange.dto.marketdata.Ticker)67 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)54 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)40 Trades (org.knowm.xchange.dto.marketdata.Trades)25 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)20 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)13 IOException (java.io.IOException)11 BigDecimal (java.math.BigDecimal)11 MercadoBitcoinExchange (org.knowm.xchange.mercadobitcoin.MercadoBitcoinExchange)11 CoinmateExchange (org.knowm.xchange.coinmate.CoinmateExchange)10 ArrayList (java.util.ArrayList)6 BitfinexExchange (org.knowm.xchange.bitfinex.BitfinexExchange)6 CoinEggExchange (org.knowm.xchange.coinegg.CoinEggExchange)6 CoinsuperExchange (org.knowm.xchange.coinsuper.CoinsuperExchange)6 Date (java.util.Date)5 BitstampExchange (org.knowm.xchange.bitstamp.BitstampExchange)5 SwingWrapper (org.knowm.xchart.SwingWrapper)5