QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
prices.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2006 Katiuscia Manzoni
6 Copyright (C) 2006 Joseph Wang
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_prices_hpp
27#define quantlib_prices_hpp
28
29#include <ql/timeseries.hpp>
30#include <ql/utilities/null.hpp>
31
32namespace QuantLib {
33
35 enum PriceType {
40 Mid,
47 MidSafe
49 };
50
54 Real midEquivalent(Real bid, Real ask, Real last, Real close);
55
59 Real midSafe(Real bid, Real ask);
60
63 public:
64 enum Type { Open, Close, High, Low };
65
68
70
71 Real open() const { return open_; }
72 Real close() const { return close_; }
73 Real high() const { return high_; }
74 Real low() const { return low_; }
77
79
83
85
87 const std::vector<Date>& d,
88 const std::vector<Real>& open,
89 const std::vector<Real>& close,
90 const std::vector<Real>& high,
91 const std::vector<Real>& low);
92 static std::vector<Real> extractValues(
99 private:
101 };
102
103 #ifdef QL_NULL_AS_FUNCTIONS
104
105 template <>
107 return {};
108 };
109
110 #else
111
112 template <>
114 {
115 public:
116 Null() = default;
117 operator IntervalPrice() const { return {}; }
118 };
119
120 #endif
121
122}
123
124#endif
interval price
Definition: prices.hpp:62
void setValue(Real value, IntervalPrice::Type)
Definition: prices.cpp:79
static TimeSeries< Real > extractComponent(const TimeSeries< IntervalPrice > &, enum IntervalPrice::Type)
Definition: prices.cpp:143
Real low() const
Definition: prices.hpp:74
static std::vector< Real > extractValues(const TimeSeries< IntervalPrice > &, IntervalPrice::Type)
Definition: prices.cpp:132
Real open() const
Definition: prices.hpp:71
Real close() const
Definition: prices.hpp:72
Real high() const
Definition: prices.hpp:73
void setValues(Real open, Real close, Real high, Real low)
Definition: prices.cpp:99
Real value(IntervalPrice::Type) const
Definition: prices.cpp:64
static TimeSeries< IntervalPrice > makeSeries(const std::vector< Date > &d, const std::vector< Real > &open, const std::vector< Real > &close, const std::vector< Real > &high, const std::vector< Real > &low)
Definition: prices.cpp:104
template class providing a null value for a given type.
Definition: null.hpp:76
Container for historical data.
Definition: timeseries.hpp:51
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
PriceType
Price types.
Definition: prices.hpp:35
@ MidSafe
Definition: prices.hpp:47
@ MidEquivalent
Definition: prices.hpp:42
@ Close
Definition: prices.hpp:39
@ Last
Definition: prices.hpp:38
Real midSafe(const Real bid, const Real ask)
Definition: prices.cpp:46
Real midEquivalent(const Real bid, const Real ask, const Real last, const Real close)
Definition: prices.cpp:27
bool close(const Quantity &m1, const Quantity &m2, Size n)
Definition: quantity.cpp:163