Loading [MathJax]/extensions/tex2jax.js
QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
•All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
partialtimebarrieroption.cpp
Go to the documentation of this file.
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
21#include <ql/exercise.hpp>
22
23namespace QuantLib {
24
26 Barrier::Type barrierType,
27 PartialBarrier::Range barrierRange,
28 Real barrier,
29 Real rebate,
30 Date coverEventDate,
31 const ext::shared_ptr<StrikedTypePayoff>& payoff,
32 const ext::shared_ptr<Exercise>& exercise)
33 : OneAssetOption(payoff, exercise),
34 barrierType_(barrierType), barrierRange_(barrierRange),
35 barrier_(barrier), rebate_(rebate),
36 coverEventDate_(coverEventDate) {}
37
39 PricingEngine::arguments* args) const {
41
42 auto* moreArgs = dynamic_cast<PartialTimeBarrierOption::arguments*>(args);
43 QL_REQUIRE(moreArgs != nullptr, "wrong argument type");
44 moreArgs->barrierType = barrierType_;
45 moreArgs->barrierRange = barrierRange_;
46 moreArgs->barrier = barrier_;
47 moreArgs->rebate = rebate_;
48 moreArgs->coverEventDate = coverEventDate_;
49 }
50
52 : barrierType(Barrier::Type(-1)),
53 barrierRange(PartialBarrier::Range(-1)),
54 barrier(Null<Real>()), rebate(Null<Real>()) {}
55
57 OneAssetOption::arguments::validate();
58
59 QL_REQUIRE(barrier != Null<Real>(), "no barrier given");
60 QL_REQUIRE(rebate != Null<Real>(), "no rebate given");
61 QL_REQUIRE(coverEventDate != Date(), "no cover event date given");
62 QL_REQUIRE(coverEventDate < exercise->lastDate(),
63 "cover event date equal or later than exercise date");
64 }
65
66}
Concrete date class.
Definition: date.hpp:125
virtual void setupArguments(PricingEngine::arguments *) const
Definition: instrument.cpp:45
template class providing a null value for a given type.
Definition: null.hpp:59
Base class for options on a single asset.
Arguments for partial-time barrier option calculation
void setupArguments(PricingEngine::arguments *) const override
PartialTimeBarrierOption(Barrier::Type barrierType, PartialBarrier::Range barrierRange, Real barrier, Real rebate, Date coverEventDate, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Option exercise classes and payoff function.
QL_REAL Real
real number
Definition: types.hpp:50
Partial-time barrier option.
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:37
Placeholder for enumerated barrier types.
Definition: barriertype.hpp:35
choice of time range for partial-time barrier options