templat<typename T, typename I = unsigned long, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
struct VWBASVisitor;
|
This functor class calculates VWBAS (Volume Weighted Bid-Ask Spread) – and more - between the four column values. The first column is the index (assumed to represent time). The second column is assumed to be bid price. The third column is assumed to be ask price. The fourth column is assumed to be bid size. The fifth column is assumed to be ask size.
The constructor takes:
- The interval value for the bucket. VWBAS 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.
- A function to calculates the difference between two index values. The default is a simple subtraction.
VWBASVisitor(double interval,
double max_volume = 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 VWBAS {
value_type spread;
value_type percent_spread; // with respect to bid side
value_type vwbas;
value_type percent_vwbas; // with respect to bid side
index_type index_value;
size_type event_count;
value_type total_ask_volume;
value_type total_bid_volume;
value_type high_ask_price;
value_type low_ask_price;
value_type high_bid_price;
value_type low_bid_price;
value_type cumulative_vwbas;
size_type cumulative_event_count;
value_type cumulative_total_ask_volume;
value_type cumulative_total_bid_volume;
value_type cumulative_high_ask_price;
value_type comulative_low_ask_price;
value_type cumulative_high_bid_price;
value_type comulative_low_bid_price;
}
|
T: Column data type.
I: Index type.
|