/src/quantlib/ql/quotes/eurodollarfuturesquote.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2006, 2008 Ferdinando Ametrano |
5 | | Copyright (C) 2006 François du Vignaud |
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 | | <https://www.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 | | #include <ql/pricingengines/blackformula.hpp> |
22 | | #include <ql/quotes/eurodollarfuturesquote.hpp> |
23 | | #include <utility> |
24 | | |
25 | | namespace QuantLib { |
26 | | |
27 | | EurodollarFuturesImpliedStdDevQuote::EurodollarFuturesImpliedStdDevQuote( |
28 | | Handle<Quote> forward, |
29 | | Handle<Quote> callPrice, |
30 | | Handle<Quote> putPrice, |
31 | | Real strike, |
32 | | Real guess, |
33 | | Real accuracy, |
34 | | Natural maxIter) |
35 | 0 | : impliedStdev_(guess), strike_(100.0 - strike), accuracy_(accuracy), maxIter_(maxIter), |
36 | 0 | forward_(std::move(forward)), callPrice_(std::move(callPrice)), |
37 | 0 | putPrice_(std::move(putPrice)) { |
38 | 0 | registerWith(forward_); |
39 | 0 | registerWith(callPrice_); |
40 | 0 | registerWith(putPrice_); |
41 | 0 | } Unexecuted instantiation: QuantLib::EurodollarFuturesImpliedStdDevQuote::EurodollarFuturesImpliedStdDevQuote(QuantLib::Handle<QuantLib::Quote>, QuantLib::Handle<QuantLib::Quote>, QuantLib::Handle<QuantLib::Quote>, double, double, double, unsigned int) Unexecuted instantiation: QuantLib::EurodollarFuturesImpliedStdDevQuote::EurodollarFuturesImpliedStdDevQuote(QuantLib::Handle<QuantLib::Quote>, QuantLib::Handle<QuantLib::Quote>, QuantLib::Handle<QuantLib::Quote>, double, double, double, unsigned int) |
42 | | |
43 | 0 | Real EurodollarFuturesImpliedStdDevQuote::value() const { |
44 | 0 | calculate(); |
45 | 0 | return impliedStdev_; |
46 | 0 | } |
47 | | |
48 | 0 | bool EurodollarFuturesImpliedStdDevQuote::isValid() const { |
49 | 0 | if (forward_.empty() || !forward_->isValid()) |
50 | 0 | return false; |
51 | 0 | Real forwardValue = 100.0-forward_->value(); |
52 | 0 | if (strike_>forwardValue) |
53 | 0 | return !putPrice_.empty() && putPrice_->isValid(); |
54 | 0 | else |
55 | 0 | return !callPrice_.empty() && callPrice_->isValid(); |
56 | 0 | } |
57 | | |
58 | 0 | void EurodollarFuturesImpliedStdDevQuote::performCalculations() const { |
59 | 0 | static const Real discount = 1.0; |
60 | 0 | static const Real displacement = 0.0; |
61 | 0 | Real forwardValue = 100.0-forward_->value(); |
62 | 0 | if (strike_>forwardValue) { |
63 | 0 | impliedStdev_ = |
64 | 0 | blackFormulaImpliedStdDev(Option::Call, strike_, |
65 | 0 | forwardValue, putPrice_->value(), |
66 | 0 | discount, displacement, |
67 | 0 | impliedStdev_, accuracy_, maxIter_); |
68 | 0 | } else { |
69 | 0 | impliedStdev_ = |
70 | 0 | blackFormulaImpliedStdDev(Option::Put, strike_, |
71 | 0 | forwardValue, callPrice_->value(), |
72 | 0 | discount, displacement, |
73 | 0 | impliedStdev_, accuracy_, maxIter_); |
74 | 0 | } |
75 | 0 | } |
76 | | } |