August 2019
Intermediate to advanced
560 pages
13h 41m
English
Compute the weighted average of two numeric field values according to the formula ∑(field1*field2)/∑(field2). This toy example treats the volume field as the weight and the change field as the value. The weighted average change field of the ACWF ETF in the cf_etf_hist_price index is 0.1815:
"query": { "match": { "symbol": "ACWF"}},"aggs": {"acwf_avg_change_with_vol_weight": {"weighted_avg": {"value": {"field":"change"}, "weight": {"field": "volume"}}}}
Read now
Unlock full access