/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2005, 2006 Theo Boafo Copyright (C) 2006, 2007 StatPro Italia 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 . 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 #include #include #include #include namespace QuantLib { ConvertibleBond::ConvertibleBond( const boost::shared_ptr& process, const boost::shared_ptr&, const boost::shared_ptr& engine, Real conversionRatio, const DividendSchedule& dividends, const CallabilitySchedule& callability, const Handle& creditSpread, const Date& issueDate, Natural settlementDays, const DayCounter& dayCounter, const Schedule& schedule, Real) : Bond(settlementDays, 100.0, schedule.calendar(), dayCounter, schedule.businessDayConvention()), conversionRatio_(conversionRatio), callability_(callability), dividends_(dividends), creditSpread_(creditSpread) { issueDate_ = issueDate; datedDate_ = schedule.startDate(); maturityDate_ = schedule.endDate(); frequency_ = schedule.tenor().frequency(); setPricingEngine(engine); registerWith(process); registerWith(creditSpread); } void ConvertibleBond::performCalculations() const { option_->setPricingEngine(engine_); NPV_ = option_->NPV(); errorEstimate_ = Null(); } ConvertibleZeroCouponBond::ConvertibleZeroCouponBond( const boost::shared_ptr& process, const boost::shared_ptr& exercise, const boost::shared_ptr& engine, Real conversionRatio, const DividendSchedule& dividends, const CallabilitySchedule& callability, const Handle& creditSpread, const Date& issueDate, Natural settlementDays, const DayCounter& dayCounter, const Schedule& schedule, Real redemption) : ConvertibleBond(process, exercise, engine, conversionRatio, dividends, callability, creditSpread, issueDate, settlementDays, dayCounter, schedule, redemption) { cashflows_ = Leg(); // redemption // !!! redemption *= faceAmount_/100.0; cashflows_.push_back(boost::shared_ptr(new SimpleCashFlow(redemption, maturityDate_))); option_ = boost::shared_ptr