net.finmath.marketdata.model.volatilities.CapletVolatilities 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. All rights reserved. Contact: [email protected].
*
* Created on 20.05.2005
*/
package net.finmath.marketdata.model.volatilities;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import net.finmath.marketdata.model.AnalyticModelInterface;
import net.finmath.marketdata.model.curves.Curve;
import net.finmath.marketdata.model.curves.CurveInterface;
import net.finmath.marketdata.model.curves.DiscountCurveInterface;
import net.finmath.marketdata.model.curves.ForwardCurveInterface;
import net.finmath.time.TimeDiscretization;
import net.finmath.time.TimeDiscretizationInterface;
/**
* A very simple container for Caplet volatilities.
*
* It performs piecewise constant interpolation (discretization) in maturity dimension on iso-moneyness lines
* and uses the default interpolation from the Curve class in strike dimension.
*
* It allows to convert from several quoting conventions.
*
* It needs a forward curve and a discount curve. The tenor length of the Caplet is inferred
* from the forward curve.
*
* @TODO: Need to add forward and discount curve to support implied vol.
* @author Christian Fries
*/
public class CapletVolatilities extends AbstractVolatilitySurface {
private Map capletVolatilities = new HashMap();
/**
* @param name The name of this volatility surface.
* @param referenceDate The reference date for this volatility surface, i.e., the date which defined t=0.
* @param forwardCurve The underlying forward curve.
* @param maturities The vector of maturities of the quotes.
* @param strikes The vector of strikes of the quotes.
* @param volatilities The vector of volatilities of the quotes.
* @param volatilityConvention The quoting convention of the volatilities provided.
* @param discountCurve The associated discount curve.
*/
public CapletVolatilities(String name, Calendar referenceDate, ForwardCurveInterface forwardCurve,
double[] maturities,
double[] strikes,
double[] volatilities,
QuotingConvention volatilityConvention,
DiscountCurveInterface discountCurve) {
super(name, referenceDate);
this.forwardCurve = forwardCurve;
this.discountCurve = discountCurve;
this.quotingConvention = volatilityConvention;
if(maturities.length != strikes.length || maturities.length != volatilities.length)
throw new IllegalArgumentException("Length of vectors is not equal.");
for(int i=0; i datasets = new ArrayList();
try {
while(true) {
String line = dataStream.readLine();
// Check for end of file
if(line == null) break;
// Ignore non caplet data
if(!line.startsWith("caplet\t")) continue;
datasets.add(line);
}
dataStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// @TODO: Name and reference date have to be set?!
CapletVolatilities capletVolatilities = new CapletVolatilities(null, null);
// Parse data
for(int datasetIndex=0; datasetIndex
© 2015 - 2025 Weber Informatics LLC | Privacy Policy