Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxbspiecewiseconstantparametrization.cpp
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
20
21namespace QuantExt {
22
24 const Handle<Quote>& fxSpotToday,
25 const Array& times, const Array& sigma,
26 const QuantLib::ext::shared_ptr<Constraint>& sigmaConstraint)
27 : FxBsParametrization(currency, fxSpotToday),
28 PiecewiseConstantHelper1(times, sigmaConstraint) {
29 initialize(sigma);
30}
31
32FxBsPiecewiseConstantParametrization::FxBsPiecewiseConstantParametrization(
33 const Currency& currency, const Handle<Quote>& fxSpotToday, const std::vector<Date>& dates, const Array& sigma,
34 const Handle<YieldTermStructure>& domesticTermStructure,
35 const QuantLib::ext::shared_ptr<Constraint>& sigmaConstraint)
36 : FxBsParametrization(currency, fxSpotToday),
37 PiecewiseConstantHelper1(dates, domesticTermStructure, sigmaConstraint) {
38 initialize(sigma);
39}
40
41void FxBsPiecewiseConstantParametrization::initialize(const Array& sigma) {
42 QL_REQUIRE(PiecewiseConstantHelper1::t().size() + 1 == sigma.size(),
43 "alpha size (" << sigma.size() << ") inconsistent to times size ("
44 << PiecewiseConstantHelper1::t().size() << ")");
45
46 // store raw parameter values
47 for (Size i = 0; i < PiecewiseConstantHelper1::y_->size(); ++i) {
48 PiecewiseConstantHelper1::y_->setParam(i, inverse(0, sigma[i]));
49 }
50 update();
51}
52
53} // namespace QuantExt
FxBsPiecewiseConstantParametrization(const Currency &currency, const Handle< Quote > &fxSpotToday, const Array &times, const Array &sigma, const QuantLib::ext::shared_ptr< QuantLib::Constraint > &sigmaConstraint=QuantLib::ext::make_shared< QuantLib::NoConstraint >())
piecewise constant model parametrization
QuantLib::SparseMatrix inverse(QuantLib::SparseMatrix m)