Use always precision 8 for json dumped data

This commit is contained in:
Manfred Karrer 2016-08-26 12:02:41 +02:00
parent f1996c6e8a
commit 216b4f44e8
3 changed files with 10 additions and 10 deletions

View file

@ -99,8 +99,8 @@ public class OfferForJson {
primaryMarketVolumeDisplayString = coinFormat.noCode().format(getAmountAsCoin()).toString(); primaryMarketVolumeDisplayString = coinFormat.noCode().format(getAmountAsCoin()).toString();
primaryMarketPrice = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(value, 8)); primaryMarketPrice = MathUtils.roundDoubleToLong(MathUtils.scaleUpByPowerOf10(value, 8));
primaryMarketMinAmount = getMinVolumeAsFiat().longValue(); primaryMarketMinAmount = (long) MathUtils.scaleUpByPowerOf10(getMinVolumeAsFiat().longValue(), 4);
primaryMarketAmount = getVolumeAsFiat().longValue(); primaryMarketAmount = (long) MathUtils.scaleUpByPowerOf10(getVolumeAsFiat().longValue(), 4);
primaryMarketMinVolume = getMinAmountAsCoin().longValue(); primaryMarketMinVolume = getMinAmountAsCoin().longValue();
primaryMarketVolume = getAmountAsCoin().longValue(); primaryMarketVolume = getAmountAsCoin().longValue();
@ -113,11 +113,11 @@ public class OfferForJson {
primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolumeAsFiat()).toString(); primaryMarketMinVolumeDisplayString = fiatFormat.noCode().format(getMinVolumeAsFiat()).toString();
primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolumeAsFiat()).toString(); primaryMarketVolumeDisplayString = fiatFormat.noCode().format(getVolumeAsFiat()).toString();
primaryMarketPrice = priceAsFiat.longValue(); primaryMarketPrice = (long) MathUtils.scaleUpByPowerOf10(priceAsFiat.longValue(), 4);
primaryMarketMinAmount = getMinAmountAsCoin().longValue(); primaryMarketMinAmount = getMinAmountAsCoin().longValue();
primaryMarketAmount = getAmountAsCoin().longValue(); primaryMarketAmount = getAmountAsCoin().longValue();
primaryMarketMinVolume = getMinVolumeAsFiat().longValue(); primaryMarketMinVolume = (long) MathUtils.scaleUpByPowerOf10(getMinVolumeAsFiat().longValue(), 4);
primaryMarketVolume = getVolumeAsFiat().longValue(); primaryMarketVolume = (long) MathUtils.scaleUpByPowerOf10(getVolumeAsFiat().longValue(), 4);
} }
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -75,19 +75,19 @@ public final class TradeStatisticsForJson {
primaryMarketTradeVolumeDisplayString = coinFormat.noCode().format(getTradeAmount()).toString(); primaryMarketTradeVolumeDisplayString = coinFormat.noCode().format(getTradeAmount()).toString();
primaryMarketTradeAmountDisplayString = fiatFormat.noCode().format(getTradeVolume()).toString(); primaryMarketTradeAmountDisplayString = fiatFormat.noCode().format(getTradeVolume()).toString();
primaryMarketTradeAmount = getTradeVolume().longValue(); primaryMarketTradeAmount = (long) MathUtils.scaleUpByPowerOf10(getTradeVolume().longValue(), 4);
primaryMarketTradeVolume = getTradeAmount().longValue(); primaryMarketTradeVolume = getTradeAmount().longValue();
} else { } else {
currencyPair = "BTC/" + currency; currencyPair = "BTC/" + currency;
tradePriceDisplayString = fiatFormat.noCode().format(tradePriceAsFiat).toString(); tradePriceDisplayString = fiatFormat.noCode().format(tradePriceAsFiat).toString();
primaryMarketTradePrice = tradePriceAsFiat.longValue(); primaryMarketTradePrice = (long) MathUtils.scaleUpByPowerOf10(tradePriceAsFiat.longValue(), 4);
primaryMarketTradeAmountDisplayString = coinFormat.noCode().format(getTradeAmount()).toString(); primaryMarketTradeAmountDisplayString = coinFormat.noCode().format(getTradeAmount()).toString();
primaryMarketTradeVolumeDisplayString = fiatFormat.noCode().format(getTradeVolume()).toString(); primaryMarketTradeVolumeDisplayString = fiatFormat.noCode().format(getTradeVolume()).toString();
primaryMarketTradeAmount = getTradeAmount().longValue(); primaryMarketTradeAmount = getTradeAmount().longValue();
primaryMarketTradeVolume = getTradeVolume().longValue(); primaryMarketTradeVolume = (long) MathUtils.scaleUpByPowerOf10(getTradeVolume().longValue(), 4);
} }
} catch (Throwable t) { } catch (Throwable t) {
log.error("Error at setDisplayStrings: " + t.getMessage()); log.error("Error at setDisplayStrings: " + t.getMessage());

View file

@ -61,9 +61,9 @@ public class TradeStatisticsManager {
this.cryptoCurrencyListJsonStorage.initWithFileName("crypto_currency_list.json"); this.cryptoCurrencyListJsonStorage.initWithFileName("crypto_currency_list.json");
ArrayList<CurrencyTuple> cryptoCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedCryptoCurrencies().stream() ArrayList<CurrencyTuple> cryptoCurrencyList = new ArrayList<>(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
.map(e -> new CurrencyTuple(e.getCode(), e.getName())) .map(e -> new CurrencyTuple(e.getCode(), e.getName(), 8))
.collect(Collectors.toList())); .collect(Collectors.toList()));
cryptoCurrencyList.add(0, new CurrencyTuple("BTC", "Bitcoin")); cryptoCurrencyList.add(0, new CurrencyTuple("BTC", "Bitcoin", 8));
cryptoCurrencyListJsonStorage.queueUpForSave(new PlainTextWrapper(Utilities.objectToJson(cryptoCurrencyList)), 2000); cryptoCurrencyListJsonStorage.queueUpForSave(new PlainTextWrapper(Utilities.objectToJson(cryptoCurrencyList)), 2000);
} }