CBOE Emulator
1.0
|
A structure for calculating the Rate of Change (ROC) over a rolling window. More...
#include <rate_of_change.hpp>
Public Member Functions | |
RateOfChange (std::size_t length) | |
Initialize a new RoC with given history length \(n\). More... | |
std::size_t | get_length () const |
Return the length of the rate of change history. More... | |
RoC | get_rate_of_change () const |
Return the current rate of change (RoC). More... | |
void | reset () |
Reset the history to its initial state. | |
void | process (Observation observation) |
Calculate the next RoC based on observation \(o_t\). More... | |
Static Public Attributes | |
static constexpr std::size_t | LENGTH_MIN = 2 |
the inclusive minimal size for the length of the history | |
static constexpr std::size_t | LENGTH_MAX = std::numeric_limits<uint16_t>::max() - 1 |
the inclusive maximal size for the length of the history | |
A structure for calculating the Rate of Change (ROC) over a rolling window.
Observation | the type for the observations |
RoC | the type for the rate of change to be calculated in |
The Rate of Change (ROC), i.e., momentum, is a technical analysis indicator measuring the difference between values in a time series window. A moving window of values, i.e., history vector \(\boldsymbol{h}^n\), stores of the last \(n\) observations. An indexing variable \(i\) determines the head of the circular moving window. For a new observation \(o_t\) at time \(t\), the history vector is updated with the observation \(\boldsymbol{h_i} \gets o_t\). The RoC is calculated from the current observation \(\boldsymbol{h}_i\) and the oldest observation \(\boldsymbol{h}_{(i + 1) \bmod n}\) as:
\[ r_t = \frac{\boldsymbol{h}_i - \boldsymbol{h}_{(i + 1) \bmod n}}{\boldsymbol{h}_{(i + 1) \bmod n}}\]
The index is updated as \(i \gets (i + 1) \bmod n\).
|
inlineexplicit |
Initialize a new RoC with given history length \(n\).
length | the length of the history window \(n\) |
|
inline |
Return the length of the rate of change history.
|
inline |
Return the current rate of change (RoC).
|
inline |
Calculate the next RoC based on observation \(o_t\).
observation | the observation \(o_t\) to integrate into the RoC |