30#include <ql/instruments/barriertype.hpp>
31#include <ql/instruments/vanillaoption.hpp>
32#include <ql/instruments/barrieroption.hpp>
33#include <ql/settings.hpp>
43 Date today = Settings::instance().evaluationDate();
68 auto payoff = QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(vanillaOption->payoff());
69 if (payoff && ((
barrierType_ == Barrier::DownOut && payoff->optionType() == Option::Put) ||
70 (
barrierType_ == Barrier::UpOut && payoff->optionType() == Option::Call))) {
71 const bool isTouchingOnly =
true;
81 static std::map<std::string, boost::any> emptyMap;
91 auto payoff = QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(vanillaOption->payoff());
92 if (payoff && ((
barrierType_ == Barrier::DownOut && payoff->optionType() == Option::Put) ||
93 (
barrierType_ == Barrier::UpOut && payoff->optionType() == Option::Call))) {
94 const bool isTouchingOnly =
true;
109 case Barrier::DownIn:
110 case Barrier::DownOut:
122 bool trigger =
false;
123 Date today = Settings::instance().evaluationDate();
129 QL_REQUIRE(
index_,
"no index provided");
130 QL_REQUIRE(
calendar_ != Calendar(),
"no calendar provided");
132 QuantLib::ext::shared_ptr<QuantExt::EqFxIndexBase> eqfxIndex =
133 QuantLib::ext::dynamic_pointer_cast<QuantExt::EqFxIndexBase>(
index_);
137 while (d < today && !trigger) {
138 Real fixing = eqfxIndex->pastFixing(d);
139 if (fixing == Null<Real>()) {
143 ", Skipping this date, assuming no trigger",
144 std::map<std::string, std::string>({{
"exceptionType",
"Invalid or missing fixings"}}))
150 auto fxInd = QuantLib::ext::dynamic_pointer_cast<QuantExt::FxIndex>(eqfxIndex);
151 const bool isTouchingOnly =
false;
164 const bool isTouchingOnly =
false;
167 exerciseDate_ = today;
170 exercised_ = trigger;
182 bool trigger =
false;
183 Date today = Settings::instance().evaluationDate();
189 QL_REQUIRE(
index_,
"no index provided");
190 QL_REQUIRE(
calendar_ != Calendar(),
"no calendar provided");
193 QuantLib::ext::shared_ptr<QuantExt::EqFxIndexBase> eqfxIndex =
194 QuantLib::ext::dynamic_pointer_cast<QuantExt::EqFxIndexBase>(
index_);
198 while (d < today && !trigger) {
199 Real fixing = eqfxIndex->pastFixing(d);
200 if (fixing == Null<Real>()) {
204 ", Skipping this date, assuming no trigger",
205 std::map<std::string, std::string>({{
"exceptionType",
"Invalid or missing fixings"}}))
208 const bool isTouchingOnly =
false;
219 const bool isTouchingOnly =
false;
221 exerciseDate_ = today;
224 exercised_ = trigger;
Wrapper for option instruments, tracks whether option has been exercised or not.
QuantLib::Real NPV() const override
Return the NPV of this instrument.
Barrier::Type barrierType_
const QuantLib::Date startDate_
const std::map< std::string, boost::any > & additionalResults() const override
Return the additional results of this instrument.
QuantLib::Calendar calendar_
virtual bool checkBarrier(Real, bool) const =0
QuantLib::ext::shared_ptr< QuantLib::Index > index_
bool checkBarrier(Real spot, bool isTouchingOnly) const override
bool exercise() const override
QuantLib::Real additionalInstrumentsNPV() const
Real getTimedNPV(const QuantLib::ext::shared_ptr< QuantLib::Instrument > &instr) const
QuantLib::ext::shared_ptr< QuantLib::Instrument > instrument_
void log() const
generate Boost log record to pass to corresponding sinks
QuantLib::Date exerciseDate_
virtual bool exercise() const =0
QuantLib::ext::shared_ptr< QuantLib::Instrument > activeUnderlyingInstrument_
Real multiplier2() const override
bool checkBarrier(Real spot, bool isTouchingOnly) const override
bool exercise() const override
Base class for wrapper of QL instrument, used to store "state" of trade under each scenario.
Classes and functions for log message handling.
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
std::string to_string(const LocationInfo &l)
bool checkBarrier(Real spot, Barrier::Type type, Real barrier)
Serializable Credit Default Swap.
Wrapper for option instruments, tracks whether option has been exercised or not.
string conversion utilities