本文整理汇总了Java中org.knowm.xchange.dto.marketdata.Ticker类的典型用法代码示例。如果您正苦于以下问题:Java Ticker类的具体用法?Java Ticker怎么用?Java Ticker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ticker类属于org.knowm.xchange.dto.marketdata包,在下文中一共展示了Ticker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBitstampCurrentRateBTCUSD
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
* Get the exchange rate from Bitstamp. As a trader can do a tradeback, we need the specific exchange. The exchange
* rate for the fiat currency is then calculated in a second step.
* @return
* @throws IOException
*/
public ForexDTO getBitstampCurrentRateBTCUSD() {
ForexDTO forexDTO = new ForexDTO();
try {
Ticker ticker = MARKET_DATA_SERVICE.getTicker(BTC_USD);
forexDTO.setCurrencyFrom(BTC);
forexDTO.setCurrencyTo(USD);
forexDTO.setRate(ticker.getAsk().add(ticker.getBid()).divide(BigDecimal.valueOf(2)));
forexDTO.setUpdatedAt(ticker.getTimestamp());
} catch (IOException exception) {
throw new CoinbleskInternalError("Bitstamp currency rate currently not available.");
}
return forexDTO;
}
示例2: getTargetBid
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
* Calculates bid target between current ask price and last price
*/
private BigDecimal getTargetBid(Ticker ticker) {
if (ticker.getAsk().compareTo(ticker.getLast()) < 0) {
return ticker.getAsk();
}
// Factor with regards to ask price
BigDecimal balance = BigDecimal.ZERO;
return ticker.getAsk().add(balance.multiply(ticker.getLast().subtract(ticker.getAsk())));
}
示例3: updateExchangeCache
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
* Updates the Tickers for a specific Exchange.
*
* @param reference The reference to the Exchange.
* @return The cached Tickers.
*/
@SuppressWarnings("WeakerAccess")
@Async
public CompletableFuture<Map<CurrencyPair, Ticker>> updateExchangeCache(ExchangeReference reference) {
// Create a cache for the Exchange.
Map<CurrencyPair, Ticker> exchangeCache = new HashMap<>();
// Get the MarketDataService for the Exchange.
MarketDataService marketDataService = reference.getMarketDataService();
// Try the Currency Pairs.
for (CurrencyPair currencyPair : TickerCacheService.CURRENCY_PAIRS) {
Ticker ticker = null;
// Try to get the Ticker for this CurrencyPair.
try {
ticker = marketDataService.getTicker(currencyPair);
} catch (Exception ignored) {
}
// If the Ticker was found, add it to the cache.
if (ticker != null) {
exchangeCache.put(currencyPair, ticker);
logService.logDebug(getClass(), reference.name() + ": " + currencyPair.toString() + ": Success");
} else {
logService.logDebug(getClass(), reference.name() + ": " + currencyPair.toString() + ": Fail");
}
}
return CompletableFuture.completedFuture(exchangeCache);
}
示例4: buildExchangeRateChange
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
private ExchangeRateChange buildExchangeRateChange(CurrencyUnitPair pair, Ticker ticker) {
Date date = ticker.getTimestamp();
// Not all exchanges provide a timestamp, default to 0 if it is null
long milliseconds = (date != null) ? date.getTime() : 0;
return new ExchangeRateChange(buildExchangeRate(pair, ticker), milliseconds);
}
示例5: buildExchangeRate
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
private ExchangeRate buildExchangeRate(CurrencyUnitPair pair, Ticker ticker) {
return new ExchangeRateBuilder(name, RateType.DEFERRED)
.setBase(pair.getBase())
.setTerm(pair.getTarget())
.setFactor(DefaultNumberValue.of(ticker.getLast()))
.build();
}
示例6: getTicker
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
@Override
public Ticker getTicker(CurrencyPair pair) throws IOException {
LOGGER.debug("Getting ticker for pair: {}", pair);
return marketDataService.getTicker(pair);
}
示例7: TickerDto
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public TickerDto(String exchangeName, Ticker ticker) {
this.exchangeName = exchangeName;
this.ticker = ticker;
}
示例8: getTicker
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public Ticker getTicker() {
return ticker;
}
示例9: setTicker
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public void setTicker(Ticker ticker) {
this.ticker = ticker;
}
示例10: getBTCUSD
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getBTCUSD() throws IOException {
Ticker ticker = marketDataServiceKraken.getTicker(CurrencyPair.BTC_USD);
return ticker.getLast();
}
示例11: getETHUSD
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getETHUSD() throws IOException {
Ticker ticker = marketDataServiceKraken.getTicker(CurrencyPair.ETH_USD);
return ticker.getLast();
}
示例12: getBTCUSDBitfinex
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getBTCUSDBitfinex() throws IOException {
Ticker ticker = marketDataServiceBitfinex.getTicker(CurrencyPair.BTC_USD);
return ticker.getLast();
}
示例13: getIOTAUSDBitfinex
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getIOTAUSDBitfinex() throws IOException {
Ticker ticker = marketDataServiceBitfinex.getTicker(IOTA_USD);
return ticker.getLast();
}
示例14: getETHUSDBitfinex
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getETHUSDBitfinex() throws IOException {
Ticker ticker = marketDataServiceBitfinex.getTicker(CurrencyPair.ETH_USD);
return ticker.getLast();
}
示例15: notifyObserver
import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
private void notifyObserver(ExchangeRateObserver observer, CurrencyUnitPair pair, Ticker ticker) {
observer.onExchangeRateChange(buildExchangeRateChange(pair, ticker));
}