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);
}
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);
}
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);
}
Aggregations