Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
ored
scripting
computationgraphbuilder.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2021 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 ored/scripting/computationgraphbuilder.hpp
20
\brief computation graph builder
21
\ingroup utilities
22
*/
23
24
#pragma once
25
26
#include <
ored/scripting/models/modelcg.hpp
>
27
#include <
ored/scripting/ast.hpp
>
28
#include <
ored/scripting/context.hpp
>
29
#include <
ored/scripting/paylog.hpp
>
30
31
#include <
qle/math/randomvariable_ops.hpp
>
32
33
namespace
ore
{
34
namespace
data
{
35
36
class
ComputationGraphBuilder
{
37
public
:
38
struct
PayLogEntry
{
39
std::size_t
value
;
40
std::size_t
filter
;
41
QuantLib::Date
obs
;
42
QuantLib::Date
pay
;
43
std::string
ccy
;
44
QuantLib::Size
legNo
;
45
std::string
cashflowType
;
46
QuantLib::Size
slot
;
47
};
48
49
ComputationGraphBuilder
(
ComputationGraph
& g,
const
std::vector<std::string>& opLabels,
const
ASTNodePtr
root,
50
const
QuantLib::ext::shared_ptr<Context> context,
const
QuantLib::ext::shared_ptr<ModelCG> model =
nullptr
)
51
:
g_
(g),
opLabels_
(opLabels),
root_
(root),
context_
(context),
model_
(model) {}
52
void
run
(
const
bool
generatePayLog,
const
bool
includePastCashflows =
false
,
const
std::string&
script
=
""
,
53
bool
interactive =
false
);
54
const
std::set<std::size_t>&
keepNodes
()
const
{
return
keepNodes_
; }
55
const
std::vector<PayLogEntry>&
payLogEntries
()
const
{
return
payLogEntries_
; }
56
57
private
:
58
ComputationGraph
&
g_
;
59
60
const
std::vector<std::string>
opLabels_
;
61
const
ASTNodePtr
root_
;
62
const
QuantLib::ext::shared_ptr<Context>
context_
;
63
const
QuantLib::ext::shared_ptr<ModelCG>
model_
;
64
65
std::set<std::size_t>
keepNodes_
;
66
std::vector<PayLogEntry>
payLogEntries_
;
67
};
68
69
}
// namespace data
70
}
// namespace ore
ast.hpp
abstract syntax tree for payoff scripting
script
std::string script
Definition:
asttoscriptconverter.cpp:767
QuantExt::ComputationGraph
ore::data::ComputationGraphBuilder
Definition:
computationgraphbuilder.hpp:36
ore::data::ComputationGraphBuilder::keepNodes
const std::set< std::size_t > & keepNodes() const
Definition:
computationgraphbuilder.hpp:54
ore::data::ComputationGraphBuilder::context_
const QuantLib::ext::shared_ptr< Context > context_
Definition:
computationgraphbuilder.hpp:62
ore::data::ComputationGraphBuilder::root_
const ASTNodePtr root_
Definition:
computationgraphbuilder.hpp:61
ore::data::ComputationGraphBuilder::payLogEntries
const std::vector< PayLogEntry > & payLogEntries() const
Definition:
computationgraphbuilder.hpp:55
ore::data::ComputationGraphBuilder::opLabels_
const std::vector< std::string > opLabels_
Definition:
computationgraphbuilder.hpp:60
ore::data::ComputationGraphBuilder::run
void run(const bool generatePayLog, const bool includePastCashflows=false, const std::string &script="", bool interactive=false)
Definition:
computationgraphbuilder.cpp:1485
ore::data::ComputationGraphBuilder::keepNodes_
std::set< std::size_t > keepNodes_
Definition:
computationgraphbuilder.hpp:65
ore::data::ComputationGraphBuilder::g_
ComputationGraph & g_
Definition:
computationgraphbuilder.hpp:58
ore::data::ComputationGraphBuilder::model_
const QuantLib::ext::shared_ptr< ModelCG > model_
Definition:
computationgraphbuilder.hpp:63
ore::data::ComputationGraphBuilder::payLogEntries_
std::vector< PayLogEntry > payLogEntries_
Definition:
computationgraphbuilder.hpp:66
ore::data::ComputationGraphBuilder::ComputationGraphBuilder
ComputationGraphBuilder(ComputationGraph &g, const std::vector< std::string > &opLabels, const ASTNodePtr root, const QuantLib::ext::shared_ptr< Context > context, const QuantLib::ext::shared_ptr< ModelCG > model=nullptr)
Definition:
computationgraphbuilder.hpp:49
context.hpp
script engine context holding variable names and values
data
@ data
Definition:
log.hpp:77
modelcg.hpp
interface for model against which a script can be run
ore::data::ASTNodePtr
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
Definition:
ast.hpp:46
ore
Serializable Credit Default Swap.
Definition:
namespaces.docs:23
paylog.hpp
repository for cashflows generated by the PAYLOG() function
randomvariable_ops.hpp
ore::data::ComputationGraphBuilder::PayLogEntry
Definition:
computationgraphbuilder.hpp:38
ore::data::ComputationGraphBuilder::PayLogEntry::filter
std::size_t filter
Definition:
computationgraphbuilder.hpp:40
ore::data::ComputationGraphBuilder::PayLogEntry::cashflowType
std::string cashflowType
Definition:
computationgraphbuilder.hpp:45
ore::data::ComputationGraphBuilder::PayLogEntry::obs
QuantLib::Date obs
Definition:
computationgraphbuilder.hpp:41
ore::data::ComputationGraphBuilder::PayLogEntry::slot
QuantLib::Size slot
Definition:
computationgraphbuilder.hpp:46
ore::data::ComputationGraphBuilder::PayLogEntry::legNo
QuantLib::Size legNo
Definition:
computationgraphbuilder.hpp:44
ore::data::ComputationGraphBuilder::PayLogEntry::ccy
std::string ccy
Definition:
computationgraphbuilder.hpp:43
ore::data::ComputationGraphBuilder::PayLogEntry::value
std::size_t value
Definition:
computationgraphbuilder.hpp:39
ore::data::ComputationGraphBuilder::PayLogEntry::pay
QuantLib::Date pay
Definition:
computationgraphbuilder.hpp:42
Generated by
Doxygen
1.9.5