volume_weighted_average_price
- qf_lib.common.utils.miscellaneous.volume_weighted_average_price.volume_weighted_average_price(prices_tms: PricesSeries, volumes_tms: QFSeries, interval: Timedelta) PricesSeries [source]
Aggregates prices in the prices_tms by calculating the average weighted price for each period. The average weighted prices are weighted by the volumes traded in each period.
- Parameters:
prices_tms (PricesSeries) – timeseries of prices which should be aggregated
volumes_tms (QFSeries) – timeseries of volumes traded; must correspond to the prices_tms
interval (Timedelta) – the length of each period from which prices should be aggregated
- Returns:
timeseries of aggregated prices; first datetimes are: first_price_datetime + interval, first_price_datetime + 2*interval, …, first_price_datetime + i*interval, where first_price_datetime is the datetime of the first price in the original prices_tms The last datetime is always <= last datetime in the prices_tms
- Return type: