mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Add new average bsq price after historical data
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
1b182743a2
commit
c268cc46cb
@ -67,13 +67,14 @@ public class BurningManAccountingService implements DaoSetupService {
|
|||||||
public static final int EARLIEST_BLOCK_HEIGHT = Config.baseCurrencyNetwork().isRegtest() ? 111 : 656035;
|
public static final int EARLIEST_BLOCK_HEIGHT = Config.baseCurrencyNetwork().isRegtest() ? 111 : 656035;
|
||||||
public static final int EARLIEST_DATE_YEAR = 2020;
|
public static final int EARLIEST_DATE_YEAR = 2020;
|
||||||
public static final int EARLIEST_DATE_MONTH = 10;
|
public static final int EARLIEST_DATE_MONTH = 10;
|
||||||
|
public static final int HIST_BSQ_PRICE_LAST_DATE_YEAR = 2022;
|
||||||
|
public static final int HIST_BSQ_PRICE_LAST_DATE_MONTH = 10;
|
||||||
|
|
||||||
private final BurningManAccountingStoreService burningManAccountingStoreService;
|
private final BurningManAccountingStoreService burningManAccountingStoreService;
|
||||||
private final BurningManPresentationService burningManPresentationService;
|
private final BurningManPresentationService burningManPresentationService;
|
||||||
private final TradeStatisticsManager tradeStatisticsManager;
|
private final TradeStatisticsManager tradeStatisticsManager;
|
||||||
private final Preferences preferences;
|
private final Preferences preferences;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<Date, Price> averageBsqPriceByMonth = new HashMap<>(getHistoricalAverageBsqPriceByMonth());
|
private final Map<Date, Price> averageBsqPriceByMonth = new HashMap<>(getHistoricalAverageBsqPriceByMonth());
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, BalanceModel> balanceModelByBurningManName = new HashMap<>();
|
private final Map<String, BalanceModel> balanceModelByBurningManName = new HashMap<>();
|
||||||
@ -161,6 +162,12 @@ public class BurningManAccountingService implements DaoSetupService {
|
|||||||
return getBlocks().stream().filter(block -> block.getHeight() == height).findAny();
|
return getBlocks().stream().filter(block -> block.getHeight() == height).findAny();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Date, Price> getAverageBsqPriceByMonth() {
|
||||||
|
getAverageBsqPriceByMonth(new Date(), HIST_BSQ_PRICE_LAST_DATE_YEAR, HIST_BSQ_PRICE_LAST_DATE_MONTH)
|
||||||
|
.forEach((key, value) -> averageBsqPriceByMonth.put(new Date(key.getTime()), Price.valueOf("BSQ", value.getValue())));
|
||||||
|
return averageBsqPriceByMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Delegates
|
// Delegates
|
||||||
@ -210,7 +217,7 @@ public class BurningManAccountingService implements DaoSetupService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Date, Price> getAverageBsqPriceByMonth(Date from, int toYear, int toMonth) {
|
private Map<Date, Price> getAverageBsqPriceByMonth(Date from, int backToYear, int backToMonth) {
|
||||||
Map<Date, Price> averageBsqPriceByMonth = new HashMap<>();
|
Map<Date, Price> averageBsqPriceByMonth = new HashMap<>();
|
||||||
Calendar calendar = new GregorianCalendar();
|
Calendar calendar = new GregorianCalendar();
|
||||||
calendar.setTime(from);
|
calendar.setTime(from);
|
||||||
@ -218,7 +225,7 @@ public class BurningManAccountingService implements DaoSetupService {
|
|||||||
int month = calendar.get(Calendar.MONTH);
|
int month = calendar.get(Calendar.MONTH);
|
||||||
do {
|
do {
|
||||||
for (; month >= 0; month--) {
|
for (; month >= 0; month--) {
|
||||||
if (year == toYear && month == toMonth) {
|
if (year == backToYear && month == backToMonth) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Date date = DateUtil.getStartOfMonth(year, month);
|
Date date = DateUtil.getStartOfMonth(year, month);
|
||||||
@ -227,7 +234,7 @@ public class BurningManAccountingService implements DaoSetupService {
|
|||||||
}
|
}
|
||||||
year--;
|
year--;
|
||||||
month = 11;
|
month = 11;
|
||||||
} while (year >= toYear);
|
} while (year >= backToYear);
|
||||||
return averageBsqPriceByMonth;
|
return averageBsqPriceByMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,12 +635,9 @@ public class BurningManView extends ActivatableView<ScrollPane, Void> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Date, Price> averageBsqPriceByMonth = burningManAccountingService.getAverageBsqPriceByMonth();
|
Map<Date, Price> averageBsqPriceByMonth = burningManAccountingService.getAverageBsqPriceByMonth();
|
||||||
long ts = System.currentTimeMillis();
|
|
||||||
balanceEntryObservableList.setAll(balanceEntries.stream()
|
balanceEntryObservableList.setAll(balanceEntries.stream()
|
||||||
.map(balanceEntry -> new BalanceEntryItem(balanceEntry, averageBsqPriceByMonth, bsqFormatter, btcFormatter))
|
.map(balanceEntry -> new BalanceEntryItem(balanceEntry, averageBsqPriceByMonth, bsqFormatter, btcFormatter))
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
// 108869: 617 - 1878, 640-1531
|
|
||||||
log.error("balanceEntryObservableList setAll took {} ms size={}", System.currentTimeMillis() - ts, balanceEntryObservableList.size());
|
|
||||||
} else {
|
} else {
|
||||||
balanceEntryObservableList.clear();
|
balanceEntryObservableList.clear();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user