I'd suggest to move the problem to the database by using this query using GROUP BY
and the respective aggregation functions:
SELECT `date`, AVG( `price` ), SUM( `qty`)
FROM `table`
GROUP BY `date`
ORDER BY `date`
In general, it is more advisable to let MySQL do such work, than first transmitting the data to your application and rearrange it there.