Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxspotconfig.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 ored/configuration/fxspotconfig.hpp
20 \brief security spread configuration classes
21 \ingroup configuration
22*/
23
24#pragma once
25
28#include <ql/currency.hpp>
29#include <ql/types.hpp>
30
31namespace ore {
32namespace data {
34using QuantLib::Currency;
35using std::string;
36using std::vector;
37
38//! FXSpot configuration
39/*!
40 \ingroup configuration
41*/
42class FXSpotConfig : public CurveConfig {
43public:
44 //! \name Constructors/Destructors
45 //@{
46 //! Detailed constructor
48 QL_REQUIRE(curveID.size() == 6, "FXSpot curveID must be of the form Ccy1Ccy2");
49 Currency ccy1 = parseCurrency(curveID.substr(0, 3));
50 Currency ccy2 = parseCurrency(curveID.substr(3, 3));
51 quotes_.push_back("FX/RATE/" + ccy1.code() + "/" + ccy2.code());
52 };
53 //! Default constructor
55 //@}
56
57 void fromXML(XMLNode* node) override {
58 XMLUtils::checkNode(node, "FXSpot");
59 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
60 QL_REQUIRE(curveID_.size() == 6, "FXSpot curveID must be of the form Ccy1Ccy2");
61 Currency ccy1 = parseCurrency(curveID_.substr(0, 3));
62 Currency ccy2 = parseCurrency(curveID_.substr(3, 3));
63 quotes_.push_back("FX/RATE/" + ccy1.code() + "/" + ccy2.code());
64
65 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
66 }
67
68 XMLNode* toXML(XMLDocument& doc) const override {
69 XMLNode* node = doc.allocNode("FXSpot");
70 XMLUtils::addChild(doc, node, "CurveId", curveID_);
71 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
72 return node;
73 }
74};
75} // namespace data
76} // namespace ore
Base curve configuration.
Definition: curveconfig.hpp:41
vector< string > quotes_
Definition: curveconfig.hpp:74
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
FXSpot configuration.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
FXSpotConfig(const string &curveID, const string &curveDescription)
Detailed constructor.
FXSpotConfig()
Default constructor.
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
Base curve configuration classes.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.