Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxbsconstantparametrization.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file fxbsconstantparametrization.hpp
20 \brief Constant FX model parametrization
21 \ingroup models
22*/
23
24#ifndef quantext_constant_fxbs_parametrization_hpp
25#define quantext_constant_fxbs_parametrization_hpp
26
28
29namespace QuantExt {
30//! FX Black Scholes parametrization
31/*! FX Black Scholes parametrization, with constant volatility
32 \ingroup models
33*/
35public:
36 /*! The currency refers to the foreign currency, the
37 spot is as of today (i.e. the discounted spot) */
38 FxBsConstantParametrization(const Currency& currency, const Handle<Quote>& fxSpotToday, const Real sigma,
39 const QuantLib::ext::shared_ptr<QuantLib::Constraint>& sigmaConstraint = QuantLib::ext::make_shared<QuantLib::NoConstraint>());
40
41 Real variance(const Time t) const override;
42 Real sigma(const Time t) const override;
43 const QuantLib::ext::shared_ptr<Parameter> parameter(const Size) const override;
44
45protected:
46 Real direct(const Size i, const Real x) const override;
47 Real inverse(const Size i, const Real y) const override;
48
49private:
50 const QuantLib::ext::shared_ptr<PseudoParameter> sigma_;
51};
52
53// inline
54
55inline Real FxBsConstantParametrization::direct(const Size, const Real x) const { return x * x; }
56
57inline Real FxBsConstantParametrization::inverse(const Size, const Real y) const { return std::sqrt(y); }
58
59inline Real FxBsConstantParametrization::variance(const Time t) const {
60 return direct(0, sigma_->params()[0]) * direct(0, sigma_->params()[0]) * t;
61}
62
63inline Real FxBsConstantParametrization::sigma(const Time) const { return direct(0, sigma_->params()[0]); }
64
65inline const QuantLib::ext::shared_ptr<Parameter> FxBsConstantParametrization::parameter(const Size i) const {
66 QL_REQUIRE(i == 0, "parameter " << i << " does not exist, only have 0");
67 return sigma_;
68}
69
70} // namespace QuantExt
71
72#endif
Real inverse(const Size i, const Real y) const override
Real variance(const Time t) const override
Real direct(const Size i, const Real x) const override
const QuantLib::ext::shared_ptr< PseudoParameter > sigma_
const QuantLib::ext::shared_ptr< Parameter > parameter(const Size) const override
FX Black Scholes parametrizations.
const Handle< Quote > fxSpotToday() const
virtual const Currency & currency() const
FX Black Scholes parametrization.