flexiblepower / powermatcher

PowerMatcher - The Java implementation of the PowerMatcher, including the API, the core, a couple of examples, a remote implementation using websockets and a visualisation of the configuration.
http://www.powermatcher.org
Apache License 2.0
43 stars 25 forks source link

Bug in Price fromPriceStep method #220

Open jpwijbenga opened 6 years ago

jpwijbenga commented 6 years ago

Is the price step 0-based or 1-based. Because the check allows both 0 and 'number of pricesteps'. It seems like priceStep should only be allowed to be smaller or equal to marketBasis.getPriceSteps() - 1.

public static Price fromPriceStep(MarketBasis marketBasis, double priceStep) {
        if (marketBasis == null) {
            throw new IllegalArgumentException("marketBasis cannot be null");
        }
        if (priceStep < 0 || priceStep > marketBasis.getPriceSteps()) {
            throw new IllegalArgumentException("priceStep is not in the range of the marketBasis");
        }
        return new Price(marketBasis, marketBasis.getMinimumPrice() + priceStep * marketBasis.getPriceIncrement());
    }