templat<typename T, typename I = unsigned long, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
struct VWAPVisitor;
|
This functor class calculates VWAP – and more - between the two column values. The first column is the index (assumed to represent time). The second column is assumed to be trade price. The third column is assumed to be trade size The constructor takes:
- The interval value for the bucket. VWAP is calculated for buckets of interval time. 0 means everything is in one bucket.
- Max Volume: Excludes trades whose size is equal or greater than Max Volume. 0 means include everything.
- Total Volume Limit: Stops calculations when the cumulative volume exceeds Total Volume Limit. 0 means there is no limit.
- A function to calculates the difference between two index values. The default is a simple subtraction.
VWAPVisitor(double interval,
double max_volume = 0,
double total_volume_limit = 0,
distance_func f = [](const I &idx1, const I &idx2) -> double {
return (static_cast(idx2 - idx1));
})
The result is a vector of following structs:
struct VWAP {
value_type vwap;
index_type index_value;
size_type event_count;
value_type total_volume;
value_type high_price;
value_type low_price;
value_type cumulative_vwap;
size_type cumulative_event_count;
value_type cumulative_total_volume;
value_type cumulative_high_price;
value_type comulative_low_price;
}
|
T: Column data type.
I: Index type.
|