Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cboengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 cboengine.hpp
20 \brief collateralized bond obligation pricing engine
21*/
22
23#pragma once
24
26#include <ql/experimental/credit/distribution.hpp>
27#include <ql/experimental/credit/randomdefaultmodel.hpp>
28#include <ql/math/distributions/bivariatenormaldistribution.hpp>
29#include <ql/math/distributions/normaldistribution.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33
34//--------------------------------------------------------------------------
35//! CBO base engine
36class CBO::engine : public GenericEngine<CBO::arguments, CBO::results> {
37protected:
38 // virtual Real expectedTrancheLoss(const Date&) const = 0;
39 virtual void initialize() const { remainingBasket_ = this->arguments_.basket; }
40 mutable QuantLib::ext::shared_ptr<BondBasket> remainingBasket_;
41};
42
43//--------------------------------------------------------------------------
44//! helper class for the MonteCarloCBOEngine
45class Stats {
46public:
47 Stats(std::vector<Real> data);
48 Real mean();
49 Real std();
50 Real max();
51 Real min();
52 std::vector<Real>& data();
53 Distribution histogram(Size bins, Real xmin = -QL_MAX_REAL, Real xmax = QL_MAX_REAL);
54
55private:
56 std::vector<Real> data_;
57 Real mean_;
58 Real std_;
59 Real max_;
60 Real min_;
61};
62
63inline Real Stats::mean() { return mean_; }
64
65inline Real Stats::std() { return std_; }
66
67inline Real Stats::max() { return max_; }
68
69inline Real Stats::min() { return min_; }
70
71inline std::vector<Real>& Stats::data() { return data_; }
72
73} // namespace QuantExt
collateralized bond obligation instrument
CBO base engine.
Definition: cboengine.hpp:36
virtual void initialize() const
Definition: cboengine.hpp:39
QuantLib::ext::shared_ptr< BondBasket > remainingBasket_
Definition: cboengine.hpp:40
helper class for the MonteCarloCBOEngine
Definition: cboengine.hpp:45
Distribution histogram(Size bins, Real xmin=-QL_MAX_REAL, Real xmax=QL_MAX_REAL)
Definition: cboengine.cpp:43
std::vector< Real > & data()
Definition: cboengine.hpp:71
std::vector< Real > data_
Definition: cboengine.hpp:56
Swap::arguments * arguments_