use of io.bisq.core.provider.price.MarketPrice in project bisq-api by mrosseel.
the class MainViewModelHeadless method setMarketPriceInItems.
private void setMarketPriceInItems() {
priceFeedComboBoxItems.stream().forEach(item -> {
String currencyCode = item.currencyCode;
MarketPrice marketPrice = priceFeedService.getMarketPrice(currencyCode);
String priceString;
if (marketPrice != null && marketPrice.isPriceAvailable()) {
priceString = formatter.formatMarketPrice(marketPrice.getPrice(), currencyCode);
item.setPriceAvailable(true);
item.setExternallyProvidedPrice(marketPrice.isExternallyProvidedPrice());
} else {
priceString = Res.get("shared.na");
item.setPriceAvailable(false);
}
item.setDisplayString(formatter.getCurrencyPair(currencyCode) + ": " + priceString);
final String code = item.currencyCode;
if (selectedPriceFeedComboBoxItemProperty.get() != null && selectedPriceFeedComboBoxItemProperty.get().currencyCode.equals(code)) {
isFiatCurrencyPriceFeedSelected.set(CurrencyUtil.isFiatCurrency(code) && CurrencyUtil.getFiatCurrency(code).isPresent() && item.isPriceAvailable() && item.isExternallyProvidedPrice());
isCryptoCurrencyPriceFeedSelected.set(CurrencyUtil.isCryptoCurrency(code) && CurrencyUtil.getCryptoCurrency(code).isPresent() && item.isPriceAvailable() && item.isExternallyProvidedPrice());
isExternallyProvidedPrice.set(item.isExternallyProvidedPrice());
isPriceAvailable.set(item.isPriceAvailable());
marketPriceUpdated.set(marketPriceUpdated.get() + 1);
}
});
}
Aggregations