Logo Search packages:      
Sourcecode: quantlib version File versions  Download package


/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

 Copyright (C) 2003 RiskMap srl

 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
 <quantlib-dev@lists.sf.net>. 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.

#include <ql/CashFlows/parcoupon.hpp>
#include <ql/Indexes/indexmanager.hpp>

namespace QuantLib {

    ParCoupon::ParCoupon(Real nominal, const Date& paymentDate,
                         const boost::shared_ptr<Xibor>& index,
                         const Date& startDate, const Date& endDate,
                         Integer fixingDays, Spread spread,
                         const Date& refPeriodStart,
                         const Date& refPeriodEnd,
                         const DayCounter& dayCounter)
    : FloatingRateCoupon(nominal, paymentDate, startDate, endDate,
                         fixingDays, spread, refPeriodStart, refPeriodEnd),
      index_(index), dayCounter_(dayCounter) {

00039     Real ParCoupon::amount() const {
        boost::shared_ptr<YieldTermStructure> termStructure =
                   "null term structure set to par coupon");
        Date today = Settings::instance().evaluationDate();
        Date fixing_date = fixingDate();
        if (fixing_date < today) {
            // must have been fixed
            Rate pastFixing = IndexManager::instance().getHistory(
            QL_REQUIRE(pastFixing != Null<Real>(),
                       "Missing " << index_->name()
                       << " fixing for " << fixing_date);
            return (pastFixing+spread_)*accrualPeriod()*nominal();
        if (fixing_date == today) {
            // might have been fixed
            try {
                Rate pastFixing = IndexManager::instance().getHistory(
                if (pastFixing != Null<Real>())
                    return (pastFixing+spread_)*accrualPeriod()*nominal();
                    ;   // fall through and forecast
            } catch (Error&) {
                ;       // fall through and forecast
        Date fixingValueDate = index_->calendar().advance(
                                 fixing_date, index_->settlementDays(), Days);
        DiscountFactor startDiscount =
        Date temp = index_->calendar().advance(accrualEndDate_,
                                               -fixingDays_, Days);
        DiscountFactor endDiscount =
                                       temp, index_->settlementDays(), Days));
        return ((startDiscount/endDiscount-1.0) +
                spread_*accrualPeriod()) * nominal();

00081     Rate ParCoupon::indexFixing() const {
        DayCounter dayCount = index_->termStructure()->dayCounter();
        Date begin = index_->calendar().advance(
                                fixingDate(), index_->settlementDays(), Days);
        Date temp = index_->calendar().advance(accrualEndDate_,
                                               -fixingDays_, Days);
        Date end = index_->calendar().advance(
                                        temp, index_->settlementDays(), Days);
        return (amount()/nominal() - spread()*accrualPeriod()) /


Generated by  Doxygen 1.6.0   Back to index