32 const QuantLib::ext::shared_ptr<SimMarket>& simMarket,
33 QuantLib::ext::shared_ptr<NPVCube>& outputCube,
34 QuantLib::ext::shared_ptr<NPVCube>& outputCubeNettingSet,
const Date& date,
35 Size dateIndex, Size sample,
bool isCloseOut) {
37 std::vector<Real> stateNpvs =
multiStateNpv(tradeIndex, trade, simMarket);
38 for (Size i = 0; i < stateNpvs.size(); ++i) {
39 outputCube->set(stateNpvs[i], tradeIndex, dateIndex, sample,
index_ + i);
45 const QuantLib::ext::shared_ptr<SimMarket>& simMarket,
46 QuantLib::ext::shared_ptr<NPVCube>& outputCube,
47 QuantLib::ext::shared_ptr<NPVCube>& outputCubeNettingSet) {
48 std::vector<Real> stateNpvs =
multiStateNpv(tradeIndex, trade, simMarket);
49 for (Size i = 0; i < stateNpvs.size(); ++i) {
50 outputCube->setT0(stateNpvs[i], tradeIndex,
index_ + i);
55 const QuantLib::ext::shared_ptr<SimMarket>& simMarket) {
58 if (trade->instrument()->qlInstrument()->isExpired()) {
59 return std::vector<Real>(
states_, 0.0);
62 if (
auto tmp = trade->instrument()->qlInstrument()->additionalResults().find(
"stateNpv");
63 tmp != trade->instrument()->qlInstrument()->additionalResults().end()) {
67 std::vector<Real> stateNpv;
69 stateNpv = boost::any_cast<std::vector<Real>>(tmp->second);
70 }
catch (
const std::exception& e) {
71 QL_FAIL(
"unexpected type of result stateNpv: " << e.what());
73 for (
auto& n : stateNpv) {
75 n *= trade->instrument()->multiplier() * trade->instrument()->multiplier2();
77 Real numeraire = simMarket->numeraire();
std::vector< Real > multiStateNpv(Size tradeIndex, const QuantLib::ext::shared_ptr< Trade > &trade, const QuantLib::ext::shared_ptr< SimMarket > &simMarket)
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 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
std::vector< Size > tradeCcyIndex_
std::vector< double > fxRates_
virtual Real npv(Size tradeIndex, const QuantLib::ext::shared_ptr< Trade > &trade, const QuantLib::ext::shared_ptr< SimMarket > &simMarket)
a calculator that computes npvs for a vector of credit states
Filter close_enough(const RandomVariable &x, const RandomVariable &y)