19#include <boost/make_shared.hpp>
27#include <ql/cashflows/simplecashflow.hpp>
41 LOG(
"FxAverageForward::build() called");
44 QL_REQUIRE(!
fxIndex_.empty(),
"fx index must not be blank");
49 QL_REQUIRE(payDate >= observationSchedule.dates().back(),
50 "payment date >= last observation date required");
52 QL_REQUIRE(!
fxIndex_.empty(),
"FX settlement index must be specified for averaging forwards");
53 QuantLib::ext::shared_ptr<QuantExt::FxIndex>
fxIndex =
buildFxIndex(
fxIndex_, payCcy.code(), refCcy.code(), engineFactory->market(),
55 for (
const auto& date : observationSchedule.dates()) {
56 if (date <= Settings::instance().evaluationDate())
64 {QuantLib::ext::make_shared<QuantExt::AverageFXLinkedCashFlow>(payDate, observationSchedule.dates(),
71 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(
"Swap");
72 QuantLib::ext::shared_ptr<SwapEngineBuilderBase> swapBuilder = QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(builder);
73 QL_REQUIRE(swapBuilder,
"No Builder found for Swap " <<
id());
74 swap->setPricingEngine(swapBuilder->engine(payCcy, std::string(), std::string()));
83 LOG(
"FxAverageForward::build() done");
93 auto avg = QuantLib::ext::dynamic_pointer_cast<QuantExt::AverageFXLinkedCashFlow>(
legs_[1].front());
95 for (
auto [date,
value] : avg->fixings())
107 QL_REQUIRE(fxNode,
"No FxAverageForwardData Node");
110 QL_REQUIRE(tmp,
"No ObservationDates provided in FxAverageForwardData");
Engine builder for Swaps.
string settlementCurrency_
string referenceCurrency_
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
double referenceNotional_
ScheduleData observationDates_
double settlementNotional_
std::string fxIndex_
Needed for past fixings.
const std::string & fxIndex() const
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
const std::map< std::string, boost::any > & additionalData() const override
returns all additional data returned by the trade once built
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
std::vector< bool > legPayers_
std::vector< string > legCurrencies_
std::vector< QuantLib::Leg > legs_
virtual void fromXML(XMLNode *node) override
void setSensitivityTemplate(const EngineBuilder &builder)
virtual XMLNode * toXML(XMLDocument &doc) const override
RequiredFixings requiredFixings_
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Vanilla Instrument Wrapper.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
SafeStack< ValueType > value
Fx Average Forward data model and serialization.
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Classes and functions for log message handling.
#define LOG(text)
Logging Macro (Level = Notice)
market data related utilties
std::string to_string(const LocationInfo &l)
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
Schedule makeSchedule(const ScheduleDates &data)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.