22#include <ql/utilities/null.hpp>
37 const string& calculationCurrency,
const bool overwrite) {
38 if (!(mt == SimmConfiguration::MarginType::AdditionalIM || mt == SimmConfiguration::MarginType::All))
39 QL_REQUIRE(im >= 0.0,
"Cannot add negative IM " << im <<
" result to SimmResults for RiskClass=" << rc
40 <<
", MarginType=" << mt <<
", and Bucket=" << b);
42 const auto key = make_tuple(pc, rc, mt, b);
48 const std::string& calculationCurrency,
const bool overwrite) {
55 "Cannot add value to SimmResults with a different result currency ("
62 "Cannot add value to SimmResults in a different calculation currency ("
65 const bool hasResults =
data_.find(key) !=
data_.end();
66 if (hasResults && !overwrite)
73void SimmResults::convert(
const QuantLib::ext::shared_ptr<ore::data::Market>& market,
const string& currency) {
75 Real fxSpot = market->fxRate(
resultCcy_ + currency)->value();
83 << currency <<
") must be a valid ISO currency code");
90 for (
auto& sr :
data_)
99 if (
has(pc, rc, mt, b)) {
100 return data_.at(make_tuple(pc, rc, mt, b));
108 return data_.count(make_tuple(pc, rc, mt, b)) > 0;
116 return out <<
"[" << get<0>(k) <<
", " << get<1>(k) <<
", " << get<2>(k) <<
", " << get<3>(k) <<
"]";
std::string & calculationCurrency()
bool empty() const
Return true if the container is empty, otherwise false.
void add(const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string &b, QuantLib::Real im, const std::string &resultCurrency, const std::string &calculationCurrency, const bool overwrite)
std::tuple< ProductClass, RiskClass, MarginType, std::string > Key
bool has(const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string b) const
void convert(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const std::string ¤cy)
Convert SIMM amounts to a different currency.
QuantLib::Real get(const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string b) const
void clear()
Clear the results from the container.
std::string & resultCurrency()
std::map< Key, QuantLib::Real > data_
bool checkCurrency(const string &code)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
Class for holding SIMM results.