Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
ascot.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Managment 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
20
21#include <ql/cashflows/couponpricer.hpp>
22#include <ql/cashflows/fixedratecoupon.hpp>
23#include <ql/cashflows/iborcoupon.hpp>
24#include <ql/cashflows/simplecashflow.hpp>
25#include <ql/exercise.hpp>
26#include <ql/instruments/payoffs.hpp>
27#include <ql/pricingengines/bond/bondfunctions.hpp>
28
29#include <ql/utilities/null_deleter.hpp>
30
31#include <iostream>
32
33namespace QuantExt {
34
35Ascot::Ascot(Option::Type callPut, const ext::shared_ptr<Exercise>& exercise, const Real& bondQuantity,
36 const ext::shared_ptr<ConvertibleBond2>& bond, const Leg& fundingLeg)
37 : callPut_(callPut), exercise_(exercise), bondQuantity_(bondQuantity), bond_(bond), fundingLeg_(fundingLeg) {
38
39 registerWith(bond_);
40 bond_->alwaysForwardNotifications();
41
42 registerWith(Settings::instance().evaluationDate());
43 for (auto& c : fundingLeg_) {
44 registerWith(c);
45 if (auto lazy = QuantLib::ext::dynamic_pointer_cast<LazyObject>(c))
46 lazy->alwaysForwardNotifications();
47 }
48}
49
50void Ascot::setupArguments(PricingEngine::arguments* args) const {
51
52 Ascot::arguments* arguments = dynamic_cast<Ascot::arguments*>(args);
53
54 QL_REQUIRE(arguments != 0, "wrong argument type");
55
61}
62
64 QL_REQUIRE(exercise, "exercise not set");
65 QL_REQUIRE(bond, "convertible bond is not set");
66 QL_REQUIRE(!fundingLeg.empty(), "no funding leg provided");
67 for (Size i = 0; i < fundingLeg.size(); ++i)
68 QL_REQUIRE(fundingLeg[i], "null cash flow provided");
69}
70
71} // namespace QuantExt
Ascot class.
ext::shared_ptr< ConvertibleBond2 > bond
Definition: ascot.hpp:79
ext::shared_ptr< Exercise > exercise
Definition: ascot.hpp:77
Option::Type callPut
Definition: ascot.hpp:76
void validate() const override
Definition: ascot.cpp:63
Ascot(Option::Type callPut, const ext::shared_ptr< Exercise > &exercise, const Real &bondQuantity, const ext::shared_ptr< ConvertibleBond2 > &bond, const Leg &fundingLeg)
Definition: ascot.cpp:35
ext::shared_ptr< ConvertibleBond2 > bond_
Definition: ascot.hpp:68
void setupArguments(PricingEngine::arguments *) const override
Definition: ascot.cpp:50
Option::Type callPut_
Definition: ascot.hpp:65
Real bondQuantity_
Definition: ascot.hpp:67
Leg fundingLeg_
Definition: ascot.hpp:69
ext::shared_ptr< Exercise > exercise_
Definition: ascot.hpp:66
const Bond & bond_