Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
discountingequityforwardengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
19#include <ql/event.hpp>
20
22
23namespace QuantExt {
24
26 const Handle<YieldTermStructure>& equityInterestRateCurve, const Handle<YieldTermStructure>& dividendYieldCurve,
27 const Handle<Quote>& equitySpot, const Handle<YieldTermStructure>& discountCurve,
28 boost::optional<bool> includeSettlementDateFlows, const Date& settlementDate, const Date& npvDate)
29 : equityRefRateCurve_(equityInterestRateCurve), divYieldCurve_(dividendYieldCurve), equitySpot_(equitySpot),
30 discountCurve_(discountCurve), includeSettlementDateFlows_(includeSettlementDateFlows),
31 settlementDate_(settlementDate), npvDate_(npvDate) {
32
33 registerWith(equityRefRateCurve_);
34 registerWith(divYieldCurve_);
35 registerWith(equitySpot_);
36 registerWith(discountCurve_);
37}
38
40
41 Date npvDate = npvDate_;
42 if (npvDate == Null<Date>()) {
43 npvDate = divYieldCurve_->referenceDate();
44 }
45 Date settlementDate = settlementDate_;
46 if (settlementDate == Null<Date>()) {
47 settlementDate = npvDate;
48 }
49
50 results_.value = 0.0;
51
52 if (!detail::simple_event(arguments_.maturityDate).hasOccurred(settlementDate, includeSettlementDateFlows_)) {
53 Real lsInd = ((arguments_.longShort == Position::Long) ? 1.0 : -1.0);
54 Real qty = arguments_.quantity;
55 Date maturity = arguments_.maturityDate;
56 Real strike = arguments_.strike;
57 Real forwardPrice =
58 equitySpot_->value() * divYieldCurve_->discount(maturity) / equityRefRateCurve_->discount(maturity);
59 DiscountFactor df = discountCurve_->discount(maturity);
60 results_.value = (lsInd * qty) * (forwardPrice - strike) * df;
61
62 results_.additionalResults["forwardPrice"] = forwardPrice;
63 results_.additionalResults["currentNotional"] = forwardPrice * strike;
64 }
65} // calculate
66
67} // namespace QuantExt
const Instrument::results * results_
Definition: cdsoption.cpp:81
DiscountingEquityForwardEngine(const Handle< YieldTermStructure > &equityInterestRateCurve, const Handle< YieldTermStructure > &dividendYieldCurve, const Handle< Quote > &equitySpot, const Handle< YieldTermStructure > &discountCurve, boost::optional< bool > includeSettlementDateFlows=boost::none, const Date &settlementDate=Date(), const Date &npvDate=Date())
Engine to value an Equity Forward contract.
Swap::arguments * arguments_