Search in sources :

Example 1 with KrakenPublicTrades

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

the class KrakenTradesDemo method raw.

private static void raw(Exchange krakenExchange) throws IOException {
    // Interested in the public market data feed (no authentication)
    KrakenMarketDataServiceRaw krakenMarketDataService = (KrakenMarketDataServiceRaw) krakenExchange.getMarketDataService();
    // Get the latest trade data for BTC_USD
    KrakenPublicTrades krakenPublicTrades = krakenMarketDataService.getKrakenTrades(CurrencyPair.BTC_USD);
    long last = krakenPublicTrades.getLast();
    System.out.println(krakenPublicTrades.getTrades());
    System.out.println("Trades size: " + krakenPublicTrades.getTrades().size());
    System.out.println("Trades(0): " + krakenPublicTrades.getTrades().get(0).toString());
    System.out.println("Last: " + last);
    // Poll for any new trades since last id
    krakenPublicTrades = krakenMarketDataService.getKrakenTrades(CurrencyPair.LTC_USD, last);
    System.out.println(krakenPublicTrades.getTrades());
    System.out.println("Trades size: " + krakenPublicTrades.getTrades().size());
}
Also used : KrakenMarketDataServiceRaw(org.knowm.xchange.kraken.service.KrakenMarketDataServiceRaw) KrakenPublicTrades(org.knowm.xchange.kraken.dto.marketdata.KrakenPublicTrades)

Example 2 with KrakenPublicTrades

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

the class KrakenMarketDataService method getTrades.

@Override
public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException {
    Long since = null;
    if (args != null && args.length > 0) {
        Object arg0 = args[0];
        if (arg0 instanceof Long) {
            since = (Long) arg0;
        } else {
            throw new ExchangeException("args[0] must be of type Long!");
        }
    }
    KrakenPublicTrades krakenTrades = getKrakenTrades(currencyPair, since);
    return KrakenAdapters.adaptTrades(krakenTrades.getTrades(), currencyPair, krakenTrades.getLast());
}
Also used : ExchangeException(org.knowm.xchange.exceptions.ExchangeException) KrakenPublicTrades(org.knowm.xchange.kraken.dto.marketdata.KrakenPublicTrades)

Aggregations

KrakenPublicTrades (org.knowm.xchange.kraken.dto.marketdata.KrakenPublicTrades)2 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 KrakenMarketDataServiceRaw (org.knowm.xchange.kraken.service.KrakenMarketDataServiceRaw)1