| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2010 Ferdinando Ametrano |
| 5 | |
| 6 | This file is part of QuantLib, a free-software/open-source library |
| 7 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 8 | |
| 9 | QuantLib is free software: you can redistribute it and/or modify it |
| 10 | under the terms of the QuantLib license. You should have received a |
| 11 | copy of the license along with this program; if not, please email |
| 12 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 13 | <http://quantlib.org/license.shtml>. |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 17 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 18 | */ |
| 19 | |
| 20 | /*! \file proxyibor.hpp |
| 21 | \brief IborIndex calculated as proxy of some other IborIndex |
| 22 | */ |
| 23 | |
| 24 | #ifndef quantlib_proxyibor_hpp |
| 25 | #define quantlib_proxyibor_hpp |
| 26 | |
| 27 | #include <ql/indexes/iborindex.hpp> |
| 28 | |
| 29 | namespace QuantLib { |
| 30 | |
| 31 | //! IborIndex calculated as proxy of some other IborIndex |
| 32 | class ProxyIbor : public IborIndex { |
| 33 | public: |
| 34 | ProxyIbor(const std::string& familyName, |
| 35 | const Period& tenor, |
| 36 | Natural settlementDays, |
| 37 | const Currency& currency, |
| 38 | const Calendar& fixingCalendar, |
| 39 | BusinessDayConvention convention, |
| 40 | bool endOfMonth, |
| 41 | const DayCounter& dayCounter, |
| 42 | Handle<Quote> gearing, |
| 43 | ext::shared_ptr<IborIndex> iborIndex, |
| 44 | Handle<Quote> spread); |
| 45 | |
| 46 | private: |
| 47 | // overload |
| 48 | Rate forecastFixing(const Date& fixingDate) const override; |
| 49 | |
| 50 | Handle<Quote> gearing_; |
| 51 | ext::shared_ptr<IborIndex> iborIndex_; |
| 52 | Handle<Quote> spread_; |
| 53 | }; |
| 54 | |
| 55 | inline Rate ProxyIbor::forecastFixing(const Date& fixingDate) const { |
| 56 | Rate proxy = iborIndex_->fixing(fixingDate); |
| 57 | return gearing_->value() * proxy * spread_->value(); |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | #endif |
| 63 | |