diff --git a/.editorconfig b/.editorconfig index dcf01fb3..e35cb503 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,7 +8,7 @@ indent_size = 4 tab_width = 4 trim_trailing_whitespace = true insert_final_newline = false -max_line_length = 120 +max_line_length = 140 ij_continuation_indent_size = 4 ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index f77ab75b..b44f9949 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -39,7 +39,7 @@ - + diff --git a/gradle.properties b/gradle.properties index 5bfee169..ce7502f0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=3.3.6 +projectVersion=3.3.7 pf4jVersion=3.4.0 xchangeVersion=5.0.4 requiredEverytradeVersion=>=20210427 diff --git a/plugin-api/src/main/java/io/everytrade/server/model/Currency.java b/plugin-api/src/main/java/io/everytrade/server/model/Currency.java index b167dd8a..cc842423 100644 --- a/plugin-api/src/main/java/io/everytrade/server/model/Currency.java +++ b/plugin-api/src/main/java/io/everytrade/server/model/Currency.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.EnumSet; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -125,22 +126,33 @@ public enum Currency { PAXG(false, Instant.parse("2019-09-26T00:00:00Z"), "PAX Gold"), CAKE(false, Instant.parse("2021-01-30T00:00:00Z"), "PancakeSwap"), BAL(false, Instant.parse("2020-06-24T00:00:00Z"), "Balancer"), - BEAM(false, Instant.parse("2019-01-18T00:00:00Z"), "Beam"); + BEAM(false, Instant.parse("2019-01-18T00:00:00Z"), "Beam"), + _1INCH("1INCH",false, Instant.parse("2020-12-25T00:00:00Z"), "1inch"); + private final String code; private final int decimalDigits; private final boolean fiat; private final Instant introduction; private final String description; Currency(boolean fiat, Instant introduction, String description) { - this(fiat ? 2 : 8, fiat, introduction, description); + this(null, fiat ? 2 : 8, fiat, introduction, description); } - Currency(int decimalDigits, boolean fiat, Instant introduction, String description) { + Currency(String code, boolean fiat, Instant introduction, String description) { + this(code, fiat ? 2 : 8, fiat, introduction, description); + } + + Currency(String code, int decimalDigits, boolean fiat, Instant introduction, String description) { this.decimalDigits = decimalDigits; this.fiat = fiat; this.introduction = introduction; this.description = description; + this.code = code == null ? name() : code; + } + + public String code() { + return code; } public int getDecimalDigits() { @@ -177,4 +189,14 @@ public static Set getFiatsExcept(Set exceptions) { .filter(it -> !exceptions.contains(it)) .collect(Collectors.toCollection(() -> EnumSet.noneOf(Currency.class))); } + + public static Currency fromCode(String code) { + Objects.requireNonNull(code, "code is null"); + for (Currency c : values()) { + if (code.equals(c.code())) { + return c; + } + } + throw new IllegalArgumentException("No enum constant " + Currency.class.getCanonicalName() + "." + code); + } } diff --git a/plugin-api/src/main/java/io/everytrade/server/model/CurrencyPair.java b/plugin-api/src/main/java/io/everytrade/server/model/CurrencyPair.java index 2eb4dd72..debc82de 100644 --- a/plugin-api/src/main/java/io/everytrade/server/model/CurrencyPair.java +++ b/plugin-api/src/main/java/io/everytrade/server/model/CurrencyPair.java @@ -24,7 +24,7 @@ public enum CurrencyPosition {BASE, QUOTE} public CurrencyPair(String base, String quote) { - this(Currency.valueOf(base), Currency.valueOf(quote)); + this(Currency.fromCode(base), Currency.fromCode(quote)); } public CurrencyPair(Currency base, Currency quote) { diff --git a/plugin-api/src/main/java/io/everytrade/server/plugin/api/rateprovider/Rate.java b/plugin-api/src/main/java/io/everytrade/server/plugin/api/rateprovider/Rate.java index b3bc71da..1cdcb4aa 100644 --- a/plugin-api/src/main/java/io/everytrade/server/plugin/api/rateprovider/Rate.java +++ b/plugin-api/src/main/java/io/everytrade/server/plugin/api/rateprovider/Rate.java @@ -40,8 +40,8 @@ public Rate( ) { this( value, - Currency.valueOf(base), - Currency.valueOf(quote), + Currency.fromCode(base), + Currency.fromCode(quote), validityStartIncl, validityEndExcl, sourceType, diff --git a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/BlockchainApiTransactionBean.java b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/BlockchainApiTransactionBean.java index 85514f3e..479f02cc 100644 --- a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/BlockchainApiTransactionBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/BlockchainApiTransactionBean.java @@ -41,8 +41,8 @@ public BlockchainApiTransactionBean( id = transaction.getTxHash(); timestamp = Instant.ofEpochMilli(transaction.getTimestamp()); type = transaction.isDirectionSend() ? TransactionType.SELL : TransactionType.BUY; - this.base = Currency.valueOf(base.toUpperCase()); - this.quote = Currency.valueOf(quote.toUpperCase()); + this.base = Currency.fromCode(base.toUpperCase()); + this.quote = Currency.fromCode(quote.toUpperCase()); this.price = null; // it will be automatically added from the market in everytrade. feeCurrency = this.base; originalAmount = Client.satoshisToBigDecimal(transaction.getAmount()).abs(); diff --git a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/EveryTradeApiTransactionBean.java b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/EveryTradeApiTransactionBean.java index a372fed8..40b0b0a8 100644 --- a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/EveryTradeApiTransactionBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/EveryTradeApiTransactionBean.java @@ -107,15 +107,15 @@ public String getFeeCurrency() { } public TransactionCluster toTransactionCluster() { - final Currency base = Currency.valueOf(Objects.requireNonNull(this.base)); - final Currency quote = Currency.valueOf(Objects.requireNonNull(this.quote)); + final Currency base = Currency.fromCode(Objects.requireNonNull(this.base)); + final Currency quote = Currency.fromCode(Objects.requireNonNull(this.quote)); try { new CurrencyPair(base, quote); } catch (CurrencyPair.FiatCryptoCombinationException e) { throw new DataValidationException(e.getMessage()); } - final Currency parsedFeeCurrency = Currency.valueOf(Objects.requireNonNull(feeCurrency)); + final Currency parsedFeeCurrency = Currency.fromCode(Objects.requireNonNull(feeCurrency)); final List related; final boolean ignoredFee; if (parsedFeeCurrency == base || parsedFeeCurrency == quote) { diff --git a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/GbApiTransactionBean.java b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/GbApiTransactionBean.java index 4d36d9fb..2ce9aa7e 100644 --- a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/GbApiTransactionBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/GbApiTransactionBean.java @@ -129,8 +129,8 @@ public String getStatus() { } public TransactionCluster toTransactionCluster() { - final Currency baseCurrency = Currency.valueOf(base); - final Currency quoteCurrency = Currency.valueOf(quote); + final Currency baseCurrency = Currency.fromCode(base); + final Currency quoteCurrency = Currency.fromCode(quote); try { new CurrencyPair(baseCurrency, quoteCurrency); } catch (CurrencyPair.FiatCryptoCombinationException e) { @@ -148,7 +148,7 @@ public TransactionCluster toTransactionCluster() { quoteCurrency, TransactionType.FEE, expense, - Currency.valueOf(expenseCurrency), + Currency.fromCode(expenseCurrency), getRemoteUid() ) ); diff --git a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/OkexApiTransactionBean.java b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/OkexApiTransactionBean.java index cbeebac8..c593e8c4 100644 --- a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/OkexApiTransactionBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/OkexApiTransactionBean.java @@ -37,7 +37,7 @@ public class OkexApiTransactionBean { FAST_CURRENCY_PAIRS = new HashMap<>(); for (CurrencyPair currencyPair : CurrencyPair.getTradeablePairs()) { FAST_CURRENCY_PAIRS.put( - String.format("%s-%s", currencyPair.getBase().name(), currencyPair.getQuote().name()), currencyPair + String.format("%s-%s", currencyPair.getBase().code(), currencyPair.getQuote().code()), currencyPair ); } } @@ -52,7 +52,7 @@ public OkexApiTransactionBean(OrderInfo orderInfo) { side = TransactionType.valueOf(orderInfo.getSide().toUpperCase()); instrumentIdBase = toCurrencyPair(orderInfo.getInstrument_id()).getBase(); instrumentIdQuote = toCurrencyPair(orderInfo.getInstrument_id()).getQuote(); - feeCurrency = Currency.valueOf(orderInfo.getFee_currency()); + feeCurrency = Currency.fromCode(orderInfo.getFee_currency()); filledSize = new BigDecimal(orderInfo.getFilled_size()); priceAvg = new BigDecimal(orderInfo.getPrice_avg()); fee = new BigDecimal(orderInfo.getFee()); diff --git a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/XChangeApiTransactionBean.java b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/XChangeApiTransactionBean.java index a157b429..fa07bb43 100644 --- a/plugin-base/src/main/java/io/everytrade/server/parser/exchange/XChangeApiTransactionBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/parser/exchange/XChangeApiTransactionBean.java @@ -119,11 +119,11 @@ private TransactionType getTransactionType(Order.OrderType orderType) { private Currency convert(org.knowm.xchange.currency.Currency currency) { try { - return Currency.valueOf(currency.getCurrencyCode()); + return Currency.fromCode(currency.getCurrencyCode()); } catch (IllegalArgumentException e) { final org.knowm.xchange.currency.Currency currencyConverted = org.knowm.xchange.currency.Currency.getInstance(currency.getCurrencyCode()).getCommonlyUsedCurrency(); - return Currency.valueOf(currencyConverted.getCurrencyCode()); + return Currency.fromCode(currencyConverted.getCurrencyCode()); } } } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/BlockchainDownloader.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/BlockchainDownloader.java index 63237e59..f0bfbe24 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/BlockchainDownloader.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/BlockchainDownloader.java @@ -47,7 +47,7 @@ public BlockchainDownloader( String importFeesFromWithdrawals ) { Objects.requireNonNull(cryptoCurrency); - if (!SUPPORTED_CRYPTO.contains(Currency.valueOf(cryptoCurrency))) { + if (!SUPPORTED_CRYPTO.contains(Currency.fromCode(cryptoCurrency))) { throw new IllegalArgumentException(String.format("Unsupported crypto currency %s.", cryptoCurrency)); } this.cryptoCurrency = cryptoCurrency; diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/ExchangeBean.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/ExchangeBean.java index 965f72bc..45ecc9f7 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/ExchangeBean.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/ExchangeBean.java @@ -78,9 +78,9 @@ protected TransactionType detectTransactionType(Currency fromCurrency, Currency } else { throw new DataValidationException( UNSUPPORTED_CURRENCY_PAIR - .concat(fromCurrency.name()) + .concat(fromCurrency.code()) .concat("/") - .concat(toCurrency.name()) + .concat(toCurrency.code()) ); } } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BinanceBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BinanceBeanV1.java index 0ee8d264..735f2ca8 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BinanceBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BinanceBeanV1.java @@ -86,7 +86,7 @@ public void setFee(BigDecimal value) { @Parsed(field = "Fee Coin") public void setFeeCurrency(String value) { try { - feeCoin = Currency.valueOf(value); + feeCoin = Currency.fromCode(value); } catch (IllegalArgumentException e) { feeCoin = null; } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitfinexBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitfinexBeanV1.java index c0615e58..06b1c302 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitfinexBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitfinexBeanV1.java @@ -41,8 +41,8 @@ public void setUid(String value) { @Parsed(field = "PAIR") public void setPair(String value) { final String[] values = value.split("/"); - pairBase = Currency.valueOf(values[0]); - pairQuote = Currency.valueOf(values[1]); + pairBase = Currency.fromCode(values[0]); + pairQuote = Currency.fromCode(values[1]); } @Parsed(field = "AMOUNT") @@ -69,7 +69,7 @@ public void setFee(BigDecimal value) { @Parsed(field = "FEE CURRENCY") public void setFeeCurrency(String value) { try { - feeCurrency = Currency.valueOf(value); + feeCurrency = Currency.fromCode(value); } catch (IllegalArgumentException e) { feeCurrency = null; } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitflyerBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitflyerBeanV1.java index 74cc5930..28e72d35 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitflyerBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitflyerBeanV1.java @@ -49,7 +49,7 @@ public void setTradedPrice(BigDecimal value) { @Parsed(field = "Currency 1") public void setCurrency1(String value) { - this.currency1 = Currency.valueOf(value); + this.currency1 = Currency.fromCode(value); } @Parsed(field = "Amount (Currency 1)", defaultNullRead = "0") @@ -67,7 +67,7 @@ public void setFee(BigDecimal value) { @Parsed(field = "Currency 2") public void setCurrency2(String value) { - this.currency2 = Currency.valueOf(value); + this.currency2 = Currency.fromCode(value); } @Parsed(field = "Order ID") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitmexBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitmexBeanV1.java index 81c301e0..38cfbb8b 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitmexBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitmexBeanV1.java @@ -60,7 +60,7 @@ public void setSymbol(String value) { String mappedPair; String replaceBase = findStarts(value); if (replaceBase != null) { - mappedPair = value.replaceFirst(replaceBase, CURRENCIES.get(replaceBase).name()); + mappedPair = value.replaceFirst(replaceBase, CURRENCIES.get(replaceBase).code()); } else { mappedPair = value; } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitstampBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitstampBeanV1.java index 024a755b..4e7ac7e0 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitstampBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BitstampBeanV1.java @@ -42,7 +42,7 @@ public void setDate(Date date) { public void setAmount(String amount) { String[] amountParts = amount.split(" "); String mBase = amountParts[1]; - amountCurrency = Currency.valueOf(mBase); + amountCurrency = Currency.fromCode(mBase); if (amountParts[0].isEmpty()) { throw new DataValidationException("BaseQuantity can not be null or empty."); } @@ -56,7 +56,7 @@ public void setAmount(String amount) { @Parsed(field = "Value") public void setValue(String value) { String[] valueParts = value.split(" "); - valueCurrency = Currency.valueOf(valueParts[1]); + valueCurrency = Currency.fromCode(valueParts[1]); if (valueParts[0].isEmpty()) { this.value = BigDecimal.ZERO; } else { @@ -66,7 +66,7 @@ public void setValue(String value) { @Parsed(field = "Rate") public void setRate(String rate) { - rateCurrency = Currency.valueOf(rate.split(" ")[1]); + rateCurrency = Currency.fromCode(rate.split(" ")[1]); } @Parsed(field = "Fee") @@ -77,7 +77,7 @@ public void setFee(String fee) { } else { this.fee = new BigDecimal(feeParts[0]); } - feeCurrency = Currency.valueOf(feeParts[1]); + feeCurrency = Currency.fromCode(feeParts[1]); } @Parsed(field = "Sub Type") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV1.java index 8a3d24e8..41a76947 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV1.java @@ -43,8 +43,8 @@ public void setExchange(String exchange) { String[] exchangeParts = exchange.split("-"); String mQuote = exchangeParts[0]; String mBase = exchangeParts[1]; - exchangeQuote = Currency.valueOf(mQuote); - exchangeBase = Currency.valueOf(mBase); + exchangeQuote = Currency.fromCode(mQuote); + exchangeBase = Currency.fromCode(mBase); } @Parsed(field = "Type") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV2.java index d83d82b9..11661c8f 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV2.java @@ -44,8 +44,8 @@ public void setEchange(String exchange) { String[] exchangeParts = exchange.split("-"); String mQuote = exchangeParts[0]; String mBase = exchangeParts[1]; - exchangeQuote = Currency.valueOf(mQuote); - exchangeBase = Currency.valueOf(mBase); + exchangeQuote = Currency.fromCode(mQuote); + exchangeBase = Currency.fromCode(mBase); } @Parsed(field = "OrderType") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV3.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV3.java index 5855933a..72dbdef0 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV3.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/BittrexBeanV3.java @@ -42,8 +42,8 @@ public void setEchange(String exchange) { String[] exchangeParts = exchange.split("-"); String mQuote = exchangeParts[0]; String mBase = exchangeParts[1]; - exchangeQuote = Currency.valueOf(mQuote); - exchangeBase = Currency.valueOf(mBase); + exchangeQuote = Currency.fromCode(mQuote); + exchangeBase = Currency.fromCode(mBase); } @Parsed(field = "OrderType") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseBeanV1.java index 3f32ed6e..1ce50f7e 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseBeanV1.java @@ -46,7 +46,7 @@ public void setTransactionType(String value) { @Parsed(field = "Asset") public void setAsset(String value) { - asset = Currency.valueOf(value); + asset = Currency.fromCode(value); } @Parsed(field = "Quantity Transacted") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseProBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseProBeanV1.java index 1139e589..5e2f3791 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseProBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinbaseProBeanV1.java @@ -51,8 +51,8 @@ public void setTradeId(String value) { @Parsed(field = "product") public void setProduct(String value) { final String[] split = value.split("-"); - productBase = Currency.valueOf(split[0]); - productQuote = Currency.valueOf(split[1]); + productBase = Currency.fromCode(split[0]); + productQuote = Currency.fromCode(split[1]); } @Parsed(field = "side") @@ -73,7 +73,7 @@ public void setSize(BigDecimal value) { @Parsed(field = "size unit") public void setSizeUnit(String value) { - sizeUnit = Currency.valueOf(value); + sizeUnit = Currency.fromCode(value); } @Parsed(field = "price") @@ -90,7 +90,7 @@ public void setFee(BigDecimal value) { @Parsed(field = "price/fee/total unit") public void setPriceFeeTotalUnit(String value) { - setPriceFeeTotalUnit = Currency.valueOf(value); + setPriceFeeTotalUnit = Currency.fromCode(value); } @Override @@ -98,14 +98,14 @@ public TransactionCluster toTransactionCluster() { if (!sizeUnit.equals(productBase)) { throw new DataValidationException(String.format( BASE_DIFFERS_FROM_UNIT_SIZE, - productBase.name(), sizeUnit.name() + productBase.code(), sizeUnit.code() )); } if (!setPriceFeeTotalUnit.equals(productQuote)) { throw new DataValidationException(String.format( QUOTE_DIFFERS_FROM_PRICE_FEE_TOTAL_UNIT, - productQuote.name(), setPriceFeeTotalUnit.name()) + productQuote.code(), setPriceFeeTotalUnit.code()) ); } validateCurrencyPair(productBase, productQuote); diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV1.java index 17e47f8e..0c5fc761 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV1.java @@ -64,7 +64,7 @@ public void setAmount(BigDecimal amount) { @Parsed(field = "Amount Currency") public void setAmountCurrency(String curr) { - amountCurrency = Currency.valueOf(curr); + amountCurrency = Currency.fromCode(curr); } @Parsed(field = "Price", defaultNullRead = "0") @@ -74,7 +74,7 @@ public void setPrice(BigDecimal price) { @Parsed(field = "Price Currency") public void setPriceCurrency(String curr) { - priceCurrency = Currency.valueOf(curr); + priceCurrency = Currency.fromCode(curr); } @Parsed(field = "Fee", defaultNullRead = "0") @@ -84,7 +84,7 @@ public void setFee(BigDecimal fee) { @Parsed(field = "Fee Currency") public void setFeeCurrency(String curr) { - auxFeeCurrency = Currency.valueOf(curr); + auxFeeCurrency = Currency.fromCode(curr); } @Parsed(field = "Status") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV2.java index 6a83642b..a0eacf70 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinmateBeanV2.java @@ -64,7 +64,7 @@ public void setAmount(BigDecimal amount) { @Parsed(field = "Currency Amount") public void setCurrencyAmount(String curr) { - currencyAmount = Currency.valueOf(curr); + currencyAmount = Currency.fromCode(curr); } @Parsed(field = "Price", defaultNullRead = "0") @@ -74,7 +74,7 @@ public void setPrice(BigDecimal price) { @Parsed(field = "Currency Price") public void setCurrencyPrice(String curr) { - currencyPrice = Currency.valueOf(curr); + currencyPrice = Currency.fromCode(curr); } @Parsed(field = "Fee", defaultNullRead = "0") @@ -84,7 +84,7 @@ public void setFee(BigDecimal fee) { @Parsed(field = "Currency Fee") public void setFeeCurrency(String curr) { - auxCurrencyFee = Currency.valueOf(curr); + auxCurrencyFee = Currency.fromCode(curr); } @Parsed(field = "Status") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV1.java index dba7f998..e7bf1aa7 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV1.java @@ -37,12 +37,12 @@ public void setAction(String value){ @Parsed(field = "currency") public void setCurrency(String value) { - currenncy = Currency.valueOf(value); + currenncy = Currency.fromCode(value); } @Parsed(field = "base_currency") public void setBaseCurrency(String value) { - baseCurrenncy = Currency.valueOf(value); + baseCurrenncy = Currency.fromCode(value); } @Parsed(field = "amount") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV2.java index 7ed8bac9..97f34507 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/CoinsquareBeanV2.java @@ -31,7 +31,7 @@ public void setDate(Date value) { @Parsed(field = "from_currency") public void setFromCurrency(String value) { - fromCurrenncy = Currency.valueOf(value); + fromCurrenncy = Currency.fromCode(value); } @Parsed(field = "from_amount") @@ -42,7 +42,7 @@ public void setFromAmount(BigDecimal value) { @Parsed(field = "to_currency") public void setToCurrency(String value) { - toCurrenncy = Currency.valueOf(value); + toCurrenncy = Currency.fromCode(value); } @Parsed(field = "to_amount") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV1.java index 7a62ff8f..56b741ad 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV1.java @@ -41,8 +41,8 @@ public void setDate(Date date) { @Parsed(field = "SYMBOL") public void setSymbol(String symbol) { String[] symbolParts = symbol.split("/"); - symbolBase = Currency.valueOf(symbolParts[0]); - symbolQuote = Currency.valueOf(symbolParts[1]); + symbolBase = Currency.fromCode(symbolParts[0]); + symbolQuote = Currency.fromCode(symbolParts[1]); } @Parsed(field = "ACTION") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV2.java index ca2ed1be..14fd8c26 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/EveryTradeBeanV2.java @@ -40,8 +40,8 @@ public void setDate(Date date) { @Parsed(field = "SYMBOL") public void setSymbol(String symbol) { String[] symbolParts = symbol.split("/"); - symbolBase = Currency.valueOf(symbolParts[0]); - symbolQuote = Currency.valueOf(symbolParts[1]); + symbolBase = Currency.fromCode(symbolParts[0]); + symbolQuote = Currency.fromCode(symbolParts[1]); } @Parsed(field = "ACTION") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV1.java index c8d7f927..03fede3a 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV1.java @@ -65,7 +65,7 @@ public void setCashAmount(BigDecimal cash) { @Parsed(field = "Cash Currency") public void setCashCurrency(String cur) { - cashCurrency = Currency.valueOf(cur); + cashCurrency = Currency.fromCode(cur); } @Parsed(field = "Crypto Amount", defaultNullRead = "0") @@ -81,7 +81,7 @@ public void setCryptoCurrency(String cryptoCurrency) { if ("LBTC".equalsIgnoreCase(cryptoCurrency)) { //BTC Lightening this.cryptoCurrency = Currency.BTC; } else { - this.cryptoCurrency = Currency.valueOf(cryptoCurrency); + this.cryptoCurrency = Currency.fromCode(cryptoCurrency); } } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV2.java index f9586552..6d6a5d5e 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/GeneralBytesBeanV2.java @@ -72,7 +72,7 @@ public void setCashAmount(BigDecimal cash) { @Parsed(field = "Cash Currency") public void setCashCurrency(String cur) { - cashCurrency = Currency.valueOf(cur); + cashCurrency = Currency.fromCode(cur); } @Parsed(field = "Crypto Amount", defaultNullRead = "0") @@ -88,7 +88,7 @@ public void setCryptoCurrency(String cryptoCurrency) { if ("LBTC".equalsIgnoreCase(cryptoCurrency)) { //BTC Lightening this.cryptoCurrency = Currency.BTC; } else { - this.cryptoCurrency = Currency.valueOf(cryptoCurrency); + this.cryptoCurrency = Currency.fromCode(cryptoCurrency); } } @@ -111,7 +111,7 @@ public void setExpense(BigDecimal value) { @Parsed(field = "Expense Currency") public void setExpenseCurrency(String value) { - expenseCurrency = Currency.valueOf(value); + expenseCurrency = Currency.fromCode(value); } @Override diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV1.java index 0e8a8451..9ba9ddee 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV1.java @@ -40,8 +40,8 @@ public void setDate(Date date) { @Parsed(field = "Instrument") public void setInstrument(String instrument) { String[] instrumentParts = instrument.split("/"); - instrumentBase = Currency.valueOf(instrumentParts[0]); - instrumentQuote = Currency.valueOf(instrumentParts[1]); + instrumentBase = Currency.fromCode(instrumentParts[0]); + instrumentQuote = Currency.fromCode(instrumentParts[1]); } @Parsed(field = "Trade ID") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV2.java index b09b3c0b..6ba0dd58 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HitBtcBeanV2.java @@ -40,8 +40,8 @@ public void setDate(Date date) { @Parsed(field = "Instrument") public void setInstrument(String instrument) { String[] instrumentParts = instrument.split("/"); - instrumentBase = Currency.valueOf(instrumentParts[0]); - instrumentQuote = Currency.valueOf(instrumentParts[1]); + instrumentBase = Currency.fromCode(instrumentParts[0]); + instrumentQuote = Currency.fromCode(instrumentParts[1]); } @Parsed(field = "Trade ID") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HuobiBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HuobiBeanV1.java index 39a75a9f..94112949 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HuobiBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/HuobiBeanV1.java @@ -49,8 +49,8 @@ public void setType(String value) { @Parsed(field = "Pair") public void setPair(String value) { final String[] values = value.split("/"); - pairBase = Currency.valueOf(values[0]); - pairQuote = Currency.valueOf(values[1]); + pairBase = Currency.fromCode(values[0]); + pairQuote = Currency.fromCode(values[1]); } @Parsed(field = "Side") @@ -127,7 +127,7 @@ public TransactionCluster toTransactionCluster() { private Currency findEnds(String value) { List matchedCurrencies = Arrays .stream(Currency.values()) - .filter(currency -> value.endsWith(currency.name())) + .filter(currency -> value.endsWith(currency.code())) .collect(Collectors.toList()); if (matchedCurrencies.size() == 1) { return matchedCurrencies.get(0); diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/KrakenBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/KrakenBeanV1.java index a51a15dd..e96c58e6 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/KrakenBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/KrakenBeanV1.java @@ -43,11 +43,11 @@ public class KrakenBeanV1 extends ExchangeBean { if (value.equals(Currency.BTC)) { continue; } - CURRENCY_SHORT_CODES.put(value.name(), value); + CURRENCY_SHORT_CODES.put(value.code(), value); if (value.isFiat()) { - CURRENCY_LONG_CODES.put("Z" + value.name(), value); + CURRENCY_LONG_CODES.put("Z" + value.code(), value); } else { - CURRENCY_LONG_CODES.put("X" + value.name(), value); + CURRENCY_LONG_CODES.put("X" + value.code(), value); } } } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/LocalBitcoinsBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/LocalBitcoinsBeanV1.java index 57153a21..9dea2a59 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/LocalBitcoinsBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/LocalBitcoinsBeanV1.java @@ -73,7 +73,7 @@ public void setFiatAmount(BigDecimal value) { @Parsed(field = "currency") public void setCurrency(String value) { - currency = Currency.valueOf(value); + currency = Currency.fromCode(value); if (Currency.BTC.equals(currency)) { throw new DataValidationException(UNSUPPORTED_QOUTE_BTC); diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/OkexBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/OkexBeanV1.java index 629b5bd4..2b030063 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/OkexBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/OkexBeanV1.java @@ -49,8 +49,8 @@ public void setTradeTime(Date value) { @Parsed(field = "\uFEFFPairs") public void setSymbol(String value) { final String[] pair = value.split("_"); - pairsBase = Currency.valueOf(pair[0].toUpperCase()); - pairsQuote = Currency.valueOf(pair[1].toUpperCase()); + pairsBase = Currency.fromCode(pair[0].toUpperCase()); + pairsQuote = Currency.fromCode(pair[1].toUpperCase()); } @Parsed(field = "\uFEFFAmount", defaultNullRead = "0") @@ -66,19 +66,19 @@ public void setPrice(BigDecimal value) { @Parsed(field = "\uFEFFTotal") public void setTotalCurrency(String value) { final String[] split = value.split(" "); - totalCurrency = Currency.valueOf(split[1]); + totalCurrency = Currency.fromCode(split[1]); } @Parsed(field = "\uFEFFFee") public void setFee(String value) { final String[] split = value.split(" "); fee = new BigDecimal(split[0]); - feeCurrency = Currency.valueOf(split[1].toUpperCase()); + feeCurrency = Currency.fromCode(split[1].toUpperCase()); } @Parsed(field = "\uFEFFunit\r") public void setUnit(String value) { - unit = Currency.valueOf(value); + unit = Currency.fromCode(value); } @Override diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PaxfulBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PaxfulBeanV1.java index 1d2bd189..bed5f406 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PaxfulBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PaxfulBeanV1.java @@ -38,9 +38,9 @@ public void setType(String value) { @Parsed(field = "fiat_currency") public void setFiatCurrency(String value) { - fiatCurrency = Currency.valueOf(value); + fiatCurrency = Currency.fromCode(value); if (!fiatCurrency.isFiat()) { - throw new DataValidationException(UNSUPPORTED_QUOTE_CURRENCY.concat(fiatCurrency.name())); + throw new DataValidationException(UNSUPPORTED_QUOTE_CURRENCY.concat(fiatCurrency.code())); } } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PoloniexBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PoloniexBeanV1.java index dbdc89d9..f18675f7 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PoloniexBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/PoloniexBeanV1.java @@ -39,8 +39,8 @@ public void setDate(Date value) { @Parsed(field = "Market") public void setMarket(String value) { final String[] values = value.split("/"); - marketBase = Currency.valueOf(values[0]); - marketQuote = Currency.valueOf(values[1]); + marketBase = Currency.fromCode(values[0]); + marketQuote = Currency.fromCode(values[1]); } @Parsed(field = "Category") diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/ShakePayBeanV1.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/ShakePayBeanV1.java index 773689b3..7c69ef35 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/ShakePayBeanV1.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/bean/ShakePayBeanV1.java @@ -56,7 +56,7 @@ public void setAmountDebited(BigDecimal amountDebited) { @Parsed(field = "Debit Currency") public void setDebitCurrency(String debitCurrency) { - this.debitCurrency = Currency.valueOf(debitCurrency); + this.debitCurrency = Currency.fromCode(debitCurrency); } @Parsed(field = "Amount Credited") @@ -67,7 +67,7 @@ public void setAmountCredited(BigDecimal amountCredited) { @Parsed(field = "Credit Currency") public void setCreditCurrency(String creditCurrency) { - this.creditCurrency = Currency.valueOf(creditCurrency); + this.creditCurrency = Currency.fromCode(creditCurrency); } diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/binance/v2/BinanceBeanV2.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/binance/v2/BinanceBeanV2.java index df3e84de..c7d95a98 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/binance/v2/BinanceBeanV2.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/parser/exchange/binance/v2/BinanceBeanV2.java @@ -40,7 +40,7 @@ public class BinanceBeanV2 extends ExchangeBean { static { getTradeablePairs().forEach(t -> fastCurrencyPair.put( - String.format("%s%s", t.getBase().name(), t.getQuote().name()), t) + String.format("%s%s", t.getBase().code(), t.getQuote().code()), t) ); } @@ -119,7 +119,7 @@ public TransactionCluster toTransactionCluster() { private Currency findEnds(String value) { List matchedCurrencies = Arrays .stream(Currency.values()) - .filter(currency -> value.endsWith(currency.name())) + .filter(currency -> value.endsWith(currency.code())) .collect(Collectors.toList()); if (matchedCurrencies.size() == 1) { return matchedCurrencies.get(0); diff --git a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/rateprovider/CoinPaprikaRateProvider.java b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/rateprovider/CoinPaprikaRateProvider.java index b0691e9f..c5302e06 100644 --- a/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/rateprovider/CoinPaprikaRateProvider.java +++ b/plugin-base/src/main/java/io/everytrade/server/plugin/impl/everytrade/rateprovider/CoinPaprikaRateProvider.java @@ -159,6 +159,7 @@ public final class CoinPaprikaRateProvider implements IRateProvider { COIN_IDS_BY_CURRENCY.put(Currency.CAKE, "cake-pancakeswap"); COIN_IDS_BY_CURRENCY.put(Currency.BAL, "bal-balancer"); COIN_IDS_BY_CURRENCY.put(Currency.BEAM, "beam-beam"); + COIN_IDS_BY_CURRENCY.put(Currency._1INCH, "1inch-1inch"); LISTING_START_BY_CURRENCY.put(Currency.BTC, Instant.parse("2013-04-28T18:45:00Z")); LISTING_START_BY_CURRENCY.put(Currency.ETH, Instant.parse("2015-08-07T14:45:00Z")); @@ -267,6 +268,7 @@ public final class CoinPaprikaRateProvider implements IRateProvider { LISTING_START_BY_CURRENCY.put(Currency.CAKE, Instant.parse("2021-02-05T14:50:00Z")); LISTING_START_BY_CURRENCY.put(Currency.BAL, Instant.parse("2020-09-01T13:30:00Z")); LISTING_START_BY_CURRENCY.put(Currency.BEAM, Instant.parse("2019-01-18T01:20:00Z")); + LISTING_START_BY_CURRENCY.put(Currency._1INCH, Instant.parse("2021-01-14T13:45:00Z")); SUPPORTED_QUOTES.add(Currency.USD); SUPPORTED_QUOTES.add(Currency.BTC); @@ -321,7 +323,7 @@ public Rate getRate(Currency base, Currency quote, Instant instant) { final String timeStamp = ZonedDateTime.ofInstant(instant, ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - final String quoteStr = quote.name().toLowerCase(); + final String quoteStr = quote.code().toLowerCase(); final String coinId = getCoinId(base); List historical = null; diff --git a/plugin-base/src/test/java/io/everytrade/server/model/CurrencyTest.java b/plugin-base/src/test/java/io/everytrade/server/model/CurrencyTest.java new file mode 100644 index 00000000..1d89e5f6 --- /dev/null +++ b/plugin-base/src/test/java/io/everytrade/server/model/CurrencyTest.java @@ -0,0 +1,24 @@ +package io.everytrade.server.model; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class CurrencyTest { + + @Test + public void testCodesOfCurrency() { + Arrays.stream(Currency.values()).forEach(currency -> { + String code = currency.code(); + assertEquals(currency, Currency.fromCode(code)); + }); + } + + @Test + public void test1INCH() { + assertEquals(Currency._1INCH, Currency.fromCode("1INCH")); + assertEquals("1INCH", Currency._1INCH.code()); + } +} diff --git a/plugin-tester/src/main/java/io/everytrade/server/plugin/Tester.java b/plugin-tester/src/main/java/io/everytrade/server/plugin/Tester.java index f9aa84c4..b726206c 100644 --- a/plugin-tester/src/main/java/io/everytrade/server/plugin/Tester.java +++ b/plugin-tester/src/main/java/io/everytrade/server/plugin/Tester.java @@ -105,7 +105,7 @@ private void testPlugin(IPlugin plugin) { } private void testRateProviders(IPlugin plugin) { - final Instant now = Instant.parse("2020-12-23T00:00:00Z"); + final Instant now = Instant.parse("2021-02-21T00:00:00Z"); final List providerDescriptors = plugin.allRateProviderDescriptors(); for (RateProviderDescriptor rateProviderDescriptor : providerDescriptors) { log.info("rateProviderDescriptor = " + rateProviderDescriptor);