Search in sources :

Example 1 with Ticker

use of org.knowm.xchange.dto.marketdata.Ticker 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 Ticker

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

use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.

the class CmcAdapter method adaptTickerList.

public static List<Ticker> adaptTickerList(List<CmcTicker> cmcTickerList) {
    List<Ticker> tickerList = new ArrayList<>();
    cmcTickerList.forEach(cmcTicker -> {
        cmcTicker.getQuote().forEach((currencySymbol, quote) -> {
            CurrencyPair pair = new CurrencyPair(cmcTicker.getSymbol(), currencySymbol);
            tickerList.add(adaptTicker(cmcTicker, pair));
        });
    });
    return tickerList;
}
Also used : CmcTicker(org.knowm.xchange.coinmarketcap.pro.v1.dto.marketdata.CmcTicker) Ticker(org.knowm.xchange.dto.marketdata.Ticker) ArrayList(java.util.ArrayList) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 4 with Ticker

use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.

the class TickerDemo method generic.

private static void generic(MarketDataService marketDataService) throws IOException {
    Ticker ticker = marketDataService.getTicker(new CurrencyPair(Currency.LTC, Currency.BRL));
    System.out.println(ticker.toString());
}
Also used : Ticker(org.knowm.xchange.dto.marketdata.Ticker) MercadoBitcoinTicker(org.knowm.xchange.mercadobitcoin.dto.marketdata.MercadoBitcoinTicker) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 5 with Ticker

use of org.knowm.xchange.dto.marketdata.Ticker in project XChange by knowm.

the class KrakenTickerDemo method generic.

private static void generic(Exchange krakenExchange) throws IOException {
    // Interested in the public market data feed (no authentication)
    MarketDataService marketDataService = krakenExchange.getMarketDataService();
    // Get the latest ticker data showing BTC to EUR
    Ticker ticker = marketDataService.getTicker(CurrencyPair.BTC_EUR);
    System.out.println("Ticker: " + ticker.toString());
    System.out.println("Currency: " + Currency.EUR);
    System.out.println("Last: " + ticker.getLast().toString());
    System.out.println("Volume: " + ticker.getVolume().toString());
    System.out.println("High: " + ticker.getHigh().toString());
    System.out.println("Low: " + ticker.getLow().toString());
}
Also used : MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService) KrakenTicker(org.knowm.xchange.kraken.dto.marketdata.KrakenTicker) Ticker(org.knowm.xchange.dto.marketdata.Ticker)

Aggregations

Ticker (org.knowm.xchange.dto.marketdata.Ticker)201 Test (org.junit.Test)101 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)69 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)68 BigDecimal (java.math.BigDecimal)66 Exchange (org.knowm.xchange.Exchange)48 Date (java.util.Date)34 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)23 InputStream (java.io.InputStream)23 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)22 Trades (org.knowm.xchange.dto.marketdata.Trades)15 IOException (java.io.IOException)10 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 ExchangeSpecification (org.knowm.xchange.ExchangeSpecification)8 Arrays (java.util.Arrays)6 Collectors (java.util.stream.Collectors)6 Balance (org.knowm.xchange.dto.account.Balance)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 List (java.util.List)5