Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
scriptedinstrumentpricingengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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/engines/scriptedinstrumentpricingengine.hpp
20 \brief scripted instrument pricing engine
21*/
22
23#pragma once
24
29
31
32namespace ore {
33namespace data {
34
36public:
37 ScriptedInstrumentPricingEngine(const std::string& npv,
38 const std::vector<std::pair<std::string, std::string>>& additionalResults,
39 const QuantLib::ext::shared_ptr<Model>& model, const ASTNodePtr ast,
40 const QuantLib::ext::shared_ptr<Context>& context, const std::string& script = "",
41 const bool interactive = false, const bool amcEnabled = false,
42 const std::set<std::string>& amcStickyCloseOutStates = {},
43 const bool generateAdditionalResults = false,
44 const bool includePastCashflows = false)
45 : npv_(npv), additionalResults_(additionalResults), model_(model), ast_(ast), context_(context),
46 script_(script), interactive_(interactive), amcEnabled_(amcEnabled),
47 amcStickyCloseOutStates_(amcStickyCloseOutStates), generateAdditionalResults_(generateAdditionalResults),
48 includePastCashflows_(includePastCashflows) {
49 registerWith(model_);
50 }
51
53
54private:
55 void calculate() const override;
56 Real addMcErrorEstimate(const std::string& label, const ValueType& v) const;
57
58 // calculation state, true iff calculate() was called at least once and last call went without errors
59 mutable bool lastCalculationWasValid_ = false;
60
61 const std::string npv_;
62 const std::vector<std::pair<std::string, std::string>> additionalResults_;
63 const QuantLib::ext::shared_ptr<Model> model_;
65 const QuantLib::ext::shared_ptr<Context> context_;
66 const std::string script_;
67 const bool interactive_;
68 const bool amcEnabled_;
69 const std::set<std::string> amcStickyCloseOutStates_;
72};
73
74} // namespace data
75} // namespace ore
abstract syntax tree for payoff scripting
std::string script
QuantLib::GenericEngine< arguments, results > engine
const QuantLib::ext::shared_ptr< Context > context_
ScriptedInstrumentPricingEngine(const std::string &npv, const std::vector< std::pair< std::string, std::string > > &additionalResults, const QuantLib::ext::shared_ptr< Model > &model, const ASTNodePtr ast, const QuantLib::ext::shared_ptr< Context > &context, const std::string &script="", const bool interactive=false, const bool amcEnabled=false, const std::set< std::string > &amcStickyCloseOutStates={}, const bool generateAdditionalResults=false, const bool includePastCashflows=false)
Real addMcErrorEstimate(const std::string &label, const ValueType &v) const
const std::vector< std::pair< std::string, std::string > > additionalResults_
const QuantLib::ext::shared_ptr< Model > model_
script engine context holding variable names and values
Currency and instrument specific conventions/defaults.
@ data
Definition: log.hpp:77
interface for model against which a script can be run
boost::variant< RandomVariable, EventVec, CurrencyVec, IndexVec, DaycounterVec, Filter > ValueType
Definition: value.hpp:60
QuantLib::ext::shared_ptr< ASTNode > ASTNodePtr
Definition: ast.hpp:46
Serializable Credit Default Swap.
Definition: namespaces.docs:23
scripted instrument