QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
vanillaswingoption.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) 2010 Klaus Spanderen
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/*! \file vanillaswingoption.hpp
21 \brief vanilla swing option class
22*/
23
24#ifndef quantlib_vanilla_swing_option_hpp
25#define quantlib_vanilla_swing_option_hpp
26
27#include <ql/exercise.hpp>
31
32namespace QuantLib {
33
34 //! Swing exercise
35 /*! A Swing option can only be exercised at a set of fixed date times
36 */
38 public:
39 explicit SwingExercise(const std::vector<Date>& dates,
40 const std::vector<Size>& seconds = std::vector<Size>());
41 SwingExercise(const Date& from, const Date& to, Size stepSizeSecs);
42
43 const std::vector<Size>& seconds() const;
44
45 std::vector<Time> exerciseTimes(const DayCounter& dc,
46 const Date& refDate) const;
47
48 private:
49 const std::vector<Size> seconds_;
50 };
51
53 public:
55 : StrikedTypePayoff(type, strike) {}
56
57 std::string name() const override { return "ForwardTypePayoff"; }
58 Real operator()(Real price) const override;
59 void accept(AcyclicVisitor&) override;
60 };
61
62 //! base option class
64 public:
65 class arguments;
66 VanillaSwingOption(const ext::shared_ptr<Payoff>& payoff,
67 const ext::shared_ptr<SwingExercise>& ex,
68 Size minExerciseRights, Size maxExerciseRights)
70 minExerciseRights_(minExerciseRights),
71 maxExerciseRights_(maxExerciseRights) {}
72
73 bool isExpired() const override;
74 void setupArguments(PricingEngine::arguments*) const override;
75
76 private:
78 };
79
81 : public virtual PricingEngine::arguments {
82 public:
83 arguments() = default;
84 void validate() const override;
85
87 ext::shared_ptr<StrikedTypePayoff> payoff;
88 ext::shared_ptr<SwingExercise> exercise;
89 };
90}
91
92#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Bermudan exercise.
Definition: exercise.hpp:87
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
const std::vector< Date > & dates() const
Returns all exercise dates.
Definition: exercise.hpp:48
Base class for options on a single asset.
ext::shared_ptr< Payoff > payoff() const
Definition: option.hpp:45
Intermediate class for payoffs based on a fixed strike.
Definition: payoffs.hpp:90
const std::vector< Size > seconds_
const std::vector< Size > & seconds() const
std::vector< Time > exerciseTimes(const DayCounter &dc, const Date &refDate) const
Real operator()(Real price) const override
void accept(AcyclicVisitor &) override
VanillaForwardPayoff(Option::Type type, Real strike)
std::string name() const override
ext::shared_ptr< SwingExercise > exercise
ext::shared_ptr< StrikedTypePayoff > payoff
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
VanillaSwingOption(const ext::shared_ptr< Payoff > &payoff, const ext::shared_ptr< SwingExercise > &ex, Size minExerciseRights, Size maxExerciseRights)
day counter class
Option exercise classes and payoff function.
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.