I have the datatable below :
qty price date 5 2 1/25 6 1 1/25 8 3 4/25 1 2 4/25
and I want :
qty price date 11 1.45 1/25 9 2.88 4/25
I have already group the datatable by date with
var groups = ToCalc.AsEnumerable().GroupBy(r => r.Field("trade_date"));
and the qty sum is like :
foreach (var group in groups) { qty = Convert.ToDouble( group.Sum(r => r.Field("EXEC_QTY"))); }
but I don't know how to calculate the weighted average price. Any idea ?