Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cliquetoption.cpp
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 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11
12 This program is distributed on the basis that it will form a useful
13 contribution to risk analytics and model standardisation, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
19#include <ql/settings.hpp>
20
21using namespace QuantLib;
22
23namespace QuantExt {
24
25CliquetOption::CliquetOption(const QuantLib::ext::shared_ptr<PercentageStrikePayoff>& payoff,
26 const QuantLib::ext::shared_ptr<EuropeanExercise>& maturity, const std::set<Date>& valuationDates,
27 const Date& paymentDate, const Real notional, const Position::Type& longShort,
28 const Real localCap, const Real localFloor, const Real globalCap, const Real globalFloor,
29 const Real premium, const Date& premiumPayDate, const std::string& premiumCurrency)
30 : OneAssetOption(payoff, maturity), valuationDates_(valuationDates), paymentDate_(paymentDate), notional_(notional),
31 longShort_(longShort), localCap_(localCap), localFloor_(localFloor), globalCap_(globalCap),
32 globalFloor_(globalFloor), premium_(premium), premiumPayDate_(premiumPayDate), premiumCurrency_(premiumCurrency) {
33
34 QL_REQUIRE(valuationDates.size() > 0, "cliquet option: at least one valuation date must be given");
35 QL_REQUIRE(paymentDate >= *valuationDates.rbegin(), "cliquet option: payment date ("
36 << paymentDate << ") must be after last valuation date ("
37 << *valuationDates.rbegin() << ")");
38}
39
40bool CliquetOption::isExpired() const { return Settings::instance().evaluationDate() >= paymentDate_; }
41
43 OneAssetOption::setupArguments(args);
44 CliquetOption::arguments* moreArgs = dynamic_cast<CliquetOption::arguments*>(args);
45 QL_REQUIRE(moreArgs != 0, "cliquet option: wrong engine type");
46
47 moreArgs->notional = notional_;
48 moreArgs->longShort = longShort_;
49 moreArgs->moneyness = QuantLib::ext::dynamic_pointer_cast<PercentageStrikePayoff>(payoff_)->strike();
50 moreArgs->type = QuantLib::ext::dynamic_pointer_cast<PercentageStrikePayoff>(payoff_)->optionType();
52 moreArgs->paymentDate = paymentDate_;
53 moreArgs->localCap = localCap_;
54 moreArgs->localFloor = localFloor_;
55 moreArgs->globalCap = globalCap_;
56 moreArgs->globalFloor = globalFloor_;
57 moreArgs->premium = premium_;
60}
61
63
64 QuantLib::ext::shared_ptr<PercentageStrikePayoff> moneyness = QuantLib::ext::dynamic_pointer_cast<PercentageStrikePayoff>(payoff);
65 QL_REQUIRE(moneyness, "wrong payoff type");
66 QL_REQUIRE(moneyness->strike() > 0.0, "negative or zero moneyness given");
67 QL_REQUIRE(!valuationDates.empty(), "no reset dates given");
68}
69
70} // namespace QuantExt
const Position::Type longShort_
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
const std::set< Date > & valuationDates() const
CliquetOption(const QuantLib::ext::shared_ptr< PercentageStrikePayoff > &payoff, const QuantLib::ext::shared_ptr< EuropeanExercise > &maturity, const std::set< Date > &valuationDates, const Date &paymentDate, const Real notional, const Position::Type &longShort, const Real localCap=Null< Real >(), const Real localFloor=Null< Real >(), const Real globalCap=Null< Real >(), const Real globalFloor=Null< Real >(), const Real premium=Null< Real >(), const Date &premiumPayDate=Date(), const std::string &premiumCurrency="")
const std::string premiumCurrency_
const std::set< Date > valuationDates_
Cliquet option.