当前位置: 首页>>代码示例>>Java>>正文


Java Ticker类代码示例

本文整理汇总了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;
}
 
开发者ID:coinblesk,项目名称:coinblesk-server,代码行数:23,代码来源:ForexBitcoinService.java

示例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())));
}
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:13,代码来源:FreqTradeMainRunner.java

示例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);
}
 
开发者ID:MitchTalmadge,项目名称:Professor-Doge,代码行数:37,代码来源:ExchangeTickerCacheUpdater.java

示例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);
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:8,代码来源:BaseXChangeExchangeRateProvider.java

示例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();
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:8,代码来源:BaseXChangeExchangeRateProvider.java

示例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);
}
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:6,代码来源:FreqTradeExchangeServiceImpl.java

示例7: TickerDto

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public TickerDto(String exchangeName, Ticker ticker) {
    this.exchangeName = exchangeName;
    this.ticker = ticker;
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:5,代码来源:TickerDto.java

示例8: getTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public Ticker getTicker() {
    return ticker;
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:4,代码来源:TickerDto.java

示例9: setTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public void setTicker(Ticker ticker) {
    this.ticker = ticker;
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:4,代码来源:TickerDto.java

示例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();
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:5,代码来源:ExchangeRate.java

示例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();
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:5,代码来源:ExchangeRate.java

示例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();
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:5,代码来源:ExchangeRate.java

示例13: getIOTAUSDBitfinex

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
public BigDecimal getIOTAUSDBitfinex() throws IOException {
    Ticker ticker = marketDataServiceBitfinex.getTicker(IOTA_USD);
    return ticker.getLast();
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:5,代码来源:ExchangeRate.java

示例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();
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:5,代码来源:ExchangeRate.java

示例15: notifyObserver

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
private void notifyObserver(ExchangeRateObserver observer, CurrencyUnitPair pair, Ticker ticker) {
    observer.onExchangeRateChange(buildExchangeRateChange(pair, ticker));
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:4,代码来源:BaseXChangeExchangeRateProvider.java


注:本文中的org.knowm.xchange.dto.marketdata.Ticker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。