Class RealizedVarianceTenorCalculator
Defined in File realized_variance_tenor_calculator.hpp
Inheritance Relationships
Base Type
public otyca::TenorCalculator
(Class TenorCalculator)
Class Documentation
-
class RealizedVarianceTenorCalculator : public otyca::TenorCalculator
A class that calculates realized variance time for different market periods.
This class computes various time-related values such as trade hour variance, non-trade day variance, and the variance for trade days with non-trade hours. It also provides functions to calculate the year fraction between two times and allows setting customized time periods and weights.
Public Functions
-
inline RealizedVarianceTenorCalculator(double trade_hour_variance_weight, double non_trade_day_variance_weight, double trade_day_non_trade_hour_variance_weight)
Constructor for RealizedVarianceTimeCalculator with custom variance weights.
This constructor initializes the class with given weights for trade hour variance, non-trade day variance, and trade day non-trade hour variance. It also initializes the day start and finish times.
- Parameters:
trade_hour_variance_weight – The weight for trade hour variance.
non_trade_day_variance_weight – The weight for non-trade day variance.
trade_day_non_trade_hour_variance_weight – The weight for trade day non-trade hour variance.
-
inline RealizedVarianceTenorCalculator()
Default constructor for RealizedVarianceTimeCalculator.
This constructor initializes the class with default weights for the different variances.
-
inline void init()
Initializes the time-related variables.
This method calculates the seconds for various periods in the trading day and in the year, and sets up the corresponding variance weights.
-
inline virtual ~RealizedVarianceTenorCalculator()
Destructor for RealizedVarianceTimeCalculator.
-
inline double trade_day_non_trade_hour_seconds(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end) const
Calculates the non-trade hour seconds within a trade day.
This method computes the number of non-trade hour seconds within the trade day between the given
begin
andend
times.- Parameters:
begin – The start time of the period.
end – The end time of the period.
- Returns:
The number of non-trade hour seconds.
-
inline double non_trade_seconds(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end) const
Calculates the non-trade day seconds between two given times.
This method computes the number of non-trade day seconds between the given
begin
andend
times.- Parameters:
begin – The start time of the period.
end – The end time of the period.
- Returns:
The number of non-trade day seconds.
-
double trade_hour_seconds(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end) const
Calculates the trade hour seconds between two given times.
This method computes the number of trade hour seconds between the given
begin
andend
times.- Parameters:
begin – The start time of the period.
end – The end time of the period.
- Returns:
The number of trade hour seconds.
-
double non_trade_day_seconds(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end) const
Calculates the non-trade day seconds between two given times.
This method computes the number of non-trade day seconds between the given
begin
andend
times.- Parameters:
begin – The start time of the period.
end – The end time of the period.
- Returns:
The number of non-trade day seconds.
-
virtual double tenor(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end) const
Calculates the year fraction between two given times.
This method computes the fraction of a year between the
begin
andend
times provided.- Parameters:
begin – The start time.
end – The end time.
- Returns:
The year fraction between
begin
andend
.
-
inline const boost::posix_time::time_duration &get_day_finish() const
Gets the finish time of the trading day.
This method returns the finish time for the trading day.
- Returns:
A reference to the day finish time.
-
inline const boost::posix_time::time_duration &get_day_start() const
Gets the start time of the trading day.
This method returns the start time for the trading day.
- Returns:
A reference to the day start time.
-
inline void set_day_start_finish(const boost::posix_time::time_duration &day_start, const boost::posix_time::time_duration &day_finish)
Sets the start and finish times for the trading day.
This method allows setting custom start and finish times for the trading day, recalculating related time values.
- Parameters:
day_start – The new start time for the trading day.
day_finish – The new finish time for the trading day.
-
inline void set_variance_weights(double trade_hour_variance_weight, double non_trade_day_variance_weight, double trade_day_non_trade_hour_variance_weight)
Sets the variance weights.
This method sets custom variance weights for the different periods, normalizing the weights and recalculating the corresponding time values.
- Parameters:
trade_hour_variance_weight – The weight for trade hour variance.
non_trade_day_variance_weight – The weight for non-trade day variance.
trade_day_non_trade_hour_variance_weight – The weight for trade day non-trade hour variance.
-
inline RealizedVarianceTenorCalculator(double trade_hour_variance_weight, double non_trade_day_variance_weight, double trade_day_non_trade_hour_variance_weight)