Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
mporcalculator.cpp
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 engine/valuationcalculator.hpp
20 \brief The cube valuation calculator interface
21 \ingroup simulation
22*/
23
26
27namespace ore {
28namespace analytics {
29
30void MPORCalculator::init(const QuantLib::ext::shared_ptr<Portfolio>& portfolio,
31 const QuantLib::ext::shared_ptr<SimMarket>& simMarket) {
32 DLOG("init MPORCalculator")
33 npvCalc_->init(portfolio, simMarket);
34}
35
36void MPORCalculator::initScenario() { npvCalc_->initScenario(); }
37
38void MPORCalculator::calculate(const QuantLib::ext::shared_ptr<Trade>& trade, Size tradeIndex,
39 const QuantLib::ext::shared_ptr<SimMarket>& simMarket, QuantLib::ext::shared_ptr<NPVCube>& outputCube,
40 QuantLib::ext::shared_ptr<NPVCube>& outputCubeNettingSet, const Date& date, Size dateIndex,
41 Size sample, bool isCloseOut) {
42 Size index = isCloseOut ? closeOutIndex_ : defaultIndex_;
43 Real npv = npvCalc_->npv(tradeIndex, trade, simMarket);
44 outputCube->set(npv * (isCloseOut ? simMarket->numeraire() : 1.0), tradeIndex, dateIndex, sample, index);
45}
46
47void MPORCalculator::calculateT0(const QuantLib::ext::shared_ptr<Trade>& trade, Size tradeIndex,
48 const QuantLib::ext::shared_ptr<SimMarket>& simMarket, QuantLib::ext::shared_ptr<NPVCube>& outputCube,
49 QuantLib::ext::shared_ptr<NPVCube>& outputCubeNettingSet) {
50 Real npv = npvCalc_->npv(tradeIndex, trade, simMarket);
51 //! note that when we calculate t0 NPV we will always store it according to the defaultIndex_
52 // the closeOutIndex_ is not utilised for t=0 and has no meaning
53 outputCube->setT0(npv, tradeIndex, defaultIndex_);
54}
55} // namespace analytics
56} // namespace ore
QuantLib::ext::shared_ptr< NPVCalculator > npvCalc_
void calculateT0(const QuantLib::ext::shared_ptr< Trade > &trade, Size tradeIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, QuantLib::ext::shared_ptr< NPVCube > &outputCubeNettingSet) override
void init(const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const QuantLib::ext::shared_ptr< SimMarket > &simMarket) override
void calculate(const QuantLib::ext::shared_ptr< Trade > &trade, Size tradeIndex, const QuantLib::ext::shared_ptr< SimMarket > &simMarket, QuantLib::ext::shared_ptr< NPVCube > &outputCube, QuantLib::ext::shared_ptr< NPVCube > &outputCubeNettingSet, const Date &date, Size dateIndex, Size sample, bool isCloseOut=false) override
#define DLOG(text)
The cube valuation calculator interface.