Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
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
30
32
33namespace ore {
34namespace data {
35
37public:
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
57private:
59
60 const std::vector<std::string> opLabels_;
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
abstract syntax tree for payoff scripting
std::string script
const std::set< std::size_t > & keepNodes() const
const QuantLib::ext::shared_ptr< Context > context_
const std::vector< PayLogEntry > & payLogEntries() const
const std::vector< std::string > opLabels_
void run(const bool generatePayLog, const bool includePastCashflows=false, const std::string &script="", bool interactive=false)
const QuantLib::ext::shared_ptr< ModelCG > model_
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)
script engine context holding variable names and values
@ data
Definition: log.hpp:77
interface for model against which a script can be run
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
Definition: ast.hpp:46
Serializable Credit Default Swap.
Definition: namespaces.docs:23
repository for cashflows generated by the PAYLOG() function
std::size_t filter
std::string cashflowType
QuantLib::Date obs
QuantLib::Size slot
QuantLib::Size legNo
std::string ccy
std::size_t value
QuantLib::Date pay