Search in sources :

Example 1 with LivecoinExchange

use of org.knowm.xchange.livecoin.LivecoinExchange in project XChange by knowm.

the class OrderBookDemo method main.

public static void main(String[] args) throws IOException {
    Exchange livecoinExchange = ExchangeFactory.INSTANCE.createExchange(LivecoinExchange.class);
    // Interested in the public market data feed (no authentication)
    MarketDataService marketDataService = livecoinExchange.getMarketDataService();
    System.out.println("fetching data...");
    // Get the current orderbook
    OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD);
    System.out.println("received data.");
    for (LimitOrder limitOrder : orderBook.getBids()) {
        System.out.println(limitOrder.getType() + " " + limitOrder.getCurrencyPair() + " Limit price: " + limitOrder.getLimitPrice() + " Amount: " + limitOrder.getOriginalAmount());
    }
    for (LimitOrder limitOrder : orderBook.getAsks()) {
        System.out.println(limitOrder.getType() + " " + limitOrder.getCurrencyPair() + " Limit price: " + limitOrder.getLimitPrice() + " Amount: " + limitOrder.getOriginalAmount());
    }
}
Also used : LivecoinExchange(org.knowm.xchange.livecoin.LivecoinExchange) 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)

Example 2 with LivecoinExchange

use of org.knowm.xchange.livecoin.LivecoinExchange in project XChange by knowm.

the class TradeDemo method main.

public static void main(String[] args) throws IOException {
    Exchange livecoinExchange = ExchangeFactory.INSTANCE.createExchange(LivecoinExchange.class);
    // Interested in the public market data feed (no authentication)
    MarketDataService marketDataService = livecoinExchange.getMarketDataService();
    System.out.println("fetching data...");
    Trades trades = marketDataService.getTrades(CurrencyPair.BTC_USD);
    System.out.println("received data.");
    for (Trade trade : trades.getTrades()) {
        System.out.println(trade.getType() + " " + trade.getCurrencyPair() + " Price: " + trade.getPrice() + " Amount: " + trade.getOriginalAmount());
    }
}
Also used : LivecoinExchange(org.knowm.xchange.livecoin.LivecoinExchange) 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)

Aggregations

Exchange (org.knowm.xchange.Exchange)2 LivecoinExchange (org.knowm.xchange.livecoin.LivecoinExchange)2 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)2 OrderBook (org.knowm.xchange.dto.marketdata.OrderBook)1 Trade (org.knowm.xchange.dto.marketdata.Trade)1 Trades (org.knowm.xchange.dto.marketdata.Trades)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1