QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
vanillavppoption.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) 2011 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 vanillavppoption.cpp
21*/
22
23
24#include <ql/event.hpp>
28
29namespace QuantLib {
30 namespace {
31
32 class IdenticalPayoff : public Payoff {
33 public:
34 std::string name() const override { return "IdenticalPayoff"; }
35 std::string description() const override { return name(); }
36 Real operator()(Real price) const override { return price; }
37 };
38 }
39
41 Real heatRate,
42 Real pMin, Real pMax,
43 Size tMinUp, Size tMinDown,
44 Real startUpFuel, Real startUpFixCost,
45 const ext::shared_ptr<SwingExercise>& exercise,
46 Size nStarts, Size nRunningHours)
47 : MultiAssetOption(ext::shared_ptr<Payoff>(), exercise),
48 heatRate_(heatRate),
49 pMin_(pMin), pMax_(pMax),
50 tMinUp_(tMinUp), tMinDown_(tMinDown),
51 startUpFuel_(startUpFuel),
52 startUpFixCost_(startUpFixCost),
53 nStarts_(nStarts),
54 nRunningHours_(nRunningHours) {
55 Array weigths(2);
56 weigths[0] = 1.0; weigths[1] = -heatRate;
57
58 payoff_ = ext::shared_ptr<Payoff>(new AverageBasketPayoff(
59 ext::shared_ptr<Payoff>(new IdenticalPayoff()), weigths));
60 }
61
63 QL_REQUIRE(exercise, "no exercise given");
65 "either a start limit or fuel limit is supported");
66 }
67
69 PricingEngine::arguments* args) const {
70
72
73 auto* arguments = dynamic_cast<VanillaVPPOption::arguments*>(args);
74 QL_REQUIRE(arguments != nullptr, "wrong argument type");
75
85 }
86
88 return detail::simple_event(exercise_->lastDate()).hasOccurred();
89 }
90}
91
Basket option on a number of assets.
1-D array used in linear algebra.
Definition: array.hpp:52
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
Definition: event.cpp:28
Base class for options on multiple assets.
void setupArguments(PricingEngine::arguments *) const override
template class providing a null value for a given type.
Definition: null.hpp:76
ext::shared_ptr< Exercise > exercise
Definition: option.hpp:65
ext::shared_ptr< Payoff > payoff_
Definition: option.hpp:49
ext::shared_ptr< Exercise > exercise_
Definition: option.hpp:50
Abstract base class for option payoffs.
Definition: payoff.hpp:36
VanillaVPPOption(Real heatRate, Real pMin, Real pMax, Size tMinUp, Size tMinDown, Real startUpFuel, Real startUpFixCost, const ext::shared_ptr< SwingExercise > &exercise, Size nStarts=Null< Size >(), Size nRunningHours=Null< Size >())
void setupArguments(PricingEngine::arguments *) const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
const Real heatRate_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Base class for events associated with a given date.
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
vanilla swing option class
vanilla virtual power plant option