All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xeiam.xchange.bitcurex.service.polling.BitcurexMarketDataService Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
/**
 * Copyright (C) 2012 - 2014 Xeiam LLC http://xeiam.com
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.xeiam.xchange.bitcurex.service.polling;

import java.io.IOException;
import java.util.List;

import com.xeiam.xchange.ExchangeSpecification;
import com.xeiam.xchange.NotAvailableFromExchangeException;
import com.xeiam.xchange.bitcurex.BitcurexAdapters;
import com.xeiam.xchange.bitcurex.dto.marketdata.BitcurexDepth;
import com.xeiam.xchange.bitcurex.dto.marketdata.BitcurexTicker;
import com.xeiam.xchange.bitcurex.dto.marketdata.BitcurexTrade;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.dto.ExchangeInfo;
import com.xeiam.xchange.dto.Order.OrderType;
import com.xeiam.xchange.dto.marketdata.OrderBook;
import com.xeiam.xchange.dto.marketdata.Ticker;
import com.xeiam.xchange.dto.marketdata.Trades;
import com.xeiam.xchange.dto.trade.LimitOrder;
import com.xeiam.xchange.service.polling.PollingMarketDataService;

/**
 * 

* Implementation of the generic market data service for Bitcurex *

*
    *
  • Provides access to various market data values
  • *
*/ public class BitcurexMarketDataService extends BitcurexMarketDataServiceRaw implements PollingMarketDataService { /** * Constructor * * @param exchangeSpecification The {@link ExchangeSpecification} */ public BitcurexMarketDataService(ExchangeSpecification exchangeSpecification) { super(exchangeSpecification); } @Override public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOException { verify(currencyPair); // get data BitcurexTicker bitcurexTicker = getBitcurexTicker(currencyPair.counterSymbol); // Adapt to XChange DTOs return BitcurexAdapters.adaptTicker(bitcurexTicker, currencyPair); } @Override public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException { verify(currencyPair); // get data BitcurexDepth bitcurexDepth = getBitcurexOrderBook(currencyPair.counterSymbol); // Adapt to XChange DTOs List asks = BitcurexAdapters.adaptOrders(bitcurexDepth.getAsks(), currencyPair, OrderType.ASK, ""); List bids = BitcurexAdapters.adaptOrders(bitcurexDepth.getBids(), currencyPair, OrderType.BID, ""); return new OrderBook(null, asks, bids); } @Override public Trades getTrades(CurrencyPair currencyPair, Object... args) throws IOException { verify(currencyPair); // get data BitcurexTrade[] bitcurexTrades = getBitcurexTrades(currencyPair.counterSymbol); // Adapt to XChange DTOs return BitcurexAdapters.adaptTrades(bitcurexTrades, currencyPair); } @Override public ExchangeInfo getExchangeInfo() throws IOException { throw new NotAvailableFromExchangeException(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy