net.finmath.time.Tenor Maven / Gradle / Ivy
/*
* (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: [email protected].
*
* Created on 03.09.2013
*/
package net.finmath.time;
import java.util.Calendar;
import net.finmath.time.daycount.DayCountConventionInterface;
import net.finmath.time.daycount.DayCountConvention_ACT_365;
/**
* Implements a time discretization based on dates using a reference
* date and an daycount convention / year fraction.
*
* The time as a double is represented as the year fraction from the reference date.
*
* @author Christian Fries
*/
public class Tenor extends TimeDiscretization implements TenorInterface {
private static final long serialVersionUID = 4027884423439197483L;
private static DayCountConventionInterface internalDayCounting = new DayCountConvention_ACT_365();
private Calendar referenceDate;
private Calendar[] dates;
/**
* @param dates A set of dates.
* @param referenceDate The reference date, which defines t=0 with respect to the internal double representation.
*/
public Tenor(Calendar[] dates, Calendar referenceDate) {
super(createTimeDiscretizationFromDates(dates, referenceDate));
this.dates = dates;
this.referenceDate = referenceDate;
}
/**
* @param dates
* @param referenceDate
* @return A time discretization corresponding to the given dates, relative to the reference date, using the internal day count fraction.
*/
private static double[] createTimeDiscretizationFromDates(Calendar[] dates, Calendar referenceDate) {
double[] timeDiscretization = new double[dates.length];
for(int timeIndex=0; timeIndex
© 2015 - 2025 Weber Informatics LLC | Privacy Policy