23#include <ql/cashflows/simplecashflow.hpp>
24#include <ql/instruments/compositeinstrument.hpp>
34void FxSwap::build(
const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
53 DLOG(
"FxSwap::build() called for trade " <<
id());
61 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(
"FxForward");
62 QL_REQUIRE(builder,
"No builder found for " <<
tradeType_);
63 QuantLib::ext::shared_ptr<FxForwardEngineBuilderBase> fxBuilder =
64 QuantLib::ext::dynamic_pointer_cast<FxForwardEngineBuilderBase>(builder);
65 instNear_->setPricingEngine(fxBuilder->engine(nearSoldCcy, nearBoughtCcy));
69 instFar_->setPricingEngine(fxBuilder->engine(nearSoldCcy, nearBoughtCcy));
74 QuantLib::ext::shared_ptr<CompositeInstrument> composite(
new CompositeInstrument());
79 }
catch (std::exception&) {
122 return instFar_->result<Real>(
"currentNotional");
123 }
catch (
const std::exception& e) {
124 if (strcmp(e.what(),
"currentNotional not provided"))
125 ALOG(
"error when retrieving notional: " << e.what());
134 return instFar_->result<std::string>(
"notionalCurrency");
135 }
catch (
const std::exception& e) {
136 if (strcmp(e.what(),
"notionalCurrency not provided"))
137 ALOG(
"error when retrieving notional ccy: " << e.what());
Engine builder for FX Forwards.
const string & nearDate() const
std::string notionalCurrency() const override
QuantLib::ext::shared_ptr< QuantLib::Instrument > instFar_
string nearBoughtCurrency_
QuantLib::ext::shared_ptr< QuantLib::Instrument > instNear_
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const string & farDate() const
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
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
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 XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
FX Swap data model and serialization.
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 DLOG(text)
Logging Macro (Level = Debug)
#define ALOG(text)
Logging Macro (Level = Alert)
Serializable Credit Default Swap.