QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
futuresconvadjustmentquote.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) 2006 Giorgio Facchinetti
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
22#include <ql/time/imm.hpp>
23#include <utility>
24
25namespace QuantLib {
26
27 FuturesConvAdjustmentQuote::FuturesConvAdjustmentQuote(const ext::shared_ptr<IborIndex>& index,
28 const Date& futuresDate,
29 Handle<Quote> futuresQuote,
30 Handle<Quote> volatility,
31 Handle<Quote> meanReversion)
32 : dc_(index->dayCounter()), futuresDate_(futuresDate),
33 indexMaturityDate_(index->maturityDate(futuresDate_)), futuresQuote_(std::move(futuresQuote)),
34 volatility_(std::move(volatility)), meanReversion_(std::move(meanReversion)) {
35
39 }
40
41 FuturesConvAdjustmentQuote::FuturesConvAdjustmentQuote(const ext::shared_ptr<IborIndex>& index,
42 const std::string& immCode,
43 Handle<Quote> futuresQuote,
44 Handle<Quote> volatility,
45 Handle<Quote> meanReversion)
46 : dc_(index->dayCounter()), futuresDate_(IMM::date(immCode)),
47 indexMaturityDate_(index->maturityDate(futuresDate_)), futuresQuote_(std::move(futuresQuote)),
48 volatility_(std::move(volatility)), meanReversion_(std::move(meanReversion)) {
49
53 }
54
56
57 Date settlementDate = Settings::instance().evaluationDate();
58 Time startTime = dc_.yearFraction(settlementDate, futuresDate_);
59 Time indexMaturity = dc_.yearFraction(settlementDate,
62 startTime,
63 indexMaturity,
64 volatility_->value(),
65 meanReversion_->value());
66 }
67
69 return !futuresQuote_.empty() && !volatility_.empty() &&
70 !meanReversion_.empty() && futuresQuote_->isValid() &&
71 volatility_->isValid() && meanReversion_->isValid();
72 }
73}
Concrete date class.
Definition: date.hpp:125
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Definition: daycounter.hpp:128
FuturesConvAdjustmentQuote(const ext::shared_ptr< IborIndex > &index, const Date &futuresDate, Handle< Quote > futuresQuote, Handle< Quote > volatility, Handle< Quote > meanReversion)
Real value() const override
returns the current value
bool isValid() const override
returns true if the Quote holds a valid value
Shared handle to an observable.
Definition: handle.hpp:41
static Rate convexityBias(Real futurePrice, Time t, Time T, Real sigma, Real a)
Definition: hullwhite.cpp:133
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
DateProxy & evaluationDate()
the date at which pricing is to be performed.
Definition: settings.hpp:147
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
quote for the futures-convexity adjustment of an index
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Hull & White (HW) model.
IMM-related date functions.
Definition: any.hpp:35
STL namespace.
Main cycle of the International Money Market (a.k.a. IMM) months.
Definition: imm.hpp:35