QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
commodity.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 J. Erik Radmall
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file commodity.hpp
21 \brief Commodity base class
22*/
23
24#ifndef quantlib_commodity_hpp
25#define quantlib_commodity_hpp
26
27#include <ql/any.hpp>
28#include <ql/instrument.hpp>
29#include <ql/money.hpp>
30#include <iosfwd>
31#include <utility>
32#include <vector>
33
34namespace QuantLib {
35
36 typedef std::map<std::string, ext::any> SecondaryCosts;
37 typedef std::map<std::string, Money> SecondaryCostAmounts;
38
39 std::ostream& operator<<(std::ostream& out,
40 const SecondaryCostAmounts& secondaryCostAmounts);
41
42
43 struct PricingError {
45
47 std::string tradeId;
48 std::string error;
49 std::string detail;
50
51 PricingError(Level errorLevel, std::string error, std::string detail)
52 : errorLevel(errorLevel), error(std::move(error)), detail(std::move(detail)) {}
53 };
54
55 typedef std::vector<PricingError> PricingErrors;
56
57 std::ostream& operator<<(std::ostream& out, const PricingError& error);
58 std::ostream& operator<<(std::ostream& out, const PricingErrors& errors);
59
60
61 //! Commodity base class
62 /*! \ingroup instruments */
63 class Commodity : public Instrument {
64 public:
65 explicit Commodity(ext::shared_ptr<SecondaryCosts> secondaryCosts);
66 const ext::shared_ptr<SecondaryCosts>& secondaryCosts() const;
68 const PricingErrors& pricingErrors() const;
70 const std::string& error,
71 const std::string& detail = "") const;
72 protected:
73 ext::shared_ptr<SecondaryCosts> secondaryCosts_;
76 };
77
78}
79
80#endif
Maps any to either the boost or std implementation.
Commodity base class.
Definition: commodity.hpp:63
const PricingErrors & pricingErrors() const
Definition: commodity.cpp:33
const SecondaryCostAmounts & secondaryCostAmounts() const
Definition: commodity.cpp:29
const ext::shared_ptr< SecondaryCosts > & secondaryCosts() const
void addPricingError(PricingError::Level errorLevel, const std::string &error, const std::string &detail="") const
Definition: commodity.cpp:37
ext::shared_ptr< SecondaryCosts > secondaryCosts_
Definition: commodity.hpp:73
SecondaryCostAmounts secondaryCostAmounts_
Definition: commodity.hpp:75
PricingErrors pricingErrors_
Definition: commodity.hpp:74
Abstract instrument class.
Definition: instrument.hpp:44
Abstract instrument class.
cash amount in a given currency
Definition: any.hpp:35
std::map< std::string, ext::any > SecondaryCosts
Definition: commodity.hpp:36
std::vector< PricingError > PricingErrors
Definition: commodity.hpp:55
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
std::map< std::string, Money > SecondaryCostAmounts
Definition: commodity.hpp:37
STL namespace.
PricingError(Level errorLevel, std::string error, std::string detail)
Definition: commodity.hpp:51