net.finmath.montecarlo.interestrate.products.SwapWithComponents Maven / Gradle / Ivy
/*
* Created on 06.12.2009
*/
package net.finmath.montecarlo.interestrate.products;
import java.util.ArrayList;
import java.util.Collection;
import net.finmath.exception.CalculationException;
import net.finmath.montecarlo.interestrate.TermStructureMonteCarloSimulationModel;
import net.finmath.montecarlo.interestrate.products.components.AbstractProductComponent;
import net.finmath.montecarlo.interestrate.products.components.Notional;
import net.finmath.montecarlo.interestrate.products.components.NotionalFromConstant;
import net.finmath.montecarlo.interestrate.products.components.Period;
import net.finmath.montecarlo.interestrate.products.components.ProductCollection;
import net.finmath.montecarlo.interestrate.products.indices.AbstractIndex;
import net.finmath.montecarlo.interestrate.products.indices.FixedCoupon;
import net.finmath.montecarlo.interestrate.products.indices.LIBORIndex;
import net.finmath.stochastic.RandomVariable;
/**
* Implements the pricing of a swap under a AbstractLIBORMarketModel
*
* @author Christian Fries
* @version 1.2
*/
public class SwapWithComponents extends AbstractTermStructureMonteCarloProduct {
private final ProductCollection underlying;
/**
* @param fixingDates Vector of fixing dates
* @param paymentDates Vector of payment dates (must have same length as fixing dates)
* @param swaprates Vector of strikes (must have same length as fixing dates)
*/
public SwapWithComponents(
final double[] fixingDates,
final double[] paymentDates,
final double[] swaprates) {
super();
/*
* Create components.
*
* The interesting part here is, that the creation of the components implicitly
* constitutes the (traditional) pricing algorithms (e.g., loop over all periods).
* Hence, the definition of the product is the definition of the pricing algorithm.
*/
final Collection legs = new ArrayList<>();
final Notional notional = new NotionalFromConstant(1.0);
final Collection fixedLegPeriods = new ArrayList<>();
for(int periodIndex=0; periodIndex floatingLegPeriods = new ArrayList<>();
for(int periodIndex=0; periodIndexcause()
method.
*/
@Override
public RandomVariable getValue(final double evaluationTime, final TermStructureMonteCarloSimulationModel model) throws CalculationException {
final RandomVariable values = underlying.getValue(evaluationTime, model);
return values;
}
}