Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
value.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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/scripting/value.hpp
20 \brief value type and operations
21 \ingroup utilities
22*/
23
24#pragma once
25
28
29#include <ql/time/date.hpp>
30
31#include <boost/variant.hpp>
32
33#include <ostream>
34#include <string>
35
36namespace ore {
37namespace data {
38using namespace QuantExt;
39
40struct EventVec {
41 Size size;
42 Date value;
43};
44
46 Size size;
47 std::string value;
48};
49
50struct IndexVec {
51 Size size;
52 std::string value;
53};
54
56 Size size;
57 std::string value;
58};
59
60using ValueType = boost::variant<RandomVariable, EventVec, CurrencyVec, IndexVec, DaycounterVec, Filter>;
61
62static const std::vector<std::string> valueTypeLabels = {"Number", "Event", "Currency",
63 "Index", "Daycounter", "Filter"};
64
66 enum which { Number = 0, Event = 1, Currency = 2, Index = 3, Daycounter = 4, Filter = 5 };
67};
68
69bool deterministic(const ValueType& v);
70Size size(const ValueType& v);
71
72bool operator==(const EventVec& a, const EventVec& b);
73bool operator==(const CurrencyVec& a, const CurrencyVec& b);
74bool operator==(const IndexVec& a, const IndexVec& b);
75bool operator==(const DaycounterVec& a, const DaycounterVec& b);
76std::ostream& operator<<(std::ostream& out, const EventVec& a);
77std::ostream& operator<<(std::ostream& out, const CurrencyVec& a);
78std::ostream& operator<<(std::ostream& out, const IndexVec& a);
79std::ostream& operator<<(std::ostream& out, const DaycounterVec& a);
80
81ValueType operator+(const ValueType& x, const ValueType& y);
82ValueType operator-(const ValueType& x, const ValueType& y);
83ValueType operator*(const ValueType& x, const ValueType& y);
84ValueType operator/(const ValueType& x, const ValueType& y);
85ValueType min(const ValueType& x, const ValueType& y);
86ValueType max(const ValueType& x, const ValueType& y);
87ValueType pow(const ValueType& x, const ValueType& y);
88
90ValueType abs(const ValueType& x);
91ValueType exp(const ValueType& x);
92ValueType log(const ValueType& x);
93ValueType sqrt(const ValueType& x);
96
98
99Filter equal(const ValueType& x, const ValueType& y);
100Filter notequal(const ValueType& x, const ValueType& y);
101Filter lt(const ValueType& x, const ValueType& y);
102Filter leq(const ValueType& x, const ValueType& y);
103Filter gt(const ValueType& x, const ValueType& y);
104Filter geq(const ValueType& x, const ValueType& y);
105
106Filter logicalNot(const ValueType& x);
107Filter logicalAnd(const ValueType& x, const ValueType& y);
108Filter logicalOr(const ValueType& x, const ValueType& y);
109
110} // namespace data
111} // namespace ore
@ data
Definition: log.hpp:77
RandomVariable max(RandomVariable x, const RandomVariable &y)
BucketedDistribution operator+(const BucketedDistribution &lhs, const BucketedDistribution &rhs)
RandomVariable exp(RandomVariable x)
RandomVariable sqrt(RandomVariable x)
RandomVariable log(RandomVariable x)
RandomVariable pow(RandomVariable x, const RandomVariable &y)
RandomVariable operator/(RandomVariable x, const RandomVariable &y)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
bool operator==(const Dividend &d1, const Dividend &d)
RandomVariable normalCdf(RandomVariable x)
RandomVariable abs(RandomVariable x)
RandomVariable normalPdf(RandomVariable x)
Filter equal(Filter x, const Filter &y)
RandomVariable operator-(RandomVariable x, const RandomVariable &y)
RandomVariable min(RandomVariable x, const RandomVariable &y)
BucketedDistribution operator*(Real factor, const BucketedDistribution &rhs)
Filter lt(const ValueType &x, const ValueType &y)
Definition: value.cpp:263
bool deterministic(const ValueType &v)
Definition: value.cpp:144
Filter notequal(const ValueType &x, const ValueType &y)
Definition: value.cpp:239
Filter gt(const ValueType &x, const ValueType &y)
Definition: value.cpp:282
ValueType typeSafeAssign(ValueType &x, const ValueType &y)
Definition: value.cpp:213
Filter logicalAnd(const ValueType &x, const ValueType &y)
Definition: value.cpp:352
Size size(const ValueType &v)
Definition: value.cpp:145
Filter logicalOr(const ValueType &x, const ValueType &y)
Definition: value.cpp:368
Filter leq(const ValueType &x, const ValueType &y)
Definition: value.cpp:301
Filter geq(const ValueType &x, const ValueType &y)
Definition: value.cpp:321
boost::variant< RandomVariable, EventVec, CurrencyVec, IndexVec, DaycounterVec, Filter > ValueType
Definition: value.hpp:60
Filter logicalNot(const ValueType &x)
Definition: value.cpp:341
Serializable Credit Default Swap.
Definition: namespaces.docs:23
std::string value
Definition: value.hpp:47
std::string value
Definition: value.hpp:57
std::string value
Definition: value.hpp:52