/usr/include/ql/termstructures/yield/quantotermstructure.hpp is in libquantlib0-dev 1.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2003 Ferdinando Ametrano
Copyright (C) 2008 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
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
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.
*/
/*! \file quantotermstructure.hpp
\brief Quanto term structure
*/
#ifndef quantlib_quanto_term_structure_hpp
#define quantlib_quanto_term_structure_hpp
#include <ql/termstructures/yield/zeroyieldstructure.hpp>
#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
namespace QuantLib {
//! Quanto term structure
/*! Quanto term structure for modelling quanto effect in
option pricing.
\note This term structure will remain linked to the original
structures, i.e., any changes in the latters will be
reflected in this structure as well.
*/
class QuantoTermStructure : public ZeroYieldStructure {
public:
QuantoTermStructure(
const Handle<YieldTermStructure>& underlyingDividendTS,
const Handle<YieldTermStructure>& riskFreeTS,
const Handle<YieldTermStructure>& foreignRiskFreeTS,
const Handle<BlackVolTermStructure>& underlyingBlackVolTS,
Real strike,
const Handle<BlackVolTermStructure>& exchRateBlackVolTS,
Real exchRateATMlevel,
Real underlyingExchRateCorrelation);
//! \name YieldTermStructure interface
//@{
DayCounter dayCounter() const;
Calendar calendar() const;
Natural settlementDays() const;
const Date& referenceDate() const;
Date maxDate() const;
//@}
protected:
//! returns the zero yield as seen from the evaluation date
Rate zeroYieldImpl(Time) const;
private:
Handle<YieldTermStructure> underlyingDividendTS_, riskFreeTS_,
foreignRiskFreeTS_;
Handle<BlackVolTermStructure> underlyingBlackVolTS_,
exchRateBlackVolTS_;
Real underlyingExchRateCorrelation_, strike_, exchRateATMlevel_;
};
// inline definitions
inline QuantoTermStructure::QuantoTermStructure(
const Handle<YieldTermStructure>& underlyingDividendTS,
const Handle<YieldTermStructure>& riskFreeTS,
const Handle<YieldTermStructure>& foreignRiskFreeTS,
const Handle<BlackVolTermStructure>& underlyingBlackVolTS,
Real strike,
const Handle<BlackVolTermStructure>& exchRateBlackVolTS,
Real exchRateATMlevel,
Real underlyingExchRateCorrelation)
: ZeroYieldStructure(underlyingDividendTS->dayCounter()),
underlyingDividendTS_(underlyingDividendTS),
riskFreeTS_(riskFreeTS), foreignRiskFreeTS_(foreignRiskFreeTS),
underlyingBlackVolTS_(underlyingBlackVolTS),
exchRateBlackVolTS_(exchRateBlackVolTS),
underlyingExchRateCorrelation_(underlyingExchRateCorrelation),
strike_(strike), exchRateATMlevel_(exchRateATMlevel) {
registerWith(underlyingDividendTS_);
registerWith(riskFreeTS_);
registerWith(foreignRiskFreeTS_);
registerWith(underlyingBlackVolTS_);
registerWith(exchRateBlackVolTS_);
}
inline DayCounter QuantoTermStructure::dayCounter() const {
return underlyingDividendTS_->dayCounter();
}
inline Calendar QuantoTermStructure::calendar() const {
return underlyingDividendTS_->calendar();
}
inline Natural QuantoTermStructure::settlementDays() const {
return underlyingDividendTS_->settlementDays();
}
inline const Date& QuantoTermStructure::referenceDate() const {
return underlyingDividendTS_->referenceDate();
}
inline Date QuantoTermStructure::maxDate() const {
Date maxDate = std::min(underlyingDividendTS_->maxDate(),
riskFreeTS_->maxDate());
maxDate = std::min(maxDate, foreignRiskFreeTS_->maxDate());
maxDate = std::min(maxDate, underlyingBlackVolTS_->maxDate());
maxDate = std::min(maxDate, exchRateBlackVolTS_->maxDate());
return maxDate;
}
inline Rate QuantoTermStructure::zeroYieldImpl(Time t) const {
// warning: here it is assumed that all TS have the same daycount.
// It should be QL_REQUIREd
return underlyingDividendTS_->zeroRate(t, Continuous, NoFrequency, true)
+ riskFreeTS_->zeroRate(t, Continuous, NoFrequency, true)
- foreignRiskFreeTS_->zeroRate(t, Continuous, NoFrequency, true)
+ underlyingExchRateCorrelation_
* underlyingBlackVolTS_->blackVol(t, strike_, true)
* exchRateBlackVolTS_->blackVol(t, exchRateATMlevel_, true);
}
}
#endif
|