mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Add printing of stats for trades by currency
This commit is contained in:
parent
1464beb200
commit
0cb4223246
2 changed files with 45 additions and 3 deletions
|
@ -247,14 +247,18 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("DOGE", "Dogecoin"));
|
||||
result.add(new CryptoCurrency("ETH", "Ether"));
|
||||
result.add(new CryptoCurrency("ETC", "Ether Classic"));
|
||||
result.add(new CryptoCurrency("GRC", "Gridcoin"));
|
||||
if (!baseCurrencyCode.equals("LTC"))
|
||||
result.add(new CryptoCurrency("LTC", "Litecoin"));
|
||||
result.add(new CryptoCurrency("XMR", "Monero"));
|
||||
result.add(new CryptoCurrency("MT", "Mycelium Token", true));
|
||||
result.add(new CryptoCurrency("NMC", "Namecoin"));
|
||||
result.add(new CryptoCurrency("SC", "Siacoin"));
|
||||
result.add(new CryptoCurrency("SF", "Siafund"));
|
||||
result.add(new CryptoCurrency("UNO", "Unobtanium"));
|
||||
result.add(new CryptoCurrency("ZEC", "Zcash"));
|
||||
result.sort(TradeCurrency::compareTo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,7 @@ import javafx.collections.ObservableSet;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
|
@ -96,6 +94,10 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
|||
|
||||
statisticsStorage.queueUpForSave(new TradeStatisticsList(new ArrayList<>(tradeStatisticsSet)), 2000);
|
||||
dump();
|
||||
|
||||
// print all currencies sorted by nr. of trades
|
||||
// printAllCurrencyStats();
|
||||
|
||||
}
|
||||
|
||||
public void add(TradeStatistics tradeStatistics, boolean storeLocally) {
|
||||
|
@ -134,4 +136,40 @@ public class TradeStatisticsManager implements PersistedDataHost {
|
|||
jsonFileManager.writeToDisc(Utilities.objectToJson(array), "trade_statistics");
|
||||
}
|
||||
}
|
||||
|
||||
private void printAllCurrencyStats() {
|
||||
Map<String, Set<TradeStatistics>> map1 = new HashMap<>();
|
||||
for (TradeStatistics tradeStatistics : tradeStatisticsSet) {
|
||||
if (CurrencyUtil.isFiatCurrency(tradeStatistics.getCounterCurrency())) {
|
||||
final String counterCurrency = CurrencyUtil.getNameAndCode(tradeStatistics.getCounterCurrency());
|
||||
if (!map1.containsKey(counterCurrency))
|
||||
map1.put(counterCurrency, new HashSet<>());
|
||||
|
||||
map1.get(counterCurrency).add(tradeStatistics);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb1 = new StringBuilder();
|
||||
map1.entrySet().stream()
|
||||
.sorted((o1, o2) -> Integer.valueOf(o2.getValue().size()).compareTo(o1.getValue().size()))
|
||||
.forEach(e -> sb1.append(e.getKey()).append(": ").append(e.getValue().size()).append("\n"));
|
||||
log.error(sb1.toString());
|
||||
|
||||
Map<String, Set<TradeStatistics>> map2 = new HashMap<>();
|
||||
for (TradeStatistics tradeStatistics : tradeStatisticsSet) {
|
||||
if (CurrencyUtil.isCryptoCurrency(tradeStatistics.getCounterCurrency())) {
|
||||
final String counterCurrency = CurrencyUtil.getNameAndCode(tradeStatistics.getCounterCurrency());
|
||||
if (!map2.containsKey(counterCurrency))
|
||||
map2.put(counterCurrency, new HashSet<>());
|
||||
|
||||
map2.get(counterCurrency).add(tradeStatistics);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
map2.entrySet().stream()
|
||||
.sorted((o1, o2) -> Integer.valueOf(o2.getValue().size()).compareTo(o1.getValue().size()))
|
||||
.forEach(e -> sb2.append(e.getKey()).append(": ").append(e.getValue().size()).append("\n"));
|
||||
log.error(sb2.toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue