Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
DiscountingCommodityForwardEngine Class Reference

Discounting commodity forward engine. More...

#include <qle/pricingengines/discountingcommodityforwardengine.hpp>

+ Inheritance diagram for DiscountingCommodityForwardEngine:
+ Collaboration diagram for DiscountingCommodityForwardEngine:

Public Member Functions

Constructors
 DiscountingCommodityForwardEngine (const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, boost::optional< bool > includeSettlementDateFlows=boost::none, const QuantLib::Date &npvDate=QuantLib::Date())
 
PricingEngine interface
void calculate () const override
 

Inspectors

QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
 
boost::optional< boolincludeSettlementDateFlows_
 
QuantLib::Date npvDate_
 
const QuantLib::Handle< QuantLib::YieldTermStructure > & discountCurve () const
 

Detailed Description

Discounting commodity forward engine.

This class implements pricing of a commodity forward by discounting the future nominal cash flows using the respective yield curve.

Definition at line 42 of file discountingcommodityforwardengine.hpp.

Constructor & Destructor Documentation

◆ DiscountingCommodityForwardEngine()

DiscountingCommodityForwardEngine ( const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve,
boost::optional< bool includeSettlementDateFlows = boost::none,
const QuantLib::Date &  npvDate = QuantLib::Date() 
)
Parameters
discountCurveThe discount curve to discount the forward cashflow.
includeSettlementDateFlowsIf true (false), cashflows on the forward maturity are (are not) included in the NPV.
npvDateDiscount to this date. If not given, is set to the evaluation date

Definition at line 28 of file discountingcommodityforwardengine.cpp.

31 : discountCurve_(discountCurve), includeSettlementDateFlows_(includeSettlementDateFlows),
32 npvDate_(npvDate) {
33
34 registerWith(discountCurve_);
35}
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
const QuantLib::Handle< QuantLib::YieldTermStructure > & discountCurve() const

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 37 of file discountingcommodityforwardengine.cpp.

37 {
38
39 const auto& index = arguments_.index;
40 Date npvDate = npvDate_;
41 if (npvDate == Null<Date>()) {
42 const auto& priceCurve = index->priceCurve();
43 QL_REQUIRE(!priceCurve.empty(), "DiscountingCommodityForwardEngine: need a non-empty price curve.");
44 npvDate = priceCurve->referenceDate();
45 }
46
47 const Date& maturity = arguments_.maturityDate;
48 Date paymentDate = maturity;
49 if (!arguments_.physicallySettled && arguments_.paymentDate != Date()) {
50 paymentDate = arguments_.paymentDate;
51 }
52
53 results_.value = 0.0;
54 if (!detail::simple_event(paymentDate).hasOccurred(Date(), includeSettlementDateFlows_)) {
55
56 Real buySell = arguments_.position == Position::Long ? 1.0 : -1.0;
57 Real forwardPrice = index->fixing(maturity);
58 Real discountPaymentDate = discountCurve_->discount(paymentDate);
59 auto value = arguments_.quantity * buySell * (forwardPrice - arguments_.strike) * discountPaymentDate /
60 discountCurve_->discount(npvDate);
61 if(arguments_.fxIndex && (arguments_.fixingDate!=Date()) && (arguments_.payCcy!=arguments_.currency)){ // NDF
62 auto fxRate = arguments_.fxIndex->fixing(arguments_.fixingDate);
63 value*=fxRate;
64 results_.additionalResults["productCurrency"] = arguments_.currency;
65 results_.additionalResults["settlementCurrency"] = arguments_.payCcy;
66 results_.additionalResults["fxRate"] = fxRate;
67 }
68 results_.value = value;
69 results_.additionalResults["forwardPrice"] = forwardPrice;
70 results_.additionalResults["currentNotional"] = forwardPrice * arguments_.quantity;
71 results_.additionalResults["discountPaymentDate"] = discountPaymentDate;
72 }
73}
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

◆ discountCurve()

const QuantLib::Handle< QuantLib::YieldTermStructure > & discountCurve ( ) const

Definition at line 63 of file discountingcommodityforwardengine.hpp.

63{ return discountCurve_; }

Member Data Documentation

◆ discountCurve_

QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve_
private

Definition at line 67 of file discountingcommodityforwardengine.hpp.

◆ includeSettlementDateFlows_

boost::optional<bool> includeSettlementDateFlows_
private

Definition at line 68 of file discountingcommodityforwardengine.hpp.

◆ npvDate_

QuantLib::Date npvDate_
private

Definition at line 69 of file discountingcommodityforwardengine.hpp.