Using FloatingpointDate for conversion from Date to Double.
@@ -11,7 +11,7 @@ import java.util.Set;
import net.finmath.exception.CalculationException;
import net.finmath.montecarlo.interestrate.LIBORModelMonteCarloSimulationInterface;
import net.finmath.stochastic.RandomVariableInterface;
-import net.finmath.time.daycount.DayCountConvention_ACT_365;
+import net.finmath.time.FloatingpointDate;
/**
* An index which maps is evaluation point to a fixed discrete point, the end of the month,
@@ -43,13 +43,15 @@ public class TimeDiscreteEndOfMonthIndex extends AbstractIndex {
LocalDate referenceDate = model.getModel().getForwardRateCurve().getReferenceDate();
- LocalDate endDate = referenceDate
- .plusDays((int)Math.round(evaluationTime * 365))
- .withDayOfMonth(1)
- .plusMonths(fixingOffsetMonths);
+ LocalDate evaluationDate = FloatingpointDate.getDateFromFloatingPointDate(referenceDate, evaluationTime);
+ // Roll to start of month (to prevent "overflow)
+ LocalDate endDate = evaluationDate.withDayOfMonth(1).plusMonths(fixingOffsetMonths);
+
+ // Roll to end of month.
endDate = endDate.withDayOfMonth(endDate.lengthOfMonth());
- double time = (new DayCountConvention_ACT_365()).getDaycountFraction(referenceDate, endDate);
+
+ double time = FloatingpointDate.getFloatingPointDateFromDate(referenceDate, endDate);
return baseIndex.getValue(time, model);
}
