Search in sources :

Example 1 with PoloniexMarketData

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

the class PoloniexMarketDataServiceRaw method getPoloniexTicker.

public PoloniexTicker getPoloniexTicker(CurrencyPair currencyPair) throws IOException {
    String command = "returnTicker";
    String pairString = PoloniexUtils.toPairString(currencyPair);
    long now = System.currentTimeMillis();
    if (TickermarketData == null || next_refresh < now) {
        try {
            TickermarketData = poloniex.getTicker(command);
        } catch (PoloniexException e) {
            throw PoloniexErrorAdapter.adapt(e);
        } finally {
            // also nice to take a short break on an error
            next_refresh = now + cache_delay;
        }
    }
    PoloniexMarketData data = TickermarketData.get(pairString);
    if (data == null) {
        return null;
    }
    return new PoloniexTicker(data, currencyPair);
}
Also used : PoloniexTicker(org.knowm.xchange.poloniex.dto.marketdata.PoloniexTicker) PoloniexMarketData(org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData) PoloniexException(org.knowm.xchange.poloniex.dto.PoloniexException)

Example 2 with PoloniexMarketData

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

the class PoloniexExchange method remoteInit.

@Override
public void remoteInit() throws IOException {
    PoloniexMarketDataServiceRaw poloniexMarketDataServiceRaw = (PoloniexMarketDataServiceRaw) marketDataService;
    Map<String, PoloniexCurrencyInfo> poloniexCurrencyInfoMap = poloniexMarketDataServiceRaw.getPoloniexCurrencyInfo();
    Map<String, PoloniexMarketData> poloniexMarketDataMap = poloniexMarketDataServiceRaw.getAllPoloniexTickers();
    exchangeMetaData = PoloniexAdapters.adaptToExchangeMetaData(poloniexCurrencyInfoMap, poloniexMarketDataMap, exchangeMetaData);
}
Also used : PoloniexCurrencyInfo(org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo) PoloniexMarketData(org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData) PoloniexMarketDataServiceRaw(org.knowm.xchange.poloniex.service.PoloniexMarketDataServiceRaw)

Example 3 with PoloniexMarketData

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

the class PoloniexWebSocketTickerTransaction method toPoloniexTicker.

public PoloniexTicker toPoloniexTicker(CurrencyPair currencyPair) {
    PoloniexMarketData poloniexMarketData = new PoloniexMarketData();
    BigDecimal last = new BigDecimal(ticker[1]);
    BigDecimal lowestAsk = new BigDecimal(ticker[2]);
    BigDecimal highestBid = new BigDecimal(ticker[3]);
    BigDecimal percentChange = new BigDecimal(ticker[4]);
    BigDecimal baseVolume = new BigDecimal(ticker[5]);
    BigDecimal quoteVolume = new BigDecimal(ticker[6]);
    BigDecimal isFrozen = new BigDecimal(ticker[7]);
    BigDecimal high24hr = new BigDecimal(ticker[8]);
    BigDecimal low24hr = new BigDecimal(ticker[9]);
    poloniexMarketData.setLast(last);
    poloniexMarketData.setLowestAsk(lowestAsk);
    poloniexMarketData.setHighestBid(highestBid);
    poloniexMarketData.setPercentChange(percentChange);
    poloniexMarketData.setBaseVolume(baseVolume);
    poloniexMarketData.setQuoteVolume(quoteVolume);
    poloniexMarketData.setHigh24hr(high24hr);
    poloniexMarketData.setLow24hr(low24hr);
    return new PoloniexTicker(poloniexMarketData, currencyPair);
}
Also used : PoloniexTicker(org.knowm.xchange.poloniex.dto.marketdata.PoloniexTicker) PoloniexMarketData(org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData) BigDecimal(java.math.BigDecimal)

Aggregations

PoloniexMarketData (org.knowm.xchange.poloniex.dto.marketdata.PoloniexMarketData)3 PoloniexTicker (org.knowm.xchange.poloniex.dto.marketdata.PoloniexTicker)2 BigDecimal (java.math.BigDecimal)1 PoloniexException (org.knowm.xchange.poloniex.dto.PoloniexException)1 PoloniexCurrencyInfo (org.knowm.xchange.poloniex.dto.marketdata.PoloniexCurrencyInfo)1 PoloniexMarketDataServiceRaw (org.knowm.xchange.poloniex.service.PoloniexMarketDataServiceRaw)1