本文整理汇总了Java中org.knowm.xchange.Exchange类的典型用法代码示例。如果您正苦于以下问题:Java Exchange类的具体用法?Java Exchange怎么用?Java Exchange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Exchange类属于org.knowm.xchange包,在下文中一共展示了Exchange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FreqTradeExchangeServiceImpl
import org.knowm.xchange.Exchange; //导入依赖的package包/类
@Autowired
public FreqTradeExchangeServiceImpl(FreqTradeProperties properties, Exchange exchange) {
this.properties = properties;
this.exchange = exchange;
marketDataService = (BittrexMarketDataService) exchange.getMarketDataService();
accountService = exchange.getAccountService();
tradeService = exchange.getTradeService();
if (properties.isDryRun()) {
LOGGER.info("Instance is running with dry_run enabled");
}
// Check if all pairs are available
List<CurrencyPair> markets = getMarkets();
for (CurrencyPair pair : properties.getPairWhitelist()) {
if (!markets.contains(pair)) {
throw new FreqTradeExchangeInitializationException("Pair: " + pair + " is not available");
}
}
}
示例2: getCurrencyPairs
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public Collection<CurrencyPair> getCurrencyPairs(String exchangeName) {
Exchange exchangeByName = getExchangeByName(exchangeName);
if (exchangeByName.getExchangeMetaData() != null) {
return exchangeByName.getExchangeMetaData().getCurrencyPairs().keySet();
} else {
return DEFAULT_CURRENCY_PAIRS;
}
}
示例3: getTicker
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public TickerDto getTicker(String exchangeName, CurrencyPair pair) {
Exchange exchange = getExchangeByName(exchangeName);
try {
MarketDataService marketDataService = exchange.getMarketDataService();
return new TickerDto(exchange.getExchangeSpecification().getExchangeName(), marketDataService.getTicker(pair));
} catch (Exception e) {
return new TickerDto(true, exchangeName, pair);
}
}
示例4: BaseXChangeExchangeRateProvider
import org.knowm.xchange.Exchange; //导入依赖的package包/类
/**
* Construct using an XChange Exchange class object for a set of currencies
* @param exchangeClass Class of XChange exchange we are wrapping
* @param pairs pairs to monitor
*/
protected BaseXChangeExchangeRateProvider(Class<? extends Exchange> exchangeClass,
CurrencyUnitPair... pairs) {
this(exchangeClass,
null,
pairs);
}
示例5: exchange
import org.knowm.xchange.Exchange; //导入依赖的package包/类
@Bean
public Exchange exchange() {
return ExchangeFactory.INSTANCE.createExchangeWithApiKeys(BittrexExchange.class.getName(),
properties.getBittrex().getKey(), properties.getBittrex().getSecret());
}
示例6: prepareAvailableExchanges
import org.knowm.xchange.Exchange; //导入依赖的package包/类
private void prepareAvailableExchanges() {
for (Class<? extends Exchange> exchangeClass : ApplicationConstants.exchangeClasses) {
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(exchangeClass.getName());
exchanges.put(exchangeClass, exchange);
}
}
示例7: getAvailableExchanges
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public Collection<Exchange> getAvailableExchanges() {
return exchanges.values();
}
示例8: getExchangeByName
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public Exchange getExchangeByName(String exchangeName) {
return exchanges.values().stream().filter(exchange -> exchange.getExchangeSpecification().getExchangeName().equals(exchangeName)).findFirst().orElse(null);
}
示例9: getExchangeByClass
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public Exchange getExchangeByClass(Class<? extends Exchange> exchangeClass) {
return exchanges.get(exchangeClass);
}
示例10: TickerData
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public TickerData(CurrencyPair currencyPair, Exchange exchange, BigDecimal bid, BigDecimal ask) {
this.currencyPair = currencyPair;
this.exchange = exchange;
this.bid = bid;
this.ask = ask;
}
示例11: getExchange
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public Exchange getExchange() {
return exchange;
}
示例12: setExchange
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public void setExchange(Exchange exchange) {
this.exchange = exchange;
}
示例13: ActivatedExchange
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public ActivatedExchange(Exchange exchange, boolean tradingMode) {
this.exchange = exchange;
this.tradingMode = tradingMode;
}
示例14: call
import org.knowm.xchange.Exchange; //导入依赖的package包/类
@Override
public ActivatedExchange call() {
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(exchangeSpecs.GetSetupedExchange());
return new ActivatedExchange(exchange, exchangeSpecs.getTradingMode());
}
示例15: LiveFutureTickerWriter
import org.knowm.xchange.Exchange; //导入依赖的package包/类
public LiveFutureTickerWriter(final Exchange anExchange) {
exchange = anExchange;
db = new FutureTickerDatabase(anExchange.getExchangeSpecification().getExchangeName());
try {
for (FuturesContract contract : FuturesContract.values()) {
Map<CurrencyPair, SortedSet<Trade>> map = new HashMap<>();
for (CurrencyPair pair : anExchange.getExchangeSymbols()) {
// TickerDatabase db = new
// TickerDatabase(anExchange.getExchangeSpecification().getExchangeName());
map.put(pair, new TreeSet<Trade>());
}
lastTrades.put(contract, map);
}
} catch (ExchangeException | NotAvailableFromExchangeException | NotYetImplementedForExchangeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
updaterThread = new Thread("LiveFutureTickerWriter for " + anExchange.getExchangeSpecification().getExchangeName()) {
@Override
public void run() {
while (running) {
try {
for (FuturesContract contract : FuturesContract.values()) {
for (CurrencyPair pair : anExchange.getExchangeSymbols()) {
try {
SortedSet<Trade> newTrades = new TreeSet<>(anExchange.getMarketDataService().getTrades(pair, contract).getTrades());
SortedSet<Trade> notSeen = new TreeSet<>(newTrades);
notSeen.removeAll(lastTrades.get(contract).get(pair));
lastTrades.get(contract).put(pair, newTrades);
db.putAll(contract, notSeen);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
} catch (ExchangeException | NotAvailableFromExchangeException | NotYetImplementedForExchangeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
updaterThread.setDaemon(true);
updaterThread.start();
}