use of org.knowm.xchange.lgo.dto.product.LgoProduct in project XChange by knowm.
the class LgoAdapters method adaptMetadata.
public static ExchangeMetaData adaptMetadata(ExchangeMetaData metaData, LgoProducts products, LgoCurrencies currencies) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = metaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currency = metaData.getCurrencies();
for (LgoCurrency lgoCurrency : currencies.getCurrencies()) {
currency.put(Currency.getInstance(lgoCurrency.getCode()), new CurrencyMetaData(lgoCurrency.getDecimals(), null));
}
for (LgoProduct product : products.getProducts()) {
BigDecimal minAmount = product.getBase().getLimits().getMin();
BigDecimal maxAmount = product.getBase().getLimits().getMax();
Integer baseScale = currency.get(Currency.getInstance(product.getBase().getId())).getScale();
BigDecimal increment = product.getQuote().getIncrement().stripTrailingZeros();
currencyPairs.put(toPair(product), new CurrencyPairMetaData(null, minAmount, maxAmount, null, null, baseScale, increment.scale(), null, new FeeTier[0], increment, Currency.USD, true));
}
return metaData;
}
use of org.knowm.xchange.lgo.dto.product.LgoProduct in project XChange by knowm.
the class LgoTradeService method verifyOrder.
@Override
public void verifyOrder(LimitOrder limitOrder) {
super.verifyOrder(limitOrder);
LgoProduct product = getProduct(limitOrder.getCurrencyPair());
if (product.getBase().getLimits().getMax().compareTo(limitOrder.getOriginalAmount()) < 0) {
throw new IllegalArgumentException("Order amount more than maximum");
}
if (product.getQuote().getLimits().getMin().compareTo(limitOrder.getLimitPrice()) > 0) {
throw new IllegalArgumentException("Order price to low");
}
if (product.getQuote().getLimits().getMax().compareTo(limitOrder.getLimitPrice()) < 0) {
throw new IllegalArgumentException("Order price to high");
}
if (limitOrder.getLimitPrice().remainder(product.getQuote().getIncrement()).compareTo(BigDecimal.ZERO) != 0) {
throw new IllegalArgumentException("Invalid price increment");
}
}
use of org.knowm.xchange.lgo.dto.product.LgoProduct in project XChange by knowm.
the class LgoTradeService method verifyOrder.
@Override
public void verifyOrder(MarketOrder marketOrder) {
LgoProduct product = getProduct(marketOrder.getCurrencyPair());
LgoProductCurrency currencyToCheck = OrderType.BID.equals(marketOrder.getType()) ? product.getQuote() : product.getBase();
if (currencyToCheck.getLimits().getMin().compareTo(marketOrder.getRemainingAmount()) > 0) {
throw new IllegalArgumentException("Quantity to low");
}
if (currencyToCheck.getLimits().getMax().compareTo(marketOrder.getRemainingAmount()) < 0) {
throw new IllegalArgumentException("Quantity to high");
}
}
Aggregations