Signature Description Parameters
#include <DataFrame/DataFrameFinancialVisitors.h>

template<typename T, typename I = unsigned long>
struct DecayVisitor;
        
This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_act_visit() interface.

This visitor calculates technical analysis indicator -- decay. It requires 1 input column.
The result is a vector of values with same number of items as the given column.
Decay is a simple function used to propagate signals from the past into the future. It is useful in conjunction with algorithm trading and machine learning functions.
    explicit
    DecayVisitor(size_t period = 5, bool exponential = false)

    period: Number of decay periods
    exponential: If true it decays exponentially, otherwise linearly
        
T: Column data type
I: Index type
static void test_DecayVisitor()  {

    std::cout << "\nTesting DecayVisitor{  } ..." << std::endl;

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

    try  {
        df.read("data/SHORT_IBM.csv", io_format::csv2);

        DecayVisitor<double, std::string>  decay(5, true);

        df.single_act_visit<double>("IBM_Close", decay);

        assert(decay.get_result().size() == 1721);
        assert(std::abs(decay.get_result()[0] - 185.53) < 0.01);
        assert(std::abs(decay.get_result()[27] - 179.7) < 0.01);
        assert(std::abs(decay.get_result()[28] - 180.24) < 0.01);
        assert(std::abs(decay.get_result()[30] - 183.69) < 0.01);
        assert(std::abs(decay.get_result()[35] - 183.45) < 0.01);
        assert(std::abs(decay.get_result()[1720] - 111.66) < 0.01);
        assert(std::abs(decay.get_result()[1712] - 125.513) < 0.01);
        assert(std::abs(decay.get_result()[1707] - 127.203) < 0.01);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}