net.finmath.montecarlo.interestrate.models.covariance.TermStructCovarianceModelFromLIBORCovarianceModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of finmath-lib Show documentation
Show all versions of finmath-lib Show documentation
finmath lib is a Mathematical Finance Library in Java.
It provides algorithms and methodologies related to mathematical finance.
/*
* (c) Copyright Christian P. Fries, Germany. Contact: [email protected].
*
* Created on 22.12.2016
*/
package net.finmath.montecarlo.interestrate.models.covariance;
import net.finmath.montecarlo.interestrate.TermStructureModel;
import net.finmath.montecarlo.interestrate.models.LIBORMarketModelWithTenorRefinement;
import net.finmath.stochastic.RandomVariable;
import net.finmath.time.TimeDiscretization;
/**
* @author Christian Fries
*
* @version 1.0
*/
public class TermStructCovarianceModelFromLIBORCovarianceModel implements TermStructureFactorLoadingsModel {
private final AbstractLIBORCovarianceModelParametric covarianceModel;
/**
* Create a term structure covariance model model implementing TermStructureCovarianceModelInterface
* using a given model implementing AbstractLIBORCovarianceModelParametric.
*
* @param covarianceModel The model implementing AbstractLIBORCovarianceModelParametric.
*/
public TermStructCovarianceModelFromLIBORCovarianceModel(final AbstractLIBORCovarianceModelParametric covarianceModel) {
this.covarianceModel = covarianceModel;
}
@Override
public RandomVariable[] getFactorLoading(final double time, final double periodStart, final double periodEnd, final TimeDiscretization periodDiscretization, final RandomVariable[] realizationAtTimeIndex, final TermStructureModel model) {
final TimeDiscretization liborPeriodDiscretization = covarianceModel.getLiborPeriodDiscretization();
// Cache is really needed.
final RandomVariable[] liborAtTimeIndex = new RandomVariable[liborPeriodDiscretization.getNumberOfTimeSteps()];
for(int componentIndex=0; componentIndex periodStartIndex+1) {
// Need to sum factor loadings
for(int factorIndex = 0; factorIndex