public static RandomVariable getValueOfLegAnalytic(double evaluationTime, LIBORModelMonteCarloSimulationModel model, Schedule schedule, boolean paysFloatingRate, double fixRate, double notional) throws CalculationException {

		LocalDate modelReferenceDate = null;
		try {
			modelReferenceDate = model.getReferenceDate().toLocalDate();
			if(modelReferenceDate == null) {
				modelReferenceDate = schedule.getReferenceDate();
			}
		}
		catch(UnsupportedOperationException e) {}

		RandomVariable discountedCashflowFloatingLeg	= model.getRandomVariableForConstant(0.0);
		for(int peridIndex = schedule.getNumberOfPeriods() - 1; peridIndex >= 0; peridIndex--) {
			Period period = schedule.getPeriod(peridIndex);
			double paymentTime		= FloatingpointDate.getFloatingPointDateFromDate(modelReferenceDate, period.getPayment());
			double fixingTime		= FloatingpointDate.getFloatingPointDateFromDate(modelReferenceDate, period.getFixing());
			double periodLength		= schedule.getPeriodLength(peridIndex);

			/*
			 * Note that it is important that getForwardDiscountBond and getLIBOR are called with evaluationTime = exerciseTime.
			 */
			RandomVariable discountBond = model.getModel().getForwardDiscountBond(evaluationTime, paymentTime);
			if(paysFloatingRate) {
				RandomVariable libor	= model.getLIBOR(evaluationTime, fixingTime, paymentTime);
				RandomVariable periodCashFlow = libor.mult(periodLength).mult(notional);
				discountedCashflowFloatingLeg = discountedCashflowFloatingLeg.add(periodCashFlow.mult(discountBond));
			}
			if(fixRate != 0) {
				RandomVariable periodCashFlow = model.getRandomVariableForConstant(fixRate * periodLength * notional);
				discountedCashflowFloatingLeg = discountedCashflowFloatingLeg.add(periodCashFlow.mult(discountBond));
			}
		}
		return discountedCashflowFloatingLeg;

	}
public static RandomVariable getValueOfLegAnalytic ( double evaluationTime , LIBORModelMonteCarloSimulationModel model , Schedule schedule , boolean paysFloatingRate , double fixRate , double notional ) throws CalculationException { LocalDate modelReferenceDate = null ; try { modelReferenceDate = model . getReferenceDate ( ) . toLocalDate ( ) ; if ( modelReferenceDate == null ) { modelReferenceDate = schedule . getReferenceDate ( ) ; } } catch ( UnsupportedOperationException e ) { } RandomVariable discountedCashflowFloatingLeg = model . getRandomVariableForConstant ( 0.0 ) ; for ( int peridIndex = schedule . getNumberOfPeriods ( ) - 1 ; peridIndex >= 0 ; peridIndex -- ) { Period period = schedule . getPeriod ( peridIndex ) ; double paymentTime = FloatingpointDate . getFloatingPointDateFromDate ( modelReferenceDate , period . getPayment ( ) ) ; double fixingTime = FloatingpointDate . getFloatingPointDateFromDate ( modelReferenceDate , period . getFixing ( ) ) ; double periodLength = schedule . getPeriodLength ( peridIndex ) ; RandomVariable discountBond = model . getModel ( ) . getForwardDiscountBond ( evaluationTime , paymentTime ) ; if ( paysFloatingRate ) { RandomVariable libor = model . getLIBOR ( evaluationTime , fixingTime , paymentTime ) ; RandomVariable periodCashFlow = libor . mult ( periodLength ) . mult ( notional ) ; discountedCashflowFloatingLeg = discountedCashflowFloatingLeg . add ( periodCashFlow . mult ( discountBond ) ) ; } if ( fixRate != 0 ) { RandomVariable periodCashFlow = model . getRandomVariableForConstant ( fixRate * periodLength * notional ) ; discountedCashflowFloatingLeg = discountedCashflowFloatingLeg . add ( periodCashFlow . mult ( discountBond ) ) ; } } return discountedCashflowFloatingLeg ; }
Determines the time \( t \)-measurable value of a swap leg (can handle fix or float).

@param evaluationTime The time \( t \) conditional to which the value is calculated.
@param model The model implmeneting LIBORModelMonteCarloSimulationModel.
@param schedule The schedule of the leg.
@param paysFloatingRate If true, the leg will pay {@link LIBORModelMonteCarloSimulationModel#getLIBOR(double, double, double)}
@param fixRate The fixed rate (if any)
@param notional The notional
@return The time \( t \)-measurable value
@throws CalculationException Thrown is model failed to provide the required quantities.