/src/main/java/net/finmath/montecarlo/assetderivativevaluation/products/LocalRiskMinimizingHedgePortfolio.java
final RandomVariable underlyingRebased = underlyingAtTimeNext.div( numeraireAtTimeNext) ;final RandomVariable numeraireValue = model.getNumeraire( time) ;
final RandomVariable numeraireValue = model.getNumeraire ( time ) ;
final RandomVariable derivativeTimesUnderlying = derivativeRebasedMartingale.mult(underlyingRebasedMartingale); final RandomVariable derivativeTimesUnderlyingExpected = condExpectationValuation.getConditionalExpectation(derivativeTimesUnderlying); final RandomVariable underlyingRabasedMartingaleSquared = underlyingRebasedMartingale.squared(); final RandomVariable underlyingRabasedMartingaleSquaredExpected = condExpectationValuation.getConditionalExpectation(underlyingRabasedMartingaleSquared); final RandomVariable delta = derivativeTimesUnderlyingExpected.div(underlyingRabasedMartingaleSquaredExpected); final RandomVariable underlyingValue = model.getAssetValue(time,0); <extra_id_0> final RandomVariable newNumberOfStocks = delta; final RandomVariable stocksToBuy = newNumberOfStocks.sub(amountOfUderlyingAsset); final RandomVariable numeraireAssetsToBuy = stocksToBuy.mult(underlyingValue).div(numeraireValue).mult(-1); final RandomVariable newNumberOfNumeraireAsset = amountOfNumeraireAsset.add(numeraireAssetsToBuy); amountOfNumeraireAsset = newNumberOfNumeraireAsset; amountOfUderlyingAsset = newNumberOfStocks;