Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
tradestrike.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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#pragma once
20
21
23#include <ql/interestrate.hpp>
24#include <ql/tuple.hpp>
25#include <boost/variant.hpp>
26
27namespace ore {
28namespace data {
29
31public:
32 enum class Type {
33 Price,
34 Yield
35 };
36
38 struct StrikeYield {
40 : yield(QuantLib::Null<QuantLib::Real>()), compounding(QuantLib::Compounding::SimpleThenCompounded) {}
41 StrikeYield(const QuantLib::Real& value, QuantLib::Compounding compounding = QuantLib::Compounding::SimpleThenCompounded)
43 QuantLib::Rate yield;
44 QuantLib::Compounding compounding;
45 };
46
48 TradeStrike(Type type, const QuantLib::Real& value);
49 TradeStrike(const QuantLib::Real& value, const std::string& currency);
50 TradeStrike(const QuantLib::Real& value, QuantLib::Compounding compounding);
51
52 QuantLib::Real value() const;
53 Type type() const { return type_; };
54 std::string currency();
55 const QuantLib::Compounding& compounding();
56
57 StrikePrice& strikePrice() const { return boost::get<StrikePrice>(strike_); }
58 StrikeYield& strikeYield() const { return boost::get<StrikeYield>(strike_); }
59
60 void setValue(const QuantLib::Real& value);
61 void setCurrency(const std::string& currency);
62
63 void fromXML(XMLNode* node, const bool isRequired = true, const bool allowYieldStrike = false);
64 XMLNode* toXML(XMLDocument& doc) const;
65
66 const bool empty() const;
67
68private:
69 mutable boost::variant<StrikeYield, StrikePrice> strike_;
71 bool onlyStrike_ = false;
72 bool noStrikePriceNode_ = false;
73
74};
75
76} // namespace data
77} // namespace ore
const QuantLib::Compounding & compounding()
boost::variant< StrikeYield, StrikePrice > strike_
Definition: tradestrike.hpp:69
XMLNode * toXML(XMLDocument &doc) const
Definition: tradestrike.cpp:86
void setCurrency(const std::string &currency)
void fromXML(XMLNode *node, const bool isRequired=true, const bool allowYieldStrike=false)
Definition: tradestrike.cpp:50
std::string currency()
const bool empty() const
StrikeYield & strikeYield() const
Definition: tradestrike.hpp:58
QuantLib::Real value() const
void setValue(const QuantLib::Real &value)
TradeMonetary StrikePrice
Definition: tradestrike.hpp:37
StrikePrice & strikePrice() const
Definition: tradestrike.hpp:57
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
StrikeYield(const QuantLib::Real &value, QuantLib::Compounding compounding=QuantLib::Compounding::SimpleThenCompounded)
Definition: tradestrike.hpp:41
QuantLib::Compounding compounding
Definition: tradestrike.hpp:44