QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
TimeSeries< T, Container > Class Template Reference

Container for historical data. More...

#include <ql/timeseries.hpp>

+ Inheritance diagram for TimeSeries< T, Container >:
+ Collaboration diagram for TimeSeries< T, Container >:

Classes

struct  reverse
 
struct  reverse< container, std::bidirectional_iterator_tag >
 

Public Types

typedef Date key_type
 
typedef T value_type
 

Public Member Functions

 TimeSeries ()=default
 
template<class DateIterator , class ValueIterator >
 TimeSeries (DateIterator dBegin, DateIterator dEnd, ValueIterator vBegin)
 
template<class ValueIterator >
 TimeSeries (const Date &firstDate, ValueIterator begin, ValueIterator end)
 
Inspectors
Date firstDate () const
 returns the first date for which a historical datum exists More...
 
Date lastDate () const
 returns the last date for which a historical datum exists More...
 
Size size () const
 returns the number of historical data including null ones More...
 
bool empty () const
 returns whether the series contains any data More...
 
Historical data access
operator[] (const Date &d) const
 returns the (possibly null) datum corresponding to the given date More...
 
T & operator[] (const Date &d)
 

Private Attributes

Container values_
 

Iterators

typedef Container::const_iterator const_iterator
 
typedef const_iterator::iterator_category iterator_category
 
typedef std::conditional_t< std::is_same< iterator_category, std::bidirectional_iterator_tag >::value||std::is_base_of< std::bidirectional_iterator_tag, iterator_category >::value, std::bidirectional_iterator_tag, std::input_iterator_tag > enable_reverse
 
typedef reverse< Container, enable_reverse >::const_reverse_iterator const_reverse_iterator
 
typedef Container::value_type container_value_type
 
typedef ext::function< Date(const container_value_type &)> projection_time
 
typedef ext::function< T(const container_value_type &)> projection_value
 
const_iterator cbegin () const
 
const_iterator cend () const
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 

Projection iterators

typedef boost::transform_iterator< projection_time, const_iteratorconst_time_iterator
 
typedef boost::transform_iterator< projection_value, const_iteratorconst_value_iterator
 
typedef boost::transform_iterator< projection_time, const_reverse_iteratorconst_reverse_time_iterator
 
typedef boost::transform_iterator< projection_value, const_reverse_iteratorconst_reverse_value_iterator
 
QL_DEPRECATED_DISABLE_WARNING const_value_iterator cbegin_values () const
 
const_value_iterator cend_values () const
 
const_reverse_value_iterator crbegin_values () const
 
const_reverse_value_iterator crend_values () const
 
const_time_iterator cbegin_time () const
 
const_time_iterator cend_time () const
 
const_reverse_time_iterator crbegin_time () const
 
const_reverse_time_iterator crend_time () const
 

Utilities

const_iterator find (const Date &)
 
std::vector< Datedates () const
 returns the dates for which historical data exist More...
 
std::vector< T > values () const
 returns the historical data More...
 
static const Dateget_time (const container_value_type &v)
 
static const T & get_value (const container_value_type &v)
 

Detailed Description

template<class T, class Container = std::map<Date, T>>
class QuantLib::TimeSeries< T, Container >

Container for historical data.

This class acts as a generic repository for a set of historical data. Any single datum can be accessed through its date, while sets of consecutive data can be accessed through iterators.

Precondition
The Container type must satisfy the requirements set by the C++ standard for associative containers.

Definition at line 51 of file timeseries.hpp.

Member Typedef Documentation

◆ key_type

typedef Date key_type

Definition at line 53 of file timeseries.hpp.

◆ value_type

typedef T value_type

Definition at line 54 of file timeseries.hpp.

◆ const_iterator

typedef Container::const_iterator const_iterator

Definition at line 110 of file timeseries.hpp.

◆ iterator_category

typedef const_iterator::iterator_category iterator_category

Definition at line 111 of file timeseries.hpp.

◆ enable_reverse

typedef std::conditional_t< std::is_same<iterator_category, std::bidirectional_iterator_tag>::value || std::is_base_of<std::bidirectional_iterator_tag, iterator_category>::value, std::bidirectional_iterator_tag, std::input_iterator_tag> enable_reverse

Definition at line 150 of file timeseries.hpp.

◆ const_reverse_iterator

typedef reverse<Container,enable_reverse>::const_reverse_iterator const_reverse_iterator

Definition at line 154 of file timeseries.hpp.

◆ container_value_type

typedef Container::value_type container_value_type
private

Definition at line 171 of file timeseries.hpp.

◆ projection_time

typedef ext::function<Date(const container_value_type&)> projection_time
private

Definition at line 173 of file timeseries.hpp.

◆ projection_value

typedef ext::function<T(const container_value_type&)> projection_value
private

Definition at line 175 of file timeseries.hpp.

◆ const_time_iterator

