Search in sources :

Example 1 with LgoProduct

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;
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) LgoCurrency(org.knowm.xchange.lgo.dto.currency.LgoCurrency) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) LgoProduct(org.knowm.xchange.lgo.dto.product.LgoProduct) Currency(org.knowm.xchange.currency.Currency) LgoCurrency(org.knowm.xchange.lgo.dto.currency.LgoCurrency) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with LgoProduct

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");
    }
}
Also used : LgoProduct(org.knowm.xchange.lgo.dto.product.LgoProduct)

Example 3 with LgoProduct

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");
    }
}
Also used : LgoProduct(org.knowm.xchange.lgo.dto.product.LgoProduct) LgoProductCurrency(org.knowm.xchange.lgo.dto.product.LgoProductCurrency)

Aggregations

LgoProduct (org.knowm.xchange.lgo.dto.product.LgoProduct)3 BigDecimal (java.math.BigDecimal)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)1 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)1 FeeTier (org.knowm.xchange.dto.meta.FeeTier)1 LgoCurrency (org.knowm.xchange.lgo.dto.currency.LgoCurrency)1 LgoProductCurrency (org.knowm.xchange.lgo.dto.product.LgoProductCurrency)1