use of network.bisq.api.model.PriceFeed in project bisq-api by mrosseel.
the class BisqProxy method getPriceFeed.
public PriceFeed getPriceFeed(String[] codes) {
final PriceFeedService priceFeedService = injector.getInstance(PriceFeedService.class);
final List<FiatCurrency> fiatCurrencies = preferences.getFiatCurrencies();
final List<CryptoCurrency> cryptoCurrencies = preferences.getCryptoCurrencies();
final Stream<String> codesStream;
if (null == codes || 0 == codes.length)
codesStream = Stream.concat(fiatCurrencies.stream(), cryptoCurrencies.stream()).map(TradeCurrency::getCode);
else
codesStream = Arrays.asList(codes).stream();
final List<MarketPrice> marketPrices = codesStream.map(priceFeedService::getMarketPrice).filter(i -> null != i).collect(toList());
final PriceFeed priceFeed = new PriceFeed();
for (MarketPrice price : marketPrices) priceFeed.prices.put(price.getCurrencyCode(), price.getPrice());
return priceFeed;
}
Aggregations