Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
futurepricehelper.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21using QuantLib::AcyclicVisitor;
22using QuantLib::Date;
23using QuantLib::Handle;
24using QuantLib::Quote;
25using QuantLib::Real;
26using QuantLib::Visitor;
27
28namespace QuantExt {
29
30FuturePriceHelper::FuturePriceHelper(const Handle<Quote>& price, const Date& expiryDate)
31 : PriceHelper(price) {
32 earliestDate_ = expiryDate;
33 pillarDate_ = expiryDate;
34}
35
36FuturePriceHelper::FuturePriceHelper(Real price, const Date& expiryDate)
37 : PriceHelper(price) {
38 earliestDate_ = expiryDate;
39 pillarDate_ = expiryDate;
40}
41
42Real FuturePriceHelper::impliedQuote() const {
43 QL_REQUIRE(termStructure_, "FuturePriceHelper term structure not set.");
44 return termStructure_->price(pillarDate_);
45}
46
47void FuturePriceHelper::accept(AcyclicVisitor& v) {
48 if (auto vis = dynamic_cast<Visitor<FuturePriceHelper>*>(&v))
49 vis->visit(*this);
50 else
51 PriceHelper::accept(v);
52}
53
54}
FuturePriceHelper(const QuantLib::Handle< QuantLib::Quote > &price, const QuantLib::Date &expiryDate)
Future price helper.