Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxswap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file portfolio/fxswap.hpp
20 \brief FX Swap data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
27
28namespace ore {
29namespace data {
30using std::string;
31
32//! Serializable FX Swap
33/*!
34 \ingroup tradedata
35*/
36class FxSwap : public Trade {
37public:
38 //! Default constructor
40 : Trade("FxSwap"), nearBoughtAmount_(0.0), nearSoldAmount_(0.0), farBoughtAmount_(0.0), farSoldAmount_(0.0) {}
41 //! Constructor
42 FxSwap(const Envelope& env, const string& nearDate, const string& farDate, const string& nearBoughtCurrency,
43 double nearBoughtAmount, const string& nearSoldCurrency, double nearSoldAmount, double farBoughtAmount,
44 double farSoldAmount, const string& settlement = "Physical")
48 /*! Constructs a composite pricing engine of two FX forward pricing engines.
49 One with the near amounts as notionals, the other with the far amounts.
50 NPV is the total npv of these trades.
51 */
52
53 //! Build QuantLib/QuantExt instrument, link pricing engine
54 void build(const QuantLib::ext::shared_ptr<EngineFactory>&) override;
55 QuantLib::Real notional() const override;
56 std::string notionalCurrency() const override;
57
58 //! \name Inspectors
59 //@{
60 const string& nearDate() const { return nearDate_; }
61 const string& farDate() const { return farDate_; }
62 const string& nearBoughtCurrency() const { return nearBoughtCurrency_; }
63 double nearBoughtAmount() const { return nearBoughtAmount_; }
64 const string& nearSoldCurrency() const { return nearSoldCurrency_; }
65 double nearSoldAmount() const { return nearSoldAmount_; }
66 double farBoughtAmount() const { return farBoughtAmount_; }
67 double farSoldAmount() const { return farSoldAmount_; }
68 //! Settlement Type can be set to "Cash" for NDF. Default value is "Physical"
69 const string& settlement() const { return settlement_; }
70 //@}
71
72 //! \name Serialisation
73 //@{
74 virtual void fromXML(XMLNode* node) override;
75 virtual XMLNode* toXML(XMLDocument& doc) const override;
76 //@}
77private:
78 string nearDate_;
79 string farDate_;
80 string nearBoughtCurrency_; // farBoughtCurrency==nearSoldCurrency
87 QuantLib::ext::shared_ptr<QuantLib::Instrument> instNear_, instFar_;
88};
89} // namespace data
90} // namespace ore
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable FX Swap.
Definition: fxswap.hpp:36
const string & nearDate() const
Definition: fxswap.hpp:60
double farBoughtAmount_
Definition: fxswap.hpp:84
std::string notionalCurrency() const override
Definition: fxswap.cpp:131
string settlement_
Definition: fxswap.hpp:86
double farSoldAmount_
Definition: fxswap.hpp:85
string nearDate_
Definition: fxswap.hpp:78
double nearBoughtAmount_
Definition: fxswap.hpp:81
QuantLib::ext::shared_ptr< QuantLib::Instrument > instFar_
Definition: fxswap.hpp:87
string nearSoldCurrency_
Definition: fxswap.hpp:82
string nearBoughtCurrency_
Definition: fxswap.hpp:80
QuantLib::ext::shared_ptr< QuantLib::Instrument > instNear_
Definition: fxswap.hpp:87
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
Definition: fxswap.cpp:119
const string & settlement() const
Settlement Type can be set to "Cash" for NDF. Default value is "Physical".
Definition: fxswap.hpp:69
virtual void fromXML(XMLNode *node) override
Definition: fxswap.cpp:143
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: fxswap.cpp:159
double nearBoughtAmount() const
Definition: fxswap.hpp:63
double nearSoldAmount() const
Definition: fxswap.hpp:65
const string & nearBoughtCurrency() const
Definition: fxswap.hpp:62
FxSwap(const Envelope &env, const string &nearDate, const string &farDate, const string &nearBoughtCurrency, double nearBoughtAmount, const string &nearSoldCurrency, double nearSoldAmount, double farBoughtAmount, double farSoldAmount, const string &settlement="Physical")
Constructor.
Definition: fxswap.hpp:42
string farDate_
Definition: fxswap.hpp:79
double farBoughtAmount() const
Definition: fxswap.hpp:66
double farSoldAmount() const
Definition: fxswap.hpp:67
FxSwap()
Default constructor.
Definition: fxswap.hpp:39
double nearSoldAmount_
Definition: fxswap.hpp:83
const string & farDate() const
Definition: fxswap.hpp:61
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
Definition: fxswap.cpp:34
const string & nearSoldCurrency() const
Definition: fxswap.hpp:64
Trade base class.
Definition: trade.hpp:55
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
base trade data model and serialization