Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
crcirbuilder.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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
23
25
26#include <ql/math/optimization/levenbergmarquardt.hpp>
27
33
34using namespace QuantLib;
35using namespace QuantExt;
36using namespace std;
37
38namespace ore {
39namespace data {
40
41CrCirBuilder::CrCirBuilder(const QuantLib::ext::shared_ptr<ore::data::Market>& market, const QuantLib::ext::shared_ptr<CrCirData>& data,
42 const std::string& configuration)
43 : market_(market), configuration_(configuration), data_(data),
44 optimizationMethod_(QuantLib::ext::shared_ptr<OptimizationMethod>(new LevenbergMarquardt(1E-8, 1E-8, 1E-8))),
45 endCriteria_(EndCriteria(1000, 500, 1E-8, 1E-8, 1E-8)),
46 calibrationErrorType_(BlackCalibrationHelper::RelativePriceError) {
47
48 LOG("CIR CR Calibration for name " << data_->name());
49
50 rateCurve_ = market->discountCurve(data_->currency(), configuration);
51 creditCurve_ = market->defaultCurve(data_->name(), configuration)->curve();
52 recoveryRate_ = market->recoveryRate(data_->name(), configuration);
53
54 registerWith(rateCurve_);
55 registerWith(creditCurve_);
56 registerWith(recoveryRate_);
57
58 // shifted CIR model hard coded here
59 parametrization_ = QuantLib::ext::make_shared<QuantExt::CrCirppConstantWithFellerParametrization>(
60 parseCurrency(data_->currency()), creditCurve_, data_->reversionValue(), data_->longTermValue(),
61 data_->volatility(), data_->startValue(), true, data_->relaxedFeller(), data_->fellerFactor(),
62 data_->name());
63
64 // alternatively, use unconstrained parametrization (only positivity of all parameters is implied)
65 // parametrization_ = QuantLib::ext::make_shared<QuantExt::CrCirppConstantParametrization>(
66 // parseCurrency(data_->currency()), creditCurve_, data_->reversionValue(), data_->longTermValue(),
67 // data_->volatility(), data_->startValue(), false);
68
69 model_ = QuantLib::ext::make_shared<QuantExt::CrCirpp>(parametrization_);
70}
71
72} // namespace data
73} // namespace ore
QuantLib::ext::shared_ptr< QuantExt::CrCirpp > model_
Handle< DefaultProbabilityTermStructure > creditCurve_
Handle< YieldTermStructure > rateCurve_
QuantLib::ext::shared_ptr< QuantExt::CrCirppParametrization > parametrization_
QuantLib::ext::shared_ptr< CrCirData > data_
CrCirBuilder(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const QuantLib::ext::shared_ptr< CrCirData > &data, const std::string &configuration=Market::defaultConfiguration)
Handle< Quote > recoveryRate_
Build an cir model.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
Shared utilities for model building and calibration.
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
string conversion utilities
strike description