typedef boost::transform_iterator<projection_time, const_iterator> const_time_iterator
Deprecated:
Use const_iterator instead and access the first data member. Deprecated in version 1.31.

Definition at line 185 of file timeseries.hpp.

◆ const_value_iterator

typedef boost::transform_iterator<projection_value, const_iterator> const_value_iterator
Deprecated:
Use const_iterator instead and access the second data member. Deprecated in version 1.31.

Definition at line 191 of file timeseries.hpp.

◆ const_reverse_time_iterator

Deprecated:
Use const_reverse_iterator instead and access the first data member. Deprecated in version 1.31.

Definition at line 197 of file timeseries.hpp.

◆ const_reverse_value_iterator

Deprecated:
Use const_reverse_iterator instead and access the second data member. Deprecated in version 1.31.

Definition at line 203 of file timeseries.hpp.

Constructor & Destructor Documentation

◆ TimeSeries() [1/3]

TimeSeries ( )
default

Default constructor

◆ TimeSeries() [2/3]

TimeSeries ( DateIterator  dBegin,
DateIterator  dEnd,
ValueIterator  vBegin 
)

This constructor initializes the history with a set of values passed as two sequences, the first containing dates and the second containing corresponding values.

Definition at line 65 of file timeseries.hpp.

◆ TimeSeries() [3/3]

TimeSeries ( const Date firstDate,
ValueIterator  begin,
ValueIterator  end 
)

This constructor initializes the history with a set of values. Such values are assigned to a corresponding number of consecutive dates starting from firstDate included.

Definition at line 76 of file timeseries.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ firstDate()

Date firstDate

returns the first date for which a historical datum exists

Definition at line 295 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ lastDate()

Date lastDate

returns the last date for which a historical datum exists

Definition at line 301 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ size()

Size size

returns the number of historical data including null ones

Definition at line 307 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ empty()

bool empty

returns whether the series contains any data

Definition at line 312 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ operator[]() [1/2]

T operator[] ( const Date d) const

returns the (possibly null) datum corresponding to the given date

Definition at line 96 of file timeseries.hpp.

◆ operator[]() [2/2]

T & operator[] ( const Date d)

Definition at line 102 of file timeseries.hpp.

◆ cbegin()

Definition at line 318 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ cend()

Definition at line 324 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ begin()

const_iterator begin ( ) const

Definition at line 158 of file timeseries.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end()

const_iterator end ( ) const

Definition at line 159 of file timeseries.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crbegin()

const_reverse_iterator crbegin ( ) const

Definition at line 160 of file timeseries.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crend()

const_reverse_iterator crend ( ) const

Definition at line 163 of file timeseries.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rbegin()

const_reverse_iterator rbegin ( ) const

Definition at line 166 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ rend()

const_reverse_iterator rend ( ) const

Definition at line 167 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ cbegin_values()

QL_DEPRECATED_DISABLE_WARNING const_value_iterator cbegin_values ( ) const
Deprecated:
Use cbegin instead and access the second data member. Deprecated in version 1.31.

Definition at line 211 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ cend_values()

const_value_iterator cend_values ( ) const
Deprecated:
Use cend instead and access the second data member. Deprecated in version 1.31.

Definition at line 219 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ crbegin_values()

const_reverse_value_iterator crbegin_values ( ) const
Deprecated:
Use crbegin instead and access the second data member. Deprecated in version 1.31.

Definition at line 227 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ crend_values()

const_reverse_value_iterator crend_values ( ) const
Deprecated:
Use crend instead and access the second data member. Deprecated in version 1.31.

Definition at line 235 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ cbegin_time()

const_time_iterator cbegin_time ( ) const
Deprecated:
Use cbegin instead and access the first data member. Deprecated in version 1.31.

Definition at line 243 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ cend_time()

const_time_iterator cend_time ( ) const
Deprecated:
Use cend instead and access the first data member. Deprecated in version 1.31.

Definition at line 251 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ crbegin_time()

const_reverse_time_iterator crbegin_time ( ) const
Deprecated:
Use crbegin instead and access the first data member. Deprecated in version 1.31.

Definition at line 259 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ crend_time()

const_reverse_time_iterator crend_time ( ) const
Deprecated:
Use crend instead and access the first data member. Deprecated in version 1.31.

Definition at line 267 of file timeseries.hpp.

+ Here is the call graph for this function:

◆ find()

TimeSeries< T, C >::const_iterator find ( const Date d)

Definition at line 330 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ dates()

std::vector< Date > dates

returns the dates for which historical data exist

Definition at line 340 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ values()

std::vector< T > values

returns the historical data

Definition at line 349 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ get_time()

static const Date & get_time ( const container_value_type v)
staticprivate

Definition at line 283 of file timeseries.hpp.

+ Here is the caller graph for this function:

◆ get_value()

static const T & get_value ( const container_value_type v)
staticprivate

Definition at line 286 of file timeseries.hpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ values_

Container values_
mutableprivate

Definition at line 56 of file timeseries.hpp.