QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
forwardvanillaoption.hpp
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) 2002, 2003 Ferdinando Ametrano
5 Copyright (C) 2007 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file forwardvanillaoption.hpp
22 \brief Forward version of a vanilla option
23*/
24
25#ifndef quantlib_forward_vanilla_option_hpp
26#define quantlib_forward_vanilla_option_hpp
27
30#include <ql/exercise.hpp>
31#include <ql/settings.hpp>
32
33namespace QuantLib {
34
35 //! %Arguments for forward (strike-resetting) option calculation
36 template <class ArgumentsType>
37 class ForwardOptionArguments : public ArgumentsType {
38 public:
40 resetDate(Null<Date>()) {}
41 void validate() const override;
44 };
45
46 //! %Forward version of a vanilla option
47 /*! \ingroup instruments */
49 public:
52 ForwardVanillaOption(Real moneyness,
53 const Date& resetDate,
54 const ext::shared_ptr<StrikedTypePayoff>& payoff,
55 const ext::shared_ptr<Exercise>& exercise);
56 void setupArguments(PricingEngine::arguments*) const override;
57 void fetchResults(const PricingEngine::results*) const override;
58
59 private:
60 // arguments
63 };
64
65
66 // template definitions
67
68 template <class ArgumentsType>
70 ArgumentsType::validate();
71
72 QL_REQUIRE(moneyness != Null<Real>(), "null moneyness given");
73 QL_REQUIRE(moneyness > 0.0, "negative or zero moneyness given");
74
75 QL_REQUIRE(resetDate != Null<Date>(), "null reset date given");
76 QL_REQUIRE(resetDate >= Settings::instance().evaluationDate(),
77 "reset date in the past");
78 QL_REQUIRE(this->exercise->lastDate() > resetDate,
79 "reset date later or equal to maturity");
80 }
81
82
83}
84
85
86#endif
87
Concrete date class.
Definition: date.hpp:125
Arguments for forward (strike-resetting) option calculation
Forward version of a vanilla option
void setupArguments(PricingEngine::arguments *) const override
ForwardOptionArguments< OneAssetOption::arguments > arguments
void fetchResults(const PricingEngine::results *) const override
template class providing a null value for a given type.
Definition: null.hpp:76
Results from single-asset option calculation
Base class for options on a single asset.
ext::shared_ptr< Payoff > payoff() const
Definition: option.hpp:45
ext::shared_ptr< Exercise > exercise() const
Definition: option.hpp:46
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
#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
Definition: any.hpp:35
Option on a single asset.
Payoffs for various options.
global repository for run-time library settings