QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
asianoption.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) 2003, 2004 Ferdinando Ametrano
5 Copyright (C) 2004, 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 asianoption.hpp
22 \brief Asian option on a single asset
23*/
24
25#ifndef quantlib_asian_option_hpp
26#define quantlib_asian_option_hpp
27
31#include <ql/time/date.hpp>
32#include <vector>
33
34namespace QuantLib {
35
36 //! Continuous-averaging Asian option
37 /*! \todo add running average
38
39 \ingroup instruments
40 */
42 public:
43 class arguments;
44 class engine;
46 Average::Type averageType,
47 const ext::shared_ptr<StrikedTypePayoff>& payoff,
48 const ext::shared_ptr<Exercise>& exercise);
49 void setupArguments(PricingEngine::arguments*) const override;
50
51 protected:
53 };
54
55 //! Discrete-averaging Asian option
56 /*! \ingroup instruments */
58 public:
59 class arguments;
60 class engine;
61 /*! This constructor takes the running sum or product of past fixings,
62 depending on the average type. The fixing dates passed here can be
63 only the future ones.
64 */
66 Real runningAccumulator,
67 Size pastFixings,
68 std::vector<Date> fixingDates,
69 const ext::shared_ptr<StrikedTypePayoff>& payoff,
70 const ext::shared_ptr<Exercise>& exercise);
71
72 /*! This constructor takes past fixings as a vector, defaulting to an empty
73 vector representing an unseasoned option. This constructor expects *all* fixing dates
74 to be provided, including those in the past, and to be already sorted. During the
75 calculations, the option will compare them to the evaluation date to determine which
76 are historic; it will then take as many values from allPastFixings as needed and ignore
77 the others. If not enough fixings are provided, it will raise an error.
78 */
80 std::vector<Date> fixingDates,
81 const ext::shared_ptr<StrikedTypePayoff>& payoff,
82 const ext::shared_ptr<Exercise>& exercise,
83 std::vector<Real> allPastFixings = std::vector<Real>());
84
85 void setupArguments(PricingEngine::arguments*) const override;
86
87 protected:
91 std::vector<Date> fixingDates_;
92
93 // For backwards compatibility with the traditional interface, we keep track of
94 // whether this option was initialised using the full array of seasoned fixings
95 // (even if empty) or if a pastFixings and a runningAccumulator was provided
97 std::vector<Real> allPastFixings_;
98 };
99
100 //! Extra %arguments for single-asset discrete-average Asian option
102 : public OneAssetOption::arguments {
103 public:
106 pastFixings(Null<Size>()) {}
107 void validate() const override;
111 std::vector<Date> fixingDates;
112 };
113
114 //! Extra %arguments for single-asset continuous-average Asian option
116 : public OneAssetOption::arguments {
117 public:
119 void validate() const override;
121 };
122
123 //! Discrete-averaging Asian %engine base class
125 : public GenericEngine<DiscreteAveragingAsianOption::arguments,
126 DiscreteAveragingAsianOption::results> {};
127
128 //! Continuous-averaging Asian %engine base class
130 : public GenericEngine<ContinuousAveragingAsianOption::arguments,
131 ContinuousAveragingAsianOption::results> {};
132
133}
134
135
136#endif
Averaging algorithm enumeration.
Extra arguments for single-asset continuous-average Asian option.
Continuous-averaging Asian engine base class.
Continuous-averaging Asian option.
Definition: asianoption.hpp:41
void setupArguments(PricingEngine::arguments *) const override
Extra arguments for single-asset discrete-average Asian option.
Discrete-averaging Asian engine base class.
Discrete-averaging Asian option.
Definition: asianoption.hpp:57
void setupArguments(PricingEngine::arguments *) const override
Definition: asianoption.cpp:64
template base class for option pricing engines
template class providing a null value for a given type.
Definition: null.hpp:76
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
date- and time-related classes, typedefs and enumerations
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
Option on a single asset.
Payoffs for various options.
Placeholder for enumerated averaging types.
Definition: averagetype.hpp:34