mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Merge pull request #4781 from chimp1984/use-30-day-average-for-marektcap
Use 30 days average USD/BSQ price for market cap
This commit is contained in:
commit
c707e63f35
3 changed files with 21 additions and 15 deletions
|
@ -21,7 +21,7 @@ import bisq.core.dao.governance.param.Param;
|
|||
import bisq.core.dao.governance.proposal.ProposalValidationException;
|
||||
import bisq.core.locale.GlobalSettings;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.provider.price.MarketPrice;
|
||||
import bisq.core.monetary.Price;
|
||||
import bisq.core.util.FormattingUtils;
|
||||
import bisq.core.util.ParsingUtils;
|
||||
import bisq.core.util.validation.BtcAddressValidator;
|
||||
|
@ -121,10 +121,10 @@ public class BsqFormatter implements CoinFormatter {
|
|||
return amountFormat.format(MathUtils.scaleDownByPowerOf10(amount.value, 2)) + " BSQ";
|
||||
}
|
||||
|
||||
public String formatMarketCap(MarketPrice bsqPriceMarketPrice, MarketPrice fiatMarketPrice, Coin issuedAmount) {
|
||||
if (bsqPriceMarketPrice != null && fiatMarketPrice != null) {
|
||||
double marketCap = bsqPriceMarketPrice.getPrice() * fiatMarketPrice.getPrice() * (MathUtils.scaleDownByPowerOf10(issuedAmount.value, 2));
|
||||
return marketCapFormat.format(MathUtils.doubleToLong(marketCap)) + " " + fiatMarketPrice.getCurrencyCode();
|
||||
public String formatMarketCap(Price usdBsqPrice, Coin issuedAmount) {
|
||||
if (usdBsqPrice != null && issuedAmount != null) {
|
||||
double marketCap = usdBsqPrice.getValue() * (MathUtils.scaleDownByPowerOf10(issuedAmount.value, 6));
|
||||
return marketCapFormat.format(MathUtils.doubleToLong(marketCap)) + " USD";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -2420,13 +2420,11 @@ dao.monitor.blindVote.table.numBlindVotes=No. blind votes
|
|||
dao.factsAndFigures.menuItem.supply=BSQ Supply
|
||||
dao.factsAndFigures.menuItem.transactions=BSQ Transactions
|
||||
|
||||
dao.factsAndFigures.dashboard.marketPrice=Market data
|
||||
dao.factsAndFigures.dashboard.price=Latest BSQ/BTC trade price (in Bisq)
|
||||
dao.factsAndFigures.dashboard.avgPrice90=90 days average BSQ/BTC trade price
|
||||
dao.factsAndFigures.dashboard.avgPrice30=30 days average BSQ/BTC trade price
|
||||
dao.factsAndFigures.dashboard.avgUSDPrice90=90 days volume weighted average USD/BSQ trade price
|
||||
dao.factsAndFigures.dashboard.avgUSDPrice30=30 days volume weighted average USD/BSQ trade price
|
||||
dao.factsAndFigures.dashboard.marketCap=Market capitalisation (based on trade price)
|
||||
dao.factsAndFigures.dashboard.avgUSDPrice90=90 days volume weighted average USD/BSQ price
|
||||
dao.factsAndFigures.dashboard.avgUSDPrice30=30 days volume weighted average USD/BSQ price
|
||||
dao.factsAndFigures.dashboard.marketCap=Market capitalisation (based on 30 days average USD/BSQ price)
|
||||
dao.factsAndFigures.dashboard.availableAmount=Total available BSQ
|
||||
|
||||
dao.factsAndFigures.supply.issuedVsBurnt=BSQ issued v. BSQ burnt
|
||||
|
|
|
@ -115,6 +115,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
private Coin availableAmount;
|
||||
private int gridRow = 0;
|
||||
double howManyStdDevsConstituteOutlier = 10;
|
||||
private Price avg30DayUSDPrice;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -145,6 +146,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
updatePrice();
|
||||
updateAveragePriceFields(avgPrice90TextField, avgPrice30TextField, false);
|
||||
updateAveragePriceFields(avgUSDPrice90TextField, avgUSDPrice30TextField, true);
|
||||
updateMarketCap();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -188,6 +190,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
updateChartData();
|
||||
updateAveragePriceFields(avgPrice90TextField, avgPrice30TextField, false);
|
||||
updateAveragePriceFields(avgUSDPrice90TextField, avgUSDPrice30TextField, true);
|
||||
updateMarketCap();
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,14 +336,16 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
Price bsqPrice = optionalBsqPrice.get();
|
||||
marketPriceLabel.setText(FormattingUtils.formatPrice(bsqPrice) + " BSQ/BTC");
|
||||
|
||||
marketCapTextField.setText(bsqFormatter.formatMarketCap(priceFeedService.getMarketPrice("BSQ"),
|
||||
priceFeedService.getMarketPrice(preferences.getPreferredTradeCurrency().getCode()),
|
||||
availableAmount));
|
||||
|
||||
updateChartData();
|
||||
|
||||
} else {
|
||||
marketPriceLabel.setText(Res.get("shared.na"));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMarketCap() {
|
||||
if (avg30DayUSDPrice != null) {
|
||||
marketCapTextField.setText(bsqFormatter.formatMarketCap(avg30DayUSDPrice, availableAmount));
|
||||
} else {
|
||||
marketCapTextField.setText(Res.get("shared.na"));
|
||||
}
|
||||
}
|
||||
|
@ -394,6 +399,9 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
String avg = FormattingUtils.formatPrice(avgPrice);
|
||||
if (isUSDField) {
|
||||
textField.setText(avg + " USD/BSQ");
|
||||
if (days == 30) {
|
||||
avg30DayUSDPrice = avgPrice;
|
||||
}
|
||||
} else {
|
||||
textField.setText(avg + " BSQ/BTC");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue