QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
holderextensibleoption.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2014 Master IMAFA - Polytech'Nice Sophia - Université de Nice Sophia Antipolis
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/experimental/exoticoptions/holderextensibleoption.hpp>
21#include <ql/exercise.hpp>
22
23namespace QuantLib {
24
26 Option::Type type,
27 Real premium,
28 Date secondExpiryDate,
29 Real secondStrike,
30 const ext::shared_ptr<StrikedTypePayoff>& payoff,
31 const ext::shared_ptr<Exercise>& exercise)
32 : OneAssetOption(payoff,exercise),
33 premium_(premium),
34 secondExpiryDate_(secondExpiryDate),
35 secondStrike_(secondStrike) {}
36
38 PricingEngine::arguments* args) const {
40 auto* moreArgs = dynamic_cast<HolderExtensibleOption::arguments*>(args);
41 QL_REQUIRE(moreArgs != nullptr, "wrong argument type");
42 moreArgs->premium = premium_;
43 moreArgs->secondExpiryDate = secondExpiryDate_;
44 moreArgs->secondStrike = secondStrike_;
45 }
46
48 OneAssetOption::arguments::validate();
49 QL_REQUIRE(premium > 0,"negative premium not allowed");
50 QL_REQUIRE(secondExpiryDate != Date() , "no extending date given");
51 QL_REQUIRE(secondExpiryDate >= exercise->lastDate(),
52 "extended date is earlier than or equal to first maturity date");
53 }
54
55}
Concrete date class.
Definition: date.hpp:125
void setupArguments(PricingEngine::arguments *) const override
HolderExtensibleOption(Option::Type type, Real premium, Date secondExpiryDate, Real secondStrike, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
virtual void setupArguments(PricingEngine::arguments *) const
Definition: instrument.cpp:45
Base class for options on a single asset.
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35