QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
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 void validate() const override;
43 };
44
45 //! %Forward version of a vanilla option
46 /*! \ingroup instruments */
48 public:
51 ForwardVanillaOption(Real moneyness,
52 const Date& resetDate,
53 const ext::shared_ptr<StrikedTypePayoff>& payoff,
54 const ext::shared_ptr<Exercise>& exercise);
55 void setupArguments(PricingEngine::arguments*) const override;
56 void fetchResults(const PricingEngine::results*) const override;
57
58 private:
59 // arguments
62 };
63
64
65 // template definitions
66
67 template <class ArgumentsType>
69 ArgumentsType::validate();
70
71 QL_REQUIRE(moneyness != Null<Real>(), "null moneyness given");
72 QL_REQUIRE(moneyness > 0.0, "negative or zero moneyness given");
73
74 QL_REQUIRE(resetDate != Date(), "null reset date given");
75 QL_REQUIRE(resetDate >= Settings::instance().evaluationDate(),
76 "reset date in the past");
77 QL_REQUIRE(this->exercise->lastDate() > resetDate,
78 "reset date later or equal to maturity");
79 }
80
81
82}
83
84
85#endif
86
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:59
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:37
Option on a single asset.
Payoffs for various options.
global repository for run-time library settings