QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Related Functions | List of all members
Period Class Reference

#include <period.hpp>

+ Collaboration diagram for Period:

Public Member Functions

 Period ()=default
 
 Period (Integer n, TimeUnit units)
 
 Period (Frequency f)
 
Integer length () const
 
TimeUnit units () const
 
Frequency frequency () const
 
Periodoperator+= (const Period &)
 
Periodoperator-= (const Period &)
 
Periodoperator*= (Integer)
 
Periodoperator/= (Integer)
 
void normalize ()
 
Period normalized () const
 

Private Attributes

Integer length_ = 0
 
TimeUnit units_ = Days
 

Related Functions

(Note that these are not member functions.)

Real years (const Period &)
 
Real months (const Period &)
 
Real weeks (const Period &)
 
Real days (const Period &)
 
template<typename T >
Period operator* (T n, TimeUnit units)
 
template<typename T >
Period operator* (TimeUnit units, T n)
 
Period operator- (const Period &)
 
Period operator* (Integer n, const Period &)
 
Period operator* (const Period &, Integer n)
 
Period operator/ (const Period &, Integer n)
 
Period operator+ (const Period &, const Period &)
 
Period operator- (const Period &, const Period &)
 
bool operator< (const Period &, const Period &)
 
bool operator== (const Period &, const Period &)
 
bool operator!= (const Period &, const Period &)
 
bool operator> (const Period &, const Period &)
 
bool operator<= (const Period &, const Period &)
 
bool operator>= (const Period &, const Period &)
 
std::ostream & operator<< (std::ostream &, const Period &)
 

Detailed Description

This class provides a Period (length + TimeUnit) class and implements a limited algebra.

Tests:
self-consistency of algebra is checked.
Examples
BasketLosses.cpp, BermudanSwaption.cpp, Bonds.cpp, CDS.cpp, CVAIRS.cpp, CallableBonds.cpp, ConvertibleBonds.cpp, FittedBondCurve.cpp, LatentModel.cpp, MulticurveBootstrapping.cpp, and Repo.cpp.

Definition at line 44 of file period.hpp.

Constructor & Destructor Documentation

◆ Period() [1/3]

Period ( )
default

◆ Period() [2/3]

Period ( Integer  n,
TimeUnit  units 
)

Definition at line 47 of file period.hpp.

◆ Period() [3/3]

Period ( Frequency  f)
explicit

Definition at line 29 of file period.cpp.

Member Function Documentation

◆ length()

Integer length ( ) const

Definition at line 50 of file period.hpp.

+ Here is the caller graph for this function:

◆ units()

TimeUnit units ( ) const

Definition at line 51 of file period.hpp.

+ Here is the caller graph for this function:

◆ frequency()

Frequency frequency ( ) const

Definition at line 69 of file period.cpp.

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

◆ operator+=()

Period & operator+= ( const Period p)

Definition at line 134 of file period.cpp.

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

◆ operator-=()

Period & operator-= ( const Period p)

Definition at line 219 of file period.cpp.

+ Here is the call graph for this function:

◆ operator*=()

Period & operator*= ( Integer  n)

Definition at line 223 of file period.cpp.

◆ operator/=()

Period & operator/= ( Integer  n)

Definition at line 228 of file period.cpp.

+ Here is the call graph for this function:

◆ normalize()

void normalize ( )

Definition at line 108 of file period.cpp.

+ Here is the caller graph for this function:

◆ normalized()

Period normalized ( ) const

Definition at line 140 of file period.hpp.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ years()

Real years ( const Period )
related

Definition at line 279 of file period.cpp.

+ Here is the call graph for this function:

◆ months()

Real months ( const Period )
related

Definition at line 296 of file period.cpp.

+ Here is the call graph for this function:

◆ weeks()

Real weeks ( const Period )
related

Definition at line 313 of file period.cpp.

+ Here is the call graph for this function:

◆ days()

Real days ( const Period )
related

Definition at line 330 of file period.cpp.

+ Here is the call graph for this function:

◆ operator*() [1/4]

Period operator* ( T  n,
TimeUnit  units 
)
related

Definition at line 147 of file period.hpp.

◆ operator*() [2/4]

Period operator* ( TimeUnit  units,
T  n 
)
related

Definition at line 152 of file period.hpp.

◆ operator-() [1/2]

Period operator- ( const Period )
related

Definition at line 156 of file period.hpp.

+ Here is the call graph for this function:

◆ operator*() [3/4]

Period operator* ( Integer  n,
const Period  
)
related

Definition at line 158 of file period.hpp.

+ Here is the call graph for this function:

◆ operator*() [4/4]

Period operator* ( const Period ,
Integer  n 
)
related

Definition at line 160 of file period.hpp.

+ Here is the call graph for this function:

◆ operator/()

Period operator/ ( const Period ,
Integer  n 
)
related

Definition at line 390 of file period.cpp.

◆ operator+()

Period operator+ ( const Period ,
const Period  
)
related

Definition at line 380 of file period.cpp.

◆ operator-() [2/2]

Period operator- ( const Period ,
const Period  
)
related

Definition at line 386 of file period.cpp.

◆ operator<()

bool operator< ( const Period ,
const Period  
)
related

Definition at line 347 of file period.cpp.

+ Here is the call graph for this function:

◆ operator==()

bool operator== ( const Period ,
const Period  
)
related

Definition at line 162 of file period.hpp.

◆ operator!=()

bool operator!= ( const Period ,
const Period  
)
related

Definition at line 166 of file period.hpp.

◆ operator>()

bool operator> ( const Period ,
const Period  
)
related

Definition at line 170 of file period.hpp.

◆ operator<=()

bool operator<= ( const Period ,
const Period  
)
related

Definition at line 174 of file period.hpp.

◆ operator>=()

bool operator>= ( const Period ,
const Period  
)
related

Definition at line 178 of file period.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const Period  
)
related

Definition at line 398 of file period.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ length_

Integer length_ = 0
private

Definition at line 60 of file period.hpp.

◆ units_

TimeUnit units_ = Days
private

Definition at line 61 of file period.hpp.