QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
yoyoptionlethelpers.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 Chris Kenyon
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#include <ql/experimental/inflation/yoyoptionlethelpers.hpp>
21#include <ql/instruments/makeyoyinflationcapfloor.hpp>
22#include <ql/utilities/null_deleter.hpp>
23#include <utility>
24
25namespace QuantLib {
26
28 Real notional,
29 YoYInflationCapFloor::Type capFloorType,
30 Period& lag,
31 DayCounter yoyDayCounter,
32 Calendar paymentCalendar,
33 Natural fixingDays,
34 ext::shared_ptr<YoYInflationIndex> index,
35 Rate strike,
36 Size n,
37 ext::shared_ptr<YoYInflationCapFloorEngine> pricer)
38 : BootstrapHelper<YoYOptionletVolatilitySurface>(price), notional_(notional),
39 capFloorType_(capFloorType), lag_(lag), fixingDays_(fixingDays), index_(std::move(index)),
40 strike_(strike), n_(n), yoyDayCounter_(std::move(yoyDayCounter)),
41 calendar_(std::move(paymentCalendar)), pricer_(std::move(pricer)) {
42
43 // build the instrument to reprice (only need do this once)
47 .withNominal(notional)
51
52 // dates already build in lag of index/instrument
53 // these are the dates of the values of the index
54 // that fix the capfloor
55 earliestDate_ = ext::dynamic_pointer_cast<YoYInflationCoupon>(
56 yoyCapFloor_->yoyLeg().front())->fixingDate();
57 latestDate_ = ext::dynamic_pointer_cast<YoYInflationCoupon>(
58 yoyCapFloor_->yoyLeg().back())->fixingDate();
59
60 // each reprice is resetting the inflation surf in the
61 // pricer... so set the pricer
62 yoyCapFloor_->setPricingEngine(pricer_);
63 // haven't yet set the vol (term structure = surface)
64 }
65
66
68 yoyCapFloor_->deepUpdate();
69 return yoyCapFloor_->NPV();
70 }
71
72
75
77 // set up a new yoyCapFloor
78 // but this one does NOT own its inflation term structure
79 const bool own = false;
80 // create a handle to the new vol surface
82 ext::shared_ptr<YoYOptionletVolatilitySurface>(v, null_deleter()),
83 own);
84 // in this case all we need to do is reset the vol in the pricer
85 // we must do it because the surface is a different one each time
86 // i.e. the pointer (handle) changes, not just what it points to
87 pricer_->setVolatility(volSurf);
88 }
89
90}
91
Base helper class for bootstrapping.
virtual void setTermStructure(TS *)
sets the term structure to be used for pricing
calendar class
Definition: calendar.hpp:61
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
MakeYoYInflationCapFloor & withStrike(Rate strike)
MakeYoYInflationCapFloor & withFixingDays(Natural fixingDays)
MakeYoYInflationCapFloor & withNominal(Real n)
MakeYoYInflationCapFloor & withPaymentDayCounter(const DayCounter &)
ext::shared_ptr< YoYInflationIndex > index_
void setTermStructure(YoYOptionletVolatilitySurface *) override
ext::shared_ptr< YoYInflationCapFloorEngine > pricer_
ext::shared_ptr< YoYInflationCapFloor > yoyCapFloor_
Real impliedQuote() const override
YoYInflationCapFloor::Type capFloorType_
YoYOptionletHelper(const Handle< Quote > &price, Real notional, YoYInflationCapFloor::Type capFloorType, Period &lag, DayCounter yoyDayCounter, Calendar paymentCalendar, Natural fixingDays, ext::shared_ptr< YoYInflationIndex > index, Rate strike, Size n, ext::shared_ptr< YoYInflationCapFloorEngine > pricer)
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
STL namespace.