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

template<typename T, typename I = unsigned long>
struct KamaVisitor;
        
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.

Developed by Perry Kaufman, Kaufman's Adaptive Moving Average (KAMA) is a moving average designed to account for market noise or volatility. KAMA will closely follow prices when the price swings are relatively small and the noise is low. KAMA will adjust when the price swings widen and follow prices from a greater distance. This trend-following indicator can be used to identify the overall trend, time turning points and filter price movements.
The result is a vector of values with same number of items as the given column. The first roll_count items, in the result, will be NAN.
    KamaVisitor(std::size_t roll_count = 10,
                std::size_t fast_smoothing_const = 2,
                std::size_t slow_smoothing_const = 30);
        
T: Column data type
I: Index type
static void test_KamaVisitor()  {

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

    typedef StdDataFrame<std::string> StrDataFrame;

    StrDataFrame    df;

    try  {
        df.read("IBM.csv", io_format::csv2);

        KamaVisitor<double, std::string>    k_v;

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

        assert(k_v.get_result().size() == 5031);
        assert(std::isnan(k_v.get_result()[0]));
        assert(std::isnan(k_v.get_result()[8]));
        assert(k_v.get_result()[9] == 0);
        assert(std::abs(k_v.get_result()[29] - 31.6281) < 0.0001);
        assert(std::abs(k_v.get_result()[34] - 47.2049) < 0.0001);
        assert(std::abs(k_v.get_result()[5030] - 112.438) < 0.001);
        assert(std::abs(k_v.get_result()[5026] - 118.829) < 0.001);
        assert(std::abs(k_v.get_result()[5021] - 125.937) < 0.001);
    }
    catch (const DataFrameError &ex)  {
        std::cout << ex.what() << std::endl;
    }
}