19#include <ql/event.hpp>
20#include <ql/termstructures/yieldtermstructure.hpp>
26ForwardBond::ForwardBond(
const QuantLib::ext::shared_ptr<Bond>& underlying,
const QuantLib::ext::shared_ptr<Payoff>& payoff,
27 const Date& fwdMaturityDate,
const Date& fwdSettlementDate,
const bool isPhysicallySettled,
28 const bool settlementDirty,
const Real compensationPayment,
const Date compensationPaymentDate,
29 const Real bondNotional)
30 : underlying_(underlying), payoff_(payoff), lockRate_(Null<Real>()), fwdMaturityDate_(fwdMaturityDate),
31 fwdSettlementDate_(fwdSettlementDate), isPhysicallySettled_(isPhysicallySettled),
32 settlementDirty_(settlementDirty), compensationPayment_(compensationPayment),
33 compensationPaymentDate_(compensationPaymentDate), bondNotional_(bondNotional), dv01_(Null<Real>()) {}
35ForwardBond::ForwardBond(
const QuantLib::ext::shared_ptr<Bond>& underlying,
const Real lockRate,
36 const DayCounter& lockRateDayCounter,
const bool longInForward,
const Date& fwdMaturityDate,
37 const Date& fwdSettlementDate,
const bool isPhysicallySettled,
const bool settlementDirty,
38 const Real compensationPayment,
const Date compensationPaymentDate,
39 const Real bondNotional,
const Real dv01)
40 : underlying_(underlying), payoff_(nullptr), lockRate_(lockRate), lockRateDayCounter_(lockRateDayCounter),
41 longInForward_(longInForward), fwdMaturityDate_(fwdMaturityDate), fwdSettlementDate_(fwdSettlementDate),
42 isPhysicallySettled_(isPhysicallySettled), settlementDirty_(settlementDirty),
43 compensationPayment_(compensationPayment), compensationPaymentDate_(compensationPaymentDate),
44 bondNotional_(bondNotional), dv01_(dv01) {}
46bool ForwardBond::isExpired()
const {
return detail::simple_event(fwdMaturityDate_).hasOccurred(); }
48void ForwardBond::setupArguments(PricingEngine::arguments* args)
const {
50 QL_REQUIRE(
arguments != 0,
"wrong argument type in forward bond");
66void ForwardBond::results::reset() {
67 Instrument::results::reset();
68 forwardValue = Null<Real>();
69 underlyingSpotValue = Null<Real>();
70 underlyingIncome = Null<Real>();
73void ForwardBond::fetchResults(
const PricingEngine::results* r)
const {
74 Instrument::fetchResults(r);
76 QL_REQUIRE(
results,
"wrong result type");
82void ForwardBond::arguments::validate()
const {
83 QL_REQUIRE(underlying,
"bond pointer is null");
84 QL_REQUIRE((payoff !=
nullptr && lockRate == Null<Real>()) || (payoff ==
nullptr && lockRate != Null<Real>()),
85 "exactly one of payoff or lockRate must be filled");
86 QL_REQUIRE(lockRate == Null<Real>() || longInForward,
"if lockRate is given, longInForward must be given as well");
Date compensationPaymentDate
DayCounter lockRateDayCounter
boost::optional< bool > longInForward
QuantLib::ext::shared_ptr< Payoff > payoff
QuantLib::ext::shared_ptr< QuantLib::Bond > underlying
ForwardBond(const QuantLib::ext::shared_ptr< QuantLib::Bond > &underlying, const QuantLib::ext::shared_ptr< Payoff > &payoff, const Date &fwdMaturityDate, const Date &fwdSettlementDate, const bool isPhysicallySettled, const bool settlementDirty, const Real compensationPayment, const Date compensationPaymentDate, const Real bondNotional=1.0)
Constructor vanilla forward bond.
Engine to value a Forward Bond contract.