23#include <ql/cashflows/averagebmacoupon.hpp>
24#include <ql/cashflows/coupon.hpp>
25#include <ql/cashflows/cpicoupon.hpp>
26#include <ql/cashflows/floatingratecoupon.hpp>
27#include <ql/cashflows/yoyinflationcoupon.hpp>
28#include <ql/indexes/interestrateindex.hpp>
39class AnalysisGenerator :
public QuantLib::AcyclicVisitor,
40 public QuantLib::Visitor<QuantLib::CashFlow>,
41 public QuantLib::Visitor<QuantLib::IndexedCashFlow>,
42 public QuantLib::Visitor<QuantLib::Coupon>,
43 public QuantLib::Visitor<QuantLib::FloatingRateCoupon>,
44 public QuantLib::Visitor<QuantExt::AverageONIndexedCoupon>,
45 public QuantLib::Visitor<QuantLib::AverageBMACoupon>,
46 public QuantLib::Visitor<QuantExt::FXLinkedCashFlow>,
47 public QuantLib::Visitor<QuantExt::AverageFXLinkedCashFlow>,
48 public QuantLib::Visitor<QuantExt::FloatingRateFXLinkedNotionalCoupon>,
49 public QuantLib::Visitor<QuantLib::InflationCoupon> {
51 vector<vector<string>> flowAnalysis_;
52 static const QuantLib::Size numberOfColumns_ = 5;
57 void visit(QuantLib::CashFlow& c)
override;
58 void visit(QuantLib::IndexedCashFlow& c)
override;
59 void visit(QuantLib::Coupon& c)
override;
60 void visit(QuantLib::FloatingRateCoupon& c)
override;
62 void visit(QuantLib::AverageBMACoupon& c)
override;
66 void visit(QuantLib::InflationCoupon& c)
override;
67 const vector<vector<string>>& analysis()
const;
71#define ACCRUAL_START_DATE 1
72#define ACCRUAL_END_DATE 2
76AnalysisGenerator::AnalysisGenerator() {
reset(); }
78void AnalysisGenerator::reset() {
79 flowAnalysis_.clear();
81 vector<string> headings(numberOfColumns_);
86 headings[
INDEX] = string(
"Index");
88 flowAnalysis_.push_back(headings);
91void AnalysisGenerator::visit(QuantLib::CashFlow& c) {
92 vector<string> cf(numberOfColumns_,
"#N/A");
94 flowAnalysis_.push_back(cf);
97void AnalysisGenerator::visit(QuantLib::Coupon& c) {
98 visit(
static_cast<QuantLib::CashFlow&
>(c));
103void AnalysisGenerator::visit(QuantLib::FloatingRateCoupon& c) {
104 visit(
static_cast<QuantLib::Coupon&
>(c));
106 flowAnalysis_.back()[
INDEX] = c.index()->name();
111 visit(
static_cast<QuantLib::Coupon&
>(c));
113 flowAnalysis_.back()[
INDEX] = c.index()->name();
117void AnalysisGenerator::visit(QuantLib::AverageBMACoupon& c) {
118 for (
auto& d : c.fixingDates()) {
119 visit(
static_cast<QuantLib::Coupon&
>(c));
121 flowAnalysis_.back()[
INDEX] = c.index()->name();
126 visit(
static_cast<QuantLib::CashFlow&
>(c));
132 visit(
static_cast<QuantLib::CashFlow&
>(c));
139 visit(
static_cast<QuantLib::FloatingRateCoupon&
>(c));
145void AnalysisGenerator::visit(QuantLib::InflationCoupon& c) {
146 visit(
static_cast<QuantLib::Coupon&
>(c));
148 flowAnalysis_.back()[
INDEX] = c.index()->name();
151void AnalysisGenerator::visit(QuantLib::IndexedCashFlow& c) {
152 visit(
static_cast<QuantLib::CashFlow&
>(c));
154 flowAnalysis_.back()[
INDEX] = c.index()->name();
156const vector<vector<string>>& AnalysisGenerator::analysis()
const {
return flowAnalysis_; }
160 for (QuantLib::Size i = 0; i < leg.size(); ++i)
const boost::shared_ptr< FxIndex > & fxIndex() const
const std::vector< Date > & fxFixingDates() const
const std::vector< Date > & fixingDates() const
const boost::shared_ptr< FxIndex > & fxIndex() const
Date fxFixingDate() const
#define ACCRUAL_START_DATE
Extended QuantLib flow analysis.
vector< vector< string > > flowAnalysis(const QuantLib::Leg &leg)
Flow Analysis.
Matrix generator(const Matrix &t, const Real horizon)
void reset(const ASTNodePtr root)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
string conversion utilities