33 if (ask !=
Null<Real>() && ask > 0.0)
return ((bid+ask)/2.0);
36 if (ask !=
Null<Real>() && ask > 0.0)
return ask;
37 else if (last !=
Null<Real>() && last > 0.0)
return last;
40 "all input prices are invalid");
62 : open_(open), close_(
close), high_(high), low_(low) {}
105 const std::vector<Date>&
d,
106 const std::vector<Real>& open,
107 const std::vector<Real>&
close,
108 const std::vector<Real>& high,
109 const std::vector<Real>& low) {
110 Size dsize =
d.size();
112 high.size() == dsize &&
low.size() == dsize),
113 "size mismatch (" << dsize <<
", "
114 <<
open.size() <<
", "
115 <<
close.size() <<
", "
116 <<
high.size() <<
", "
117 <<
low.size() <<
")");
119 std::vector<Date>::const_iterator i;
120 std::vector<Real>::const_iterator openi, closei, highi, lowi;
121 openi =
open.begin();
122 closei =
close.begin();
123 highi =
high.begin();
125 for (i =
d.begin(); i !=
d.end(); ++i) {
127 ++openi; ++closei; ++highi; ++lowi;
135 std::vector<Real> returnval;
136 returnval.reserve(ts.
size());
137 for (
const auto& i : ts) {
138 returnval.push_back(i.second.value(
t));
146 std::vector<Date> dates = ts.
dates();
static TimeSeries< Real > extractComponent(const TimeSeries< IntervalPrice > &, IntervalPrice::Type)
void setValue(Real value, IntervalPrice::Type)
static std::vector< Real > extractValues(const TimeSeries< IntervalPrice > &, IntervalPrice::Type)
void setValues(Real open, Real close, Real high, Real low)
Real value(IntervalPrice::Type) const
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)
template class providing a null value for a given type.
Container for historical data.
std::vector< Date > dates() const
returns the dates for which historical data exist
Size size() const
returns the number of historical data including null ones
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container
Real midSafe(const Real bid, const Real ask)
Real midEquivalent(const Real bid, const Real ask, const Real last, const Real close)
bool close(const Quantity &m1, const Quantity &m2, Size n)