Code example for MathContext

public class FixedPercentageAllocationStrategy implements MoneyManagementStrategy { 
    private BigDecimal ratio;
    private Asset asset;
    private final MathContext mc = new MathContext(10, RoundingMode.DOWN);
    public FixedPercentageAllocationStrategy(double ratio, Asset asset) throws Exception {
        if (ratio > 1.0) {
            throw new Exception("Cannot risk more than all of account");
        } else if (ratio <= 0.0) {
            throw new Exception("Ratio must be > 0");
        this.ratio = new BigDecimal(ratio);
        this.asset = asset;
    public int sizePosition(Account account, DateTime time) {
        BigDecimal price = asset.priceAt(time);
Connect your IDE to all the code out there  Get Codota for Java