QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
discountingbondengine.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) 2007 Giorgio Facchinetti
5 Copyright (C) 2009 StatPro Italia srl
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
23#include <ql/optional.hpp>
24#include <utility>
25
26namespace QuantLib {
27
29 Handle<YieldTermStructure> discountCurve,
30 const ext::optional<bool>& includeSettlementDateFlows)
31 : discountCurve_(std::move(discountCurve)),
32 includeSettlementDateFlows_(includeSettlementDateFlows) {
34 }
35
38 "discounting term structure handle is empty");
39
40 results_.valuationDate = (*discountCurve_)->referenceDate();
41
42 bool includeRefDateFlows = includeSettlementDateFlows_ ? // NOLINT(readability-implicit-bool-conversion)
45
48 includeRefDateFlows,
51
52 // a bond's cashflow on settlement date is never taken into
53 // account, so we might have to play it safe and recalculate
54 if (!includeRefDateFlows
56 // same parameters as above, we can avoid another call
58 } else {
59 // no such luck
63 false,
66 }
67 }
68
69}
bool includeSettlementDateFlows_
Definition: cashflows.cpp:1188
const YieldTermStructure & discountCurve_
Definition: cashflows.cpp:418
Cash-flow analysis functions.
static Real npv(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
NPV of the cash flows.
Definition: cashflows.cpp:425
Handle< YieldTermStructure > discountCurve_
ext::optional< bool > includeSettlementDateFlows_
DiscountingBondEngine(Handle< YieldTermStructure > discountCurve=Handle< YieldTermStructure >(), const ext::optional< bool > &includeSettlementDateFlows=ext::nullopt)
Shared handle to an observable.
Definition: handle.hpp:41
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
bool & includeReferenceDateEvents()
Definition: settings.hpp:155
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
discounting bond engine
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Definition: any.hpp:35
STL namespace.
Maps optional to either the boost or std implementation.