• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Ticker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.knowm.xchange.dto.marketdata.Ticker的典型用法代码示例。如果您正苦于以下问题:Java Ticker类的具体用法?Java Ticker怎么用?Java Ticker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Ticker类属于org.knowm.xchange.dto.marketdata包,在下文中一共展示了Ticker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: getTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
 * Get Ticker for given pair.
 *
 * @param pair Pair as str, format: BTC_ETC
 * @return the ticker
 *
 * @throws IOException if any error occur while contacting the exchange
 */
Ticker getTicker(CurrencyPair pair) throws IOException;
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:10,代码来源:FreqTradeExchangeService.java


示例17: getPrice

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
 * Determines the price of a CurrencyPair for an Exchange.
 *
 * @param exchangeReference The Exchange.
 * @param currencyPair      The CurrencyPair.
 * @return The price of the CurrencyPair on the Exchange, or null if the CurrencyPair is not on the Exchange.
 */
public BigDecimal getPrice(ExchangeReference exchangeReference, CurrencyPair currencyPair) {
    Ticker ticker = this.tickerCacheService.getTicker(exchangeReference, currencyPair);
    return ticker != null ? ticker.getBid() : null;
}
 
开发者ID:MitchTalmadge,项目名称:Professor-Doge,代码行数:12,代码来源:CryptocurrencyService.java


示例18: getTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
 * Retrieves the cached Ticker for the given Exchange and Currency Pair.
 *
 * @param exchangeReference The ExchangeReference for the desired Exchange.
 * @param currencyPair      The CurrencyPair of the Ticker.
 * @return The Ticker, if one exists.
 */
public Ticker getTicker(ExchangeReference exchangeReference, CurrencyPair currencyPair) {
    return TICKER_CACHE.get(exchangeReference).get(currencyPair);
}
 
开发者ID:MitchTalmadge,项目名称:Professor-Doge,代码行数:11,代码来源:TickerCacheService.java


示例19: getTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
 * Get Ticker from the UpdateableValueLatch
 * @return ticker object
 * @throws InterruptedException thread was interrupted by another thread
 * @throws TimeoutException should only happen if first request times out
 */
Ticker getTicker() throws InterruptedException, TimeoutException {
    return tickerLatch.getValue();
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:10,代码来源:BaseXChangeExchangeRateProvider.java


示例20: setTicker

import org.knowm.xchange.dto.marketdata.Ticker; //导入依赖的package包/类
/**
 * Set the ticker object, called from polling method
 * @param ticker ticker object
 */
void setTicker(Ticker ticker) {
    tickerLatch.setValue(ticker);
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:8,代码来源:BaseXChangeExchangeRateProvider.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RethinkDB类代码示例发布时间:2022-05-22
下一篇:
Java AWTFontManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap