21#include <ql/cashflows/cashflows.hpp>
22#include <ql/cashflows/coupon.hpp>
23#include <ql/settings.hpp>
30 Date today = Settings::instance().evaluationDate();
31 Real multiplier =
arguments_.cashLegPays ? -1.0 : 1.0;
32 Real cashLegAccrual = 0.0, cashLegNominal = 0.0, cashLegNpv = 0.0;
33 auto cf = CashFlows::nextCashFlow(
arguments_.cashLeg,
false);
35 auto cpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(*cf);
36 cashLegNominal = multiplier * cpn->nominal();
37 cashLegAccrual = multiplier * CashFlows::accruedAmount(
arguments_.cashLeg,
false);
38 cashLegNpv = cashLegNominal + cashLegAccrual;
41 Real securityLegAccrual = -multiplier *
arguments_.security->accruedAmount(today) / 100.0 *
43 results_.additionalResults[
"CashLegNominal"] = cashLegNominal;
44 results_.additionalResults[
"CashLegAccrual"] = cashLegAccrual;
45 results_.additionalResults[
"CashLegNPV"] = cashLegNpv;
47 results_.additionalResults[
"SecurityLegCleanNPV"] = securityLegNpv - securityLegAccrual;
48 results_.additionalResults[
"SecurityLegAccrual"] = securityLegAccrual;
49 results_.additionalResults[
"SecurityLegNPV"] = securityLegNpv;
const Instrument::results * results_
const bool includeSecurityLeg_
void calculate() const override
AccrualBondRepoEngine(const bool includeSecurityLeg=true)
Swap::arguments * arguments_