QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
callabilityschedule.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) 2005 Joseph Wang
5 Copyright (C) 2005, 2006 Theo Boafo
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 callabilityschedule.hpp
22 \brief Schedule of put/call dates
23*/
24
25#ifndef quantlib_callability_schedule_hpp
26#define quantlib_callability_schedule_hpp
27
28#include <ql/event.hpp>
31#include <ql/utilities/null.hpp>
32#include <ql/shared_ptr.hpp>
33#include <ql/optional.hpp>
34#include <vector>
35
36namespace QuantLib {
37
38 //! %instrument callability
39 class Callability : public Event {
40 public:
41 //! type of the callability
42 enum Type { Call, Put };
43
46 const Bond::Price& price() const {
47 QL_REQUIRE(price_, "no price given");
48 return *price_;
49 }
50 Type type() const { return type_; }
51 //! \name Event interface
52 //@{
53 Date date() const override { return date_; }
54 //@}
55 //! \name Visitability
56 //@{
57 void accept(AcyclicVisitor&) override;
58 //@}
59 private:
60 ext::optional<Bond::Price> price_;
63 };
64
66 auto* v1 = dynamic_cast<Visitor<Callability>*>(&v);
67 if (v1 != nullptr)
68 v1->visit(*this);
69 else
71 }
72
73 typedef std::vector<ext::shared_ptr<Callability> > CallabilitySchedule;
74
75}
76
77#endif
concrete bond class
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Bond price information.
Definition: bond.hpp:62
instrument callability
Type
type of the callability
void accept(AcyclicVisitor &) override
Callability(const Bond::Price &price, Type type, const Date &date)
Date date() const override
returns the date at which the event occurs
const Bond::Price & price() const
ext::optional< Bond::Price > price_
Concrete date class.
Definition: date.hpp:125
Base class for event.
Definition: event.hpp:40
virtual void accept(AcyclicVisitor &)
Definition: event.cpp:41
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
#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.
Definition: any.hpp:35
std::vector< ext::shared_ptr< Callability > > CallabilitySchedule
null values
Maps optional to either the boost or std implementation.
ext::shared_ptr< BlackVolTermStructure > v
Maps shared_ptr to either the boost or std implementation.
degenerate base class for the Acyclic Visitor pattern