use of bisq.core.trade.statistics.TradeStatistics2 in project bisq-core by bisq-network.
the class PublishTradeStatistics method run.
@Override
protected void run() {
try {
runInterceptHook();
if (trade.getDepositTx() != null) {
TradeStatistics2 tradeStatistics = new TradeStatistics2(trade.getOffer().getOfferPayload(), trade.getTradePrice(), trade.getTradeAmount(), trade.getDate(), trade.getDepositTx().getHashAsString());
processModel.getP2PService().addPersistableNetworkPayload(tradeStatistics, true);
}
complete();
} catch (Throwable t) {
failed(t);
}
}
use of bisq.core.trade.statistics.TradeStatistics2 in project bisq-core by bisq-network.
the class PriceFeedService method applyLatestBisqMarketPrice.
public void applyLatestBisqMarketPrice(HashSet<TradeStatistics2> tradeStatisticsSet) {
// takes about 10 ms for 5000 items
Map<String, List<TradeStatistics2>> mapByCurrencyCode = new HashMap<>();
tradeStatisticsSet.forEach(e -> {
final List<TradeStatistics2> list;
final String currencyCode = e.getCurrencyCode();
if (mapByCurrencyCode.containsKey(currencyCode)) {
list = mapByCurrencyCode.get(currencyCode);
} else {
list = new ArrayList<>();
mapByCurrencyCode.put(currencyCode, list);
}
list.add(e);
});
mapByCurrencyCode.values().stream().filter(list -> !list.isEmpty()).forEach(list -> {
list.sort((o1, o2) -> o1.getTradeDate().compareTo(o2.getTradeDate()));
TradeStatistics2 tradeStatistics = list.get(list.size() - 1);
setBisqMarketPrice(tradeStatistics.getCurrencyCode(), tradeStatistics.getTradePrice());
});
}
Aggregations