Signature | Description | Parameters |
---|---|---|
#include <DataFrame/DataFrameFinancialVisitors.h> template<typename T, typename I = unsigned long> struct AccumDistVisitor; // ------------------------------------- template<typename T, typename I = unsigned long> using ad_v = AccumDistVisitor<T, I>; |
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 the Accumulation/Distribution (AD) indicator. It requires 5 input columns in order of low, high, open, close, volume. The result is a vector of values with same number of items as the given column. The accumulation/distribution indicator (A/D) is a cumulative indicator that uses volume and price to assess whether a stock is being accumulated or distributed. The A/D measure seeks to identify divergences between the stock price and the volume flow. This provides insight into how strong a trend is. If the price is rising but the indicator is falling, then it suggests that buying or accumulation volume may not be enough to support the price rise and a price decline could be forthcoming. |
T: Column data type I: Index type |
atic void test_AccumDistVisitor() { std::cout << "\nTesting AccumDistVisitor{ } ..." << std::endl; typedef StdDataFrame<std::string> StrDataFrame; StrDataFrame df; try { df.read("data/SHORT_IBM.csv", io_format::csv2); ad_v<double, std::string> ad; std::future<ad_v<double, std::string> &> fut = df.single_act_visit_async<double, double, double, double, long>("IBM_Low", "IBM_High", "IBM_Open", "IBM_Close", "IBM_Volume", ad); fut.get(); assert(ad.get_result().size() == 1721); assert(std::abs(ad.get_result()[0] - -3471893.994401) < 0.00001); assert(std::abs(ad.get_result()[10] - -3089366.572853) < 0.00001); assert(std::abs(ad.get_result()[14] - 3190895.313251) < 0.00001); assert(std::abs(ad.get_result()[25] - -4599921.087384) < 0.00001); assert(std::abs(ad.get_result()[1720] - -70588883.462685) < 0.00001); assert(std::abs(ad.get_result()[1712] - -61812361.976164) < 0.00001); assert(std::abs(ad.get_result()[1707] - -47503851.035966) < 0.00001); } catch (const DataFrameError &ex) { std::cout << ex.what() << std::endl; } }