![]() |
Trading System API
3.0
Library for Simulating and Deploying Trading and Investment Strategies
|
Represents a duration - the difference between two date_time values. More...
#include <TSATime.h>
Public Member Functions | |
duration (uint64_t num_24h_periods, uint64_t microsec_of_day) | |
Constructor. The num_24h_periods argument represents a number of 24 hour periods! The microsec_of_day argument represents the number of microseconds since midnight (less than 24 hours) to be added to a given number of 24 hour periods. More... | |
duration (double decimal_24hour_periods) | |
Initializes self from decimal number of days (24 hour periods). | |
duration (const duration &) | |
Copy constructor. | |
duration (void) | |
Constructor. Both the number of 24 hour periods and microseconds since midnight are initialized to zero. is_zero() returns true. | |
duration (const date_time &a, const date_time &b) | |
Constructor. Initializes self to the duration between date-times a and b. | |
int | get_days (void) const |
Returns the number of 24 hour periods in self. | |
int64_t | get_microseconds (void) const |
Returns the number of microseconds-since-midnight component of the duration. More... | |
bool | is_zero () const |
Returns true if the duration is zero (equivalent to the duration between two identical date_time values) More... | |
duration | operator* (double multiplier) const |
Multiplies self by multiplier. | |
void | operator+= (const duration &other) |
Adds duration other to self. | |
duration | operator/ (double num) const |
Divides self into num parts. | |
bool | operator< (const duration &rhs) |
Returns true if self is smaller than rhs. | |
bool | operator<= (const duration &rhs) |
Returns true if self is smaller or equal than rhs. | |
void | operator= (const duration &) |
Assignment operator. | |
bool | operator== (const duration &other) const |
Returns true if self is identical to other. | |
bool | operator> (const duration &rhs) |
Returns true if self is larger than rhs. | |
bool | operator>= (const duration &rhs) |
Returns true if self is larger or equal than rhs. | |
double | to_fractional_days (void) const |
Returns the duration as a decimal days (24 hour periods) value. More... | |
double | to_fractional_years (void) const |
Returns the duration as a decimal number of years where a year is 365.25 days. More... | |
Static Public Member Functions | |
static duration | days (uint64_t) |
Returns a duration equivalent to a given number of days. | |
static duration | hours (uint64_t) |
Returns a duration equivalent to a given number of hours. | |
static duration | microseconds (uint64_t) |
Returns a duration equivalent to a given number of microseconds. | |
static duration | milliseconds (uint64_t) |
Returns a duration equivalent to a given number of milliseconds. | |
static duration | minutes (uint64_t) |
Returns a duration equivalent to a given number of minutes. | |
static duration | seconds (uint64_t) |
Returns a duration equivalent to a given number of seconds. | |
Represents a duration - the difference between two date_time values.
Durations can be added or subtracted from date_time objects. The duration class was conceived for working with financial data spanning centuries but was not conceived to work with time in astronomical magnitudes (billions of years). See date_time::max and date_time::min for maximum and minimum allowed date_time values. There is no check for overflow conditions!
tsa::duration::duration | ( | uint64_t | num_24h_periods, |
uint64_t | microsec_of_day | ||
) |
Constructor. The num_24h_periods argument represents a number of 24 hour periods! The microsec_of_day argument represents the number of microseconds since midnight (less than 24 hours) to be added to a given number of 24 hour periods.
num_24h_periods | Number of 24 hour periods. |
microsec_of_day | The microseconds since midnight. |
int64_t tsa::duration::get_microseconds | ( | void | ) | const |
Returns the number of microseconds-since-midnight component of the duration.
bool tsa::duration::is_zero | ( | void | ) | const |
Returns true if the duration is zero (equivalent to the duration between two identical date_time values)
double tsa::duration::to_fractional_days | ( | void | ) | const |
Returns the duration as a decimal days (24 hour periods) value.
double tsa::duration::to_fractional_years | ( | void | ) | const |
Returns the duration as a decimal number of years where a year is 365.25 days.