Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxbsmodel.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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 fxbsmodel.hpp
20 \brief fx black scholes model
21 \ingroup models
22*/
23
24#pragma once
25
28
29#include <iostream>
30
31namespace QuantExt {
32
33class FxBsModel : public FxModel {
34public:
35 explicit FxBsModel(const QuantLib::ext::shared_ptr<FxBsParametrization>& parametrization);
36
37 const QuantLib::ext::shared_ptr<Parametrization> parametrizationBase() const override { return parametrization_; }
38
39 Handle<Quote> fxSpotToday() const override { return parametrization_->fxSpotToday(); }
40 Size n() const override { return 1; }
41 Size m() const override { return 1; }
42
43 Array eulerStep(const Time t0, const Array& x0, const Time dt, const Array& dw, const Real r_dom,
44 const Real r_for) const override;
45
46private:
47 QuantLib::ext::shared_ptr<FxBsParametrization> parametrization_;
48};
49
50inline FxBsModel::FxBsModel(const QuantLib::ext::shared_ptr<FxBsParametrization>& parametrization)
51 : parametrization_(parametrization) {
52 QL_REQUIRE(parametrization != nullptr, "FxBsModel: parametrization is null");
53}
54
55inline Array FxBsModel::eulerStep(const Time t0, const Array& x0, const Time dt, const Array& dw, const Real r_dom,
56 const Real r_for) const {
57 Real sigma = parametrization_->sigma(t0);
58 return x0 + (r_dom - r_for - 0.5 * sigma * sigma) * dt + sigma * std::sqrt(dt) * dw[0];
59}
60
61} // namespace QuantExt
FxBsModel(const QuantLib::ext::shared_ptr< FxBsParametrization > &parametrization)
Definition: fxbsmodel.hpp:50
Size m() const override
Definition: fxbsmodel.hpp:41
const QuantLib::ext::shared_ptr< Parametrization > parametrizationBase() const override
Definition: fxbsmodel.hpp:37
Size n() const override
Definition: fxbsmodel.hpp:40
Handle< Quote > fxSpotToday() const override
Definition: fxbsmodel.hpp:39
QuantLib::ext::shared_ptr< FxBsParametrization > parametrization_
Definition: fxbsmodel.hpp:47
Array eulerStep(const Time t0, const Array &x0, const Time dt, const Array &dw, const Real r_dom, const Real r_for) const override
Definition: fxbsmodel.hpp:55
FX Black Scholes parametrization.
fx model base class