23#include <ql/instruments/overnightindexedswap.hpp>
24#include <ql/instruments/vanillaswap.hpp>
26#include <ql/cashflows/fixedratecoupon.hpp>
27#include <ql/cashflows/iborcoupon.hpp>
28#include <ql/cashflows/overnightindexedcoupon.hpp>
29#include <ql/indexes/iborindex.hpp>
30#include <ql/indexes/swapindex.hpp>
34std::size_t
LgmCG::numeraire(
const Date& d,
const std::size_t x,
const Handle<YieldTermStructure>& discountCurve,
35 const std::string& discountCurveId)
const {
41 Real t = p()->termStructure()->timeFromReference(d);
49 return (discountCurve.empty() ? p()->termStructure() : discountCurve)->discount(t);
61 const Handle<YieldTermStructure>& discountCurve,
62 const std::string& discountCurveId)
const {
74 const Handle<YieldTermStructure>& discountCurve,
75 const std::string& discountCurveId)
const {
84 Real t = p()->termStructure()->timeFromReference(d);
85 Real T = p()->termStructure()->timeFromReference(e);
94 return (discountCurve.empty() ? p()->termStructure() : discountCurve)->discount(T);
105std::size_t
LgmCG::fixing(
const QuantLib::ext::shared_ptr<InterestRateIndex>& index,
const Date& fixingDate,
const Date& t,
106 const std::size_t x)
const {
115 Date today = Settings::instance().evaluationDate();
123 }
else if (
auto ibor = QuantLib::ext::dynamic_pointer_cast<IborIndex>(index)) {
127 Date d1 = std::max(t, ibor->valueDate(
fixingDate));
128 Date d2 = ibor->maturityDate(d1);
130 Time dt = ibor->dayCounter().yearFraction(d1, d2);
132 std::size_t disc1 =
reducedDiscountBond(t, d1, x, ibor->forwardingTermStructure(),
"fwd_" + index->name());
133 std::size_t disc2 =
reducedDiscountBond(t, d2, x, ibor->forwardingTermStructure(),
"fwd_" + index->name());
138 QL_FAIL(
"LgmCG::fixing(): only ibor indices handled so far, index = " << index->name());
void setVariable(const std::string &name, const std::size_t node)
QuantExt::ComputationGraph & g_
std::size_t numeraire(const Date &d, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
std::vector< std::pair< std::size_t, std::function< double(void)> > > & modelParameters_
std::function< QuantLib::ext::shared_ptr< IrLgm1fParametrization >()> p_
std::size_t reducedDiscountBond(const Date &d, Date e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
std::size_t fixing(const QuantLib::ext::shared_ptr< InterestRateIndex > &index, const Date &fixingDate, const Date &t, const std::size_t x) const
std::size_t discountBond(const Date &d, const Date &e, const std::size_t x, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const std::string &discountCurveId="default") const
computation graph based lgm model calculations
basis implementation for a script engine model
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
std::size_t cg_const(ComputationGraph &g, const double value)
std::size_t cg_subtract(ComputationGraph &g, const std::size_t a, const std::size_t b, const std::string &label)
std::size_t cg_exp(ComputationGraph &g, const std::size_t a, const std::string &label)
std::size_t cg_negative(ComputationGraph &g, const std::size_t a, const std::string &label)
std::size_t cg_mult(ComputationGraph &g, const std::size_t a, const std::size_t b, const std::string &label)
std::size_t cg_add(ComputationGraph &g, const std::size_t a, const std::size_t b, const std::string &label)
std::size_t cg_var(ComputationGraph &g, const std::string &name, const bool createIfNotExists)
std::size_t cg_div(ComputationGraph &g, const std::size_t a, const std::size_t b, const std::string &label)
std::string to_string(const LocationInfo &l)
std::size_t addModelParameter(ComputationGraph &g, std::vector< std::pair< std::size_t, std::function< double(void)> > > &m, const std::string &id, std::function< double(void)> f)
string conversion utilities