/*
Copyright (C) 2009 Ueli Hofstetter
Copyright (C) 2009 John Martin
Copyright (C) 2010 Zahid Hussein
Copyright (C) 2011 Richard Gomes
This source code is release under the BSD License.
This file is part of JQuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://jquantlib.org/
JQuantLib is free software: you can redistribute it and/or modify it
under the terms of the JQuantLib license. You should have received a
copy of the license along with this program; if not, please email
. The license is also available online at
.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
JQuantLib is based on QuantLib. http://quantlib.org/
When applicable, the original copyright notice follows this notice.
*/
/*
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2003, 2004, 2005 StatPro Italia srl
Copyright (C) 2006, 2007 Cristina Duminuco
Copyright (C) 2006, 2007 Giorgio Facchinetti
Copyright (C) 2006 Mario Pucci
Copyright (C) 2007 Ferdinando Ametrano
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
. The license is also available online at
.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
package org.jquantlib.cashflow;
import org.jquantlib.QL;
import org.jquantlib.daycounters.DayCounter;
import org.jquantlib.indexes.IborIndex;
import org.jquantlib.indexes.InterestRateIndex;
import org.jquantlib.lang.exceptions.LibraryException;
import org.jquantlib.math.Constants;
import org.jquantlib.math.matrixutilities.Array;
import org.jquantlib.time.BusinessDayConvention;
import org.jquantlib.time.Calendar;
import org.jquantlib.time.Date;
import org.jquantlib.time.Schedule;
/**
* Cash flow vector builder
*
* @author Ueli Hofstetter
* @author John Martin
* @author Zahid Hussain
* @author Richard Gomes
*/
public class FloatingLeg< InterestRateIndexType extends InterestRateIndex,
FloatingCouponType extends FloatingRateCoupon,
CappedFlooredCouponType
> extends Leg {
//Make compiler happy
private static final long serialVersionUID = 1L;
private final Class> typeIRT;
private final Class> typeFCT;
private final Class> typeCFC;
//
// public constructors
//
public FloatingLeg(
final Class> typeIRT,
final Class> typeFCT,
final Class> typeCFC,
final Array nominals,
final Schedule schedule,
final InterestRateIndexType index,
final DayCounter paymentDayCounter,
final BusinessDayConvention paymentAdj,
final Array fixingDays,
final Array gearings,
final Array spreads,
final Array caps,
final Array floors,
final boolean isInArrears,
final boolean isZero) {
super(schedule.size() - 1);
this.typeIRT = typeIRT;
this.typeFCT = typeFCT;
this.typeCFC = typeCFC;
constructor(
nominals,
schedule,
index,
paymentDayCounter, paymentAdj,
fixingDays, gearings, spreads, caps, floors,
isInArrears, isZero);
}
private void constructor(
final Array nominals,
final Schedule schedule,
final InterestRateIndexType index,
final DayCounter paymentDayCounter,
final BusinessDayConvention paymentAdj,
final Array fixingDays,
final Array gearings,
final Array spreads,
final Array caps,
final Array floors,
final boolean isInArrears,
final boolean isZero) {
final int n = schedule.size()-1;
QL.require(nominals != null && nominals.size() <= n,
"too many nominals (" + nominals.size() +
"), only " + n + " required");
QL.require(gearings != null && gearings.size()<=n,
"too many gearings (" + gearings.size() +
"), only " + n + " required");
QL.require(spreads != null && spreads.size()<=n,
"too many spreads (" + spreads.size() +
"), only " + n + " required");
QL.require(caps != null && caps.size()<=n,
"too many caps (" + caps.size() +
"), only " + n + " required");
QL.require(floors != null && floors.size()<=n,
"too many floors (" + floors.size() +
"), only " + n + " required");
QL.require(!isZero || !isInArrears,
"in-arrears and zero features are not compatible");
// the following is not always correct
final Calendar calendar = schedule.calendar();
Date refStart, start, refEnd, end;
final Date lastPaymentDate = calendar.adjust(schedule.date(n), paymentAdj);
for (int i=0; i
Ads help maintain this website